vinay y.n
Published © GPL3+

Arduino to ThingSpeak via GPRS(SIM800): No Wi-Fi

Sending data from an Arduino microcontroller to the ThingSpeak platform using a GPRS module, specifically the SIM800.

BeginnerFull instructions provided6 hours867
Arduino to ThingSpeak via GPRS(SIM800): No Wi-Fi

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Gravity: Analog LM35 Temperature Sensor For Arduino
DFRobot Gravity: Analog LM35 Temperature Sensor For Arduino
×1
SIM800C
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Arduino UNO Wifi Rev.2
Arduino UNO Wifi Rev.2
×1

Software apps and online services

Arduino IDE
Arduino IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Connection Diagram

Code

Source Code

Arduino
#include <SoftwareSerial.h>
SoftwareSerial Sim800(2,3);
#include <String.h>
float temp_sen_pin = A0;
float temperature = 0;
void setup()
{
  Sim800.begin(9600);               // the GPRS baud rate   
  Serial.begin(9600);    
}
 
void loop()
{
      temperature = analogRead(temp_sen_pin);
      temperature = temperature * (5.0 / 1024.0);
      temperature = temperature * 100;
      Serial.print("Temperature = ");
      Serial.print(temperature);
      Serial.println("°C");
      delay(100);     
      
  if (Sim800.available())
    Serial.write(Sim800.read());
 
  Sim800.println("AT");
  delay(1000);
 
  Sim800.println("AT+CPIN?");
  delay(1000);
 
  Sim800.println("AT+CREG?");
  delay(1000);
 
  Sim800.println("AT+CGATT?");
  delay(1000);
 
  Sim800.println("AT+CIPSHUT");
  delay(1000);
 
  Sim800.println("AT+CIPSTATUS");
  delay(1000);
 
  Sim800.println("AT+CIPMUX=0");
  delay(1000);
  Display_feedback();
 
  Sim800.println("AT+CSTT=\"airtelgprs.com\"");//start task and setting the APN,
  delay(1000);
 
  Display_feedback();
  Sim800.println("AT+CIICR");//bring up wireless connection
  delay(1000);

  Display_feedback();
 
  Sim800.println("AT+CIFSR");//get local IP adress
  delay(1000);

  Display_feedback();
 
  Sim800.println("AT+CIPSPRT=0");
  delay(1000);

  Display_feedback();
  
  Sim800.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(2000);

  Display_feedback();

  Sim800.println("AT+CIPSEND");//begin send data to remote server
  delay(1000);
  
  Display_feedback();
  String str="GET https://api.thingspeak.com/update?api_key=5XC1TCVONJVK1PNN&field1=" + String(temperature);
 

  Serial.println(str);
  Sim800.println(str);//begin send data to remote server
  
  delay(1000);
   
  Display_feedback();
 
  Sim800.println((char)26);//sending
  delay(2000);//waitting for reply, important! the time is base on the condition of internet 
  Sim800.println();
 
  Display_feedback();
 
  Sim800.println("AT+CIPSHUT");//close the connection
  delay(100);
  
  Display_feedback();
} 
void Display_feedback()
{
  while(Sim800.available()!=0)
  Serial.write(Sim800.read());
  delay(2000); 
  
}

Credits

vinay y.n
27 projects • 51 followers
An electronic product engineer with 8 years of experience in the field. The passion for electronics began as a hobby 11 years ago.

Comments