Uploading sensor values online using SIM 900

Good day folks, I am currently building a smart irrigation project using the Arduino UNO.
Basically, a soil moisture sensor starts and stop a 12V DC water pump. A DHT 11 temperature sensor is just used for indication. I was able to get this part functioning correctly.

I would like to go a step further and upload the moisture and temperature values online. This is the part I am having difficulty with. I have tried to upload to temboo, thingspeak and google sheets via pushingbox. The only luck I had was using thingspeak. Unfortunately, the values loaded are not the values I am seeing on the serial monitor. The values are upward of 500 on the online chart but 29 on the Arduino serial monitor. I am using a GSM 900 shield.

My aim is to monitor the temperature and soil values remotely using the simplest method possible whether it is thingspeak, google sheets or a simple http web page. Any advice achieving this would be greatly appreciated.

Attached is the code i got working with thingspeak but the values are showing upward of 500 and not 29 or 30 degrees celcius as it should.

#include <SoftwareSerial.h>
#include <String.h>
#include <dht.h>
int sensorPin = 0;    // set the input pin for the potentiometer
int sensorValue = 0;

dht DHT;

#define DHT11_PIN A0

 
SoftwareSerial gprsSerial(7,8);


float temp=0.0;


void setup()
{
  gprsSerial.begin(9600);               // the GPRS baud rate   
  Serial.begin(9600);    // the GPRS baud rate 

  delay(1000);
}
 
void loop()
{
      int chk = DHT.read11(DHT11_PIN);
      temp=analogRead(A0);
      delay(2);          
      
   
  if (gprsSerial.available())
    Serial.write(gprsSerial.read());

  gprsSerial.println("AT");
  delay(1000);

  gprsSerial.println("AT+CPIN?");
  delay(1000);

  gprsSerial.println("AT+CREG?");
  delay(1000);

  gprsSerial.println("AT+CGATT?");
  delay(1000);

  gprsSerial.println("AT+CIPSHUT");
  delay(1000);

  gprsSerial.println("AT+CIPSTATUS");
  delay(2000);

  gprsSerial.println("AT+CIPMUX=0");
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CSTT=\"myAPN\"");//start task and setting the APN,
  delay(1000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSPRT=0");
  delay(3000);
 
  ShowSerialData();
  
  gprsSerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(6000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  
    String str="GET https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&field1=0" + String(temp);
  gprsSerial.println(temp);//begin send data to remote server
  delay(4000);
  ShowSerialData();

  gprsSerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet 
  gprsSerial.println();
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSHUT");//close the connection
  delay(100);
  ShowSerialData();
} 
void ShowSerialData()
{
  while(gprsSerial.available()!=0)
    Serial.write(gprsSerial.read());
}

You can print out the URL that is formed for sending before going into CIPSEND and share here to see whats getting sent in URL.

Thnaks for the reply. I have little programming experience so can you please clarify what you asked to “print out the URL”.

Print out the contents of str once it has been formed. There you can see what is going in the parameters of the GET request

   AT
AT+CPIN?
AT+CREG?
AT+CGATT?
AT+CIPSHUT
AT+CIPSTATUS
ATAT+CSTT="myApn"
AT+CIICR
AT+CIFSR
AT+CIPSPRT=0
AT+CIPSTART="TCP","api.thingspeak.com","80"
AT+CIPSEND
Temperature = 23.00
GET https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&

SEND OK
359

This is what I am seeing on the serial monitor as I added:

  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);

But the value I am seeing on thingspeak is 325

The data is not sent like that in a get request,
The URL should have the data, something like,
https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&Temperature=23

You are printing out the Temperature first, its wrong. First statement you send to module should start with GET http…

#include <SoftwareSerial.h>
#include <String.h>
#include <dht.h>
int sensorPin = 0;    // set the input pin for the potentiometer
int sensorValue = 0;

dht DHT;

#define DHT11_PIN A0

 
SoftwareSerial gprsSerial(7,8);


float temp=0.0;

void setup()
{
  gprsSerial.begin(9600);               // the GPRS baud rate   
  Serial.begin(9600);    // the GPRS baud rate 

  delay(1000);
}
 
void loop()
{
      temp=analogRead(A0);
      temp=temp*0.4887;  
      delay(2);          
      
   
  if (gprsSerial.available())
    Serial.write(gprsSerial.read());

  gprsSerial.println("AT");
  delay(1000);

  gprsSerial.println("AT+CPIN?");
  delay(1000);

  gprsSerial.println("AT+CREG?");
  delay(1000);

  gprsSerial.println("AT+CGATT?");
  delay(1000);

  gprsSerial.println("AT+CIPSHUT");
  delay(1000);

  gprsSerial.println("AT+CIPSTATUS");
  delay(2000);

  gprsSerial.println("AT+CIPMUX=0");
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CSTT=\"myApn\"");//start task and setting the APN,
  delay(1000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSPRT=0");
  delay(3000);
 
  ShowSerialData();
  
  gprsSerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(6000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  
  String str="GET https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&field1=0" + String(temp);
  Serial.println(str);
  gprsSerial.println(str);//begin send data to remote server
  delay(4000);
  ShowSerialData();

  gprsSerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet 
  gprsSerial.println();
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSHUT");//close the connection
  delay(100);
  ShowSerialData();
} 
void ShowSerialData()
{
  while(gprsSerial.available()!=0)
    Serial.write(gprsSerial.read());


  int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay(5000); 
  sensorValue = analogRead(sensorPin);     
  delay(1000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);
    sensorValue = analogRead(sensorPin);     
  delay(5000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);  
}

This is the new code I uploaded and I placed the Serial.print("Temperature = "); code lines to the end of the code as you indicated that I should perform the GET request first and not the serial printing. (please correct me If I am wrong).

After using this code, the serial monitor shows this:

OK
CONNECT OKTemperature = 28.00
Humidity = 74.00
sensor = 1023
sensor = 1023
AT+CIPSEND
Temperature = 28.00
Humidity = 75.00
sensor = 1023
sensor = 1023
GET https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&field1=0499.94
GET https://api.thingspeak.com/update?api_key=QT7O3U5O8HFEFBY8&Temperature = 28.00
Humidity = 74.00
sensor = 1023
sensor = 1023
SEND OK
523Temperature = 28.00
Humidity = 74.00
sensor = 1023
sensor = 1023
CLOSED
Temperature = -999.00
Humidity = -999.00

Haiii…I am new here. I am currently working on a project where i have to send dht11 sensor data to web server using POST method from GSM SIM900A and Arduino Uno. I have server API key also. Kindly help me in this. Thanks in advance.