Friday, 30 September 2016

Temperature updation on thingspeak using sim900


In this post we are going to discuss how to upload temperature on thingspeak channel using sim 900 and arduino uno. As I had already uploaded the data on thingspeak channel using sim 900 and terminal software.

Introduction:

This project is a wireless temperature logger on thingspeak channel using gsm module and arduino.
For temperature sensor, we are using lm35, that gives output in millivolt which can be easily calibrated in  terms of  °C. We have to use adc module, since it's an analog sensor. Once the raw data is converted into temperature, we can upload the data.

Now, we are ready to upload the data on thingspeak channel. Thingspeak provides api for uploading of data. Before this, we have to use activate GPRS on sim900. We also to provide APN for accessing the internet. After activating the GPRS, we have to use GET like this:

GET http://api.thingspeak.com/update?api_key=KTQXXXXXXXXXXXXX&field1=data

Replace this api with yours, and data is the data you want to be upload. You can upload a number of field like temperature, pressure, humidity, etc.
 

Stuff you need:

  1. SIM900A
  2. Arduino uno
  3. LM35 (it's output is in degree celsius)
  4. 12 volt adapter (for GSM module)
  5. Jumper wires
  6. Account on thingspeak


Connections:

Arduino                              GSM module
Pin no. 7     ======>         Tx
Pin no. 8     ======>         Rx
Gnd            ======>          Gnd

Output of LM35 is connected to A0 of arduino uno.

Arduino thinkspeak with sim900

Working:

Now coming to he working part, I am using sim900a module. It requires serial communication for its interfacing with arduino. It works on "AT" commands . Initially we can check our gsm modem using terminal software for quick testing as I had posted in the previous post. Now apn depends on the network operator e.g. I am using idea network and it's apn is "internet".

I will cover some important AT commands here:

AT  // this is for testing whether our connection is correct or not

AT+CPIN?  // whether sim is inserted or not

AT+CREG?  // whether network is registered or not

AT+CGATT?  // whether it is connected to internet or not

AT+CSTT="internet"  // connect to this apm

AT+CIPSTART="TCP","api.thingspeak.com","80"  // tcp is protocol, next is url that you want to hit and 80 is port for http

AT+CIPSEND  // data can be transferred
GET http://api.thinkspeak.com/update?api_key=KTQXXXXXXXXXXXXX&field1=58  // there are two methods in http GET and POST, we are using GET
API should be correct and field1 is the data you want to upload. Field1 can be static data or it can be variable. You can also add more field.  
After this we have to pass char 26 which indicates end of data.

Graph 


Check out the video:







  

12 comments:

  1. i am getting AT+CIPSEND ERROR

    ReplyDelete
    Replies
    1. May be your apn is wrong or there is some problem with your url

      Delete
  2. where can I get arduino code ??
    could you please help??

    ReplyDelete
  3. Download source code from the link below:

    http://funwidelectronics.blogspot.in/2017/02/temperature-logger.html

    ReplyDelete
  4. Replies
    1. If you wanna add more fields in thigspeak, there are options in the thingspeak page (private view)

      Delete
  5. how i can get continuous data reading?

    ReplyDelete
  6. Hello. Thanks for your device! Thank you, I was able to collect this and I like it. I want to go further and upgrade the device so that the data is taken from several different sensors. But I do not have enough knowledge to change the code, please help. I need to understand how the string will change so that the variables can be sent to different fields.
    Thank you.

    ReplyDelete
    Replies
    1. GET http://api.thinkspeak.com/update?api_key=KTQXXXXXXXXXXXXX&field1=58

      Delete
  7. Can you provide the code for 2 fields

    ReplyDelete
  8. i have connected the GSM modem to my PC and then i am send commands to the GSM Modem using terminal Software.
    This is what i am sending:
    AT
    AT+CPIN?
    AT+CREG?
    AT+CGATT?
    AT+CIPSHUT
    AT+CIPSTATUS
    AT+CIPMUX=0
    AT+CSTT=”www”
    AT+CIICR
    AT+CIFSR
    AT+CIPSTART=”TCP”,”api.thingspeak.com”,”80″
    AT+CIPSEND
    GET http://api.thingspeak.com/update?api_key=X4L3QD19Q7YSLK3J&field1=125
    #026

    When i use GET instruction and then send 026 i get SEND OK from the modem and then CLOSED but thingspeak channel is not updated.

    Please help

    ReplyDelete