Arduino Projects

Arduino SIM800L Blynk, Arduino publish data to Blynk, Arduino Blynk

Arduino SIM800L Blynk:

Arduino SIM800L Blynk

Arduino SIM800L Blynk, Arduino publish data to Blynk, Arduino Blynk- In today’s article, we are going to use the versatile SIM800L GSM/GPRS module with the Arduino. Our project centers around controlling not one, but four relays connected to bulbs, and closely monitoring temperature changes using the DS18b20, a robust one-wire waterproof digital temperature sensor.

But that’s not all! We’re taking control and monitoring to the next level with the Blynk Application.

This powerful application will be our command center, allowing us to keep an eye on the temperature readings and manage the lighting setup right from our smartphones.




Amazon Links:

Arduino Nano

SIM800L GSM/GPRS module

DS18B20 Temperature Sensor

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Next, what I am going to explain, you need to listen carefully and then you have to decide whether you want to use the SIM800L GSM/GPRS module or not.



About SIM800L:

Network Compatibility:

The SIM800L operates on quad-band GSM/GPRS frequencies (850/900/1800/1900 MHz), making it compatible with GSM network standards worldwide.

Features:

It supports voice calls, SMS messages, and data transmission via GPRS. Its small size and low power consumption make it suitable for mobile applications and IoT projects.

Applications:

Common uses include vehicle tracking, remote control systems, small-scale IoT applications, and any scenario where a basic cellular connection is needed.

Usage in Different Countries:

Developing Countries:

In developing countries like Pakistan and India, where 2G networks are still widely used, the SIM800L is highly relevant. These regions often maintain robust 2G infrastructure due to the widespread use of basic mobile phones and the slower adoption of more advanced network technologies.

In the place where I live, modern cellular networks like 3G and 4G are operational and accessible. However, despite the availability of these newer, faster networks, the infrastructure for 2G services is still supported. This means that the spectrum (the range of electromagnetic radio frequencies used for communication) is still allocated for 2G services, allowing devices and technologies that rely on 2G networks, such as the SIM800L GSM/GPRS module, to function. This scenario is common in many regions where there’s a gradual transition to advanced network technologies while maintaining support for older ones.

Developed Countries:

In contrast, developed countries like the USA, Canada, and many in Europe, are phasing out 2G networks in favor of more advanced 3G, 4G, and 5G networks. As 2G networks are being decommissioned in many developed countries, devices that rely solely on these networks, like the SIM800L, lose their functionality. In some cases, regulatory bodies in certain countries might decide to repurpose the spectrum used for 2G services for more advanced network technologies, leading to a phase-out of 2G.

I’m not sure about your location and whether 2G services are still operational there. If your area does support 2G network infrastructure, then you can effectively use a 2G SIM card in your SIM800L module. This will allow you to connect to the network and create amazing IoT projects.



Anyway, in my experience, when I tried using 3G and 4G SIM cards with the SIM800L module, it wouldn’t connect to the network. However, when I switched to an older 2G Ufone SIM card, the connection was successful almost immediately. This shows that the SIM800L module works best with 2G networks. So, if you’re planning to use this module, I recommend using a 2G SIM card. While 2G might seem outdated, many countries still offer these SIM cards, so you should be able to find one for your project.

Arduino SIM800L Blynk

As you can see in my setup, once the SIM800L module is connected to the internet, it’s fully functional. I can monitor temperature changes – watch as I apply some heat and notice the temperature rise.

Arduino SIM800L Blynk



Now, let’s move on to controlling these four bulbs.

Arduino SIM800L Blynk

Remember, safety first: When the 110/220Vac supply is connected, never touch the relay contacts as it can be extremely dangerous. It is important to note that when working with mains voltage, proper safety precautions should always be taken, and it is advisable to consult relevant electrical codes and standards.

Arduino SIM800L Blynk

As demonstrated, I can control all four bulbs with ease.

If the SIM800L module isn’t suitable for your area due to network compatibility, don’t worry. In my next video, I’ll introduce the SIM7600G LTE module, which is compatible with 2G, 3G, and 4G networks.

Arduino SIM800L Blynk

This module offers greater flexibility for different network environments. So, consider subscribing, if you don’t want to miss any of my upcoming tutorials using this module. Anyway, let’s take a look at the wiring.




SIM800L Module interfacing with Arduino:

Arduino SIM800L Blynk

As usual I am using my designed Arduino Nano Development board but you can also use Arduino Uno. The reason I am using this development board is because on this board I have a 5V and 3A power supply which is more than enough to power up the Arduino, GSM SIM800L module, and all the other electronics. I have talked about the SIM800L module technical specifications, power supply requirements, and related issues in detail in my getting started article on the SIM800L module.

Arduino SIM800L Blynk

Connect the VCC and GND pins of the SIM800L module to the 5V and 3A power supply. Connect the TXD pin to the Arduino D9 and connect the RXD pin to the Arduino D10.

The 5V SPDT type relays and are connected to the Arduino pins D4, D5, D6, and D7.

Connect the VCC and GND wires of the DS18B20 temperature sensor to the Arduino 3.3V and GND. Connect the Data pin to the Arduino Pin D3. And don’t forget to add a 10K resistor between the VCC and Data wire.

You can see the Vin and GND wires in the circuit diagram. Simply, connect these wires to a 5V and 3A power supply.

Arduino SIM800L Blynk

You can follow this circuit diagram; if you want to make your own 5V and 3A power supply. Now, let’s start with the Blynk Web Dashboard setup.



Blynk Web Dashboard Setup:

While you are logged-in into your Blynk account. Click on the New Template.

Arduino SIM800L Blynk

Write the Template Name, select the Hardware, and select the connection type as GSM. Finally, click on the Done button.

Then click on the Datastreams and click on the new Datastream and select the virtual pin.

Arduino SIM800L Blynk

Write name of the virtual Pin “Temperature”, select the PIN V0, select the DATA TYPE, select the UNITS, and define the MIN and MAX values. Finally, click on the Create button.

Arduino SIM800L Blynk

Now again click on the new Datastream and select the virtual pin. Write name of the virtual Pin “Relay1”, Select the PIN “V1”, Select the DATA TYPE “Integer”, set the UNITS to “None”, and select the MIN and MAX values as 0 and 1.

Arduino SIM800L Blynk

Following the same exact steps, create three more virtual pins for the remaining 3 relays and assign Virtual Pins V2, V3, and V4; as you can see in the image below.

Arduino SIM800L Blynk

Then click on the web Dashboard.

Arduino SIM800L Blynk



Double click on the Gauge or drag and drop the gauge from the Widget Box. Then click on the settings “Gear Icon”.

Arduino SIM800L Blynk

Select the Datastream Temperature(V0).

Arduino SIM800L Blynk

Next, add 4 switches the way we added the Gauge widget and assign the corresponding Datastreams; as you can see in the image below.

Arduino SIM800L Blynk

All the 5 widgets have been added to the Web Dashboard. We will be using the Gauge for the temperature monitoring and all the other switches for controlling the output loads. Anyway, make sure you click on the save button.

Click on the Devices on the left side, under the Developer Zone.

Arduino SIM800L Blynk



Click the + New Device and then click on the “From template”.

Arduino SIM800L Blynk

Select the DS18B20 template and click on the create button.

Arduino SIM800L Blynk

Then copy the credentials.

Arduino SIM800L Blynk

When the dashboard is ready, simply copy these credentials, open the program and paste the credentials as you can see in the prom given below.




Arduino SIM800L Blynk, Programming:

//-----------------------------------------------------------------------
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
//-----------------------------------------------------------------------
#define BLYNK_TEMPLATE_ID "TMPL6gW5tkaBt"
#define BLYNK_TEMPLATE_NAME "DS18B20 sensor with Arduino using SIM800"
#define BLYNK_AUTH_TOKEN "_do7cL1tmYPbkfunT3rZYCv790AIUElX"
//-----------------------------------------------------------------------
// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE
//-----------------------------------------------------------------------
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30
//-----------------------------------------------------------------------
#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
//-----------------------------------------------------------------------
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
//-----------------------------------------------------------------------
// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "ufone.pinternet";
char user[] = "";
char pass[] = "";


//-----------------------------------------------------------------------
// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(9, 10); // TXpin=9 RXpin=10
TinyGsm modem(SerialAT);
//-----------------------------------------------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
// Setup a oneWire instance to communicate with any OneWire devices
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);
float temp;
int Relay1 = 4;
int Relay2 = 5;
int Relay3 = 6;
int Relay4 = 7;
//-----------------------------------------------------------------------
BlynkTimer timer;
#define INTERVAL 1000L
//-----------------------------------------------------------------------
void SendData()
{
  // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
  sensors.requestTemperatures(); 
  temp=sensors.getTempCByIndex(0);
  Blynk.virtualWrite(V0,temp);
}


/************************************************************************************
 *  setup() function
 **********************************************************************************/
void setup()
{
  //-----------------------------------------------------------
  // Debug console
  Serial.begin(115200);
   pinMode(Relay1,OUTPUT);
 pinMode(Relay2,OUTPUT);
 pinMode(Relay3,OUTPUT);
 pinMode(Relay4,OUTPUT);
  delay(10);
  //-----------------------------------------------------------
  // Set GSM module baud rate
  SerialAT.begin(9600);
  //SerialAT.begin(9600,SWSERIAL_8N1,D3,D4);
  delay(3000);
  //-----------------------------------------------------------
  sensors.begin();
  //-----------------------------------------------------------
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();
  //-----------------------------------------------------------
  Blynk.begin(auth, modem, apn, user, pass);
  //-----------------------------------------------------------
  // Setup a function to be called every second
  timer.setInterval(INTERVAL, SendData);
  //-----------------------------------------------------------  
}


/************************************************************************************
 *  loop() function
 **********************************************************************************/
void loop()
{
  Blynk.run();
  timer.run();
}


 BLYNK_WRITE(V1) // From Blynk to the ESP32, to control a Relay
{
  int pinValue1 = param.asInt();
  digitalWrite(Relay1 , pinValue1);
  
  }
     BLYNK_WRITE(V2) // From Blynk to the ESP32, to control a Relay
{
  int pinValue2 = param.asInt();
  digitalWrite(Relay2 , pinValue2);
  
  }
     BLYNK_WRITE(V3) // From Blynk to the ESP32, to control a Relay
{
  int pinValue3 = param.asInt();
  digitalWrite(Relay3 , pinValue3);
  
  }
     BLYNK_WRITE(V4) // From Blynk to the ESP32, to control a Relay
{
  int pinValue4 = param.asInt();
  digitalWrite(Relay4 , pinValue4);
  
  }

Don’t forget to change the GPRS Credentials.

Before, you upload the program, make sure you have installed the required libraries. Simply copy the library name, then go to the Sketch menu, then to Include Library, and click on the Manage Libraries. Paste the library name in the search box, as you can see I have already installed this library.

Arduino SIM800L Blynk




Next, you will also need to install the entire Blynk library package, for this simply type Blynk in the search box.

Arduino SIM800L Blynk

You can see I have also installed this library. It works with over 400 boards.

Finally, you can upload the program, in my case I have already uploaded this program. Anyway, go back to the Blynk web dashboard and check if you can monitor the sensor and control the relays.

Arduino SIM800L Blynk

If it’s working then congrats you have done it. Next, you can start with the Blynk IoT Application setup on your Smartphone.



Blynk IoT App setup on Smartphone:

Open the Blynk IoT App and click on the DS18B20 sensor with Arduino using SIM800 template.

Arduino SIM800L Blynk

Click on the settings icon to enter in the developer mode. Then rest of the process is pretty straightforward. Simply, add a Gauge and 4 switches, and assign the corresponding Datastreams. Your Application should look something like this.

Arduino SIM800L Blynk

If you face any issues then watch the video tutorial on my YouTube channel “Electronic Clinic”.

So, that’s all for now.



Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

One Comment

  1. Hi my two points:
    1. I’m afraid that there is a major flaw in the circuit, SIM800 module can accept max 4.2V, internal voltage monitor will trigger over-voltage protection most probably above that level or close to 4.4V at 5V module will not survive very long.
    2. In the transfer mode SIM800 will use at max 2A so 3A power supply is not really needed, a big capacitor at around 2200uf between the VIN and GND will help to stabilise the power supply.

    Other than this it’s a nice concept 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button