Arduino IoT projects – getting started with a SIM900 GSM Module with example

Arduino IoT projects – getting started with a SIM900 GSM Module

Introduction

IoT projects have become a culture among developers, and in the midst of some very interesting projects and business opportunities, the Tech market is booming with huge new investments being made on it. One of the key aspects of the internet of things is the capability of remote controlling devices from anywhere in the world. Dedicated networks are therefore being designed for such applications.

That's why we think you should know how to make your own IoT products!



Many IoT products have used WiFi and RF networks, but suffer from challenges of signal range. To be honest, ‘true’ IoT devices would be location-agnostic and connect to the internet from wherever they may be.

Arduino IoT Projects. Source: Udemy
Taking this approach, a good mode of communication is GSM via a Sim Card, due to its vast coverage and now a simplified way to develop on, thanks to the ready-to-use online support. GSM makes use of mobile technologies like 3G and 4G to connect a device to mobile services and the internet.

There are also ways of setting up your own IoT projects using Arduino quickly, easily and at minimal cost! Let's get into how to do that.

Choosing a Module

There are several GSM Ardiuno Shields or even stand-alone development modules that allow you to build devices capable of communicating with each other at great distances. There isn’t an official Arduino GSM shield, although a large number of third parties provide GSM shields that work equally well.
The Sim900 Chipset found on the GSM Module
We strongly recommend using a SIM900 Module. This is a development module that houses a GSM Chip, accepts a SIM Card and provides you almost all mobile functionality including SMS, Calling, Internet Connectivity and more. This module makes it possible to harness all these functions in your Arduino, Raspberry Pi or other Microcontroller projects via AT Commands using UART Serial.

To use the Sim900 Module, you will need a SIM Card with GPRS activated. You simply insert the SIM Card into the module when you want to use it.

This module supports 2G/EDGE networks. So choose your SIM Card accordingly.
Jio works on 4G and unfortunately won't be supported.

Since you can send commands to the Module via UART, you don’t even need a separate library to get started with it. You can simply use the built-in Serial or a SoftwareSerial library.

The Sim900 Module designed to easily connect with Arduino

Recommended on Amazon


Setting it up for AT Commands

To set up the SIM900 Module with the Arduino Uno, follow this connection diagram. This SIM900 Module comes with a 12V power port. It must be powered via a 12V 2A power adapter. Make sure that the Arduino and the Modules have their ground pins connected.

Follow these connections:
Connect the Module GND to Arduino GND
Connect the Module TX to Arduino Pin 7
Connect the Module RX to Arduino Pin 8

Connecting the Sim900 Module to Arduino


This makes sure that the Arduino can send AT commands to the SIM900 and receive results via Serial. All we need to do now is program the Ardiuno to do this, based on what GSM functions we want to try out.

AT Commands
AT commands are a standard text instruction protocol used to control modems. AT is short for ATtention. Every command line starts with "AT", which tells the modem that this is the start of a command. That's why these are called AT commands. GSM/GPRS modems like this SIM900 Module and even mobile phones support an AT command set that is specific to the GSM technology, which includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages) among others.

HTTP GET - How It Works

The simplest IoT Project using this Sim900 GSM Module has to be sending an HTTP GET request. HTTP GET requests are what browsers use when you open and surf websites. The GET request tells the Web Server that you are a 'Client' or a visitor and you would like to see the contents of that site. The Server then responds by sending the HTTP/CSS/JS structure of the website that your Browser then renders for you.

Browser rendering the Webpage from HTML/CSS/JS


Example Codes

This is going to be almost the same as surfing the Web, but we won't be rendering anything, since the Ardiuno and the Sim900 Module don't have Browser capabilities. Instead, we will send a GET request to a Server that responds in simple and compact JSON text.

The Test Server

One such Site is https://yesno.wtf/. They also have an API which we will use, and was probably made just for fun. It is basically a random Yes/No generator, similar to a virtual coin toss. You can try this API from your PC here.

Response from the Yes/No API. Click to enlarge.

Your first GSM Project - HTTP GET

This example reads this HTTP response from the GSM Module and prints it onto your Serial Monitor.

Use this example code: Arduino Code for this HTTP GET example.
Follow these steps:

  1. Connect your Arduino to the SIM900 Module as explained above
  2. Plug your Arduino into your PC/Laptop via USB
  3. Go to the Github code location using the link
  4. Copy the entire code from the preview
  5. Open the Arduino IDE Software and start a new project
  6. Select all the existing text in the Arduino IDE Window and delete it
  7. Now paste the copied code
  8. Make sure that your PORT and Board are set for the Ardiuno Uno
  9. Click on Upload
  10. Once Uploaded, open the Serial Monitor
  11. You should see the results of the code here!

Also check the rest of our GSM Github repository for some more sample codes we set up. There are some samples for SMS functionalities as well.

And that's it!

Hope this helps you create some great projects and get a glimpse into the world of IoT!

Comments

Popular Posts