0

I am trying to send my data to HTTP server using GET method. When i am sending some hardcoded data manually it is getting stored in database successfully.

SIM900.println("AT+HTTPPARA=\"URL\",\"xxx.xxx.xxx.xxx:xxxx/xxxxxxxxx/api/iot/v1/save-data/10/20/\""); 

This is working fine and my data is getting stored successfully.

But when i am trying to send real time data i am unable to send it successfully. Let's say

float h = DHT.humidity;

float t = DHT.temperature;

SIM900.println("AT+HTTPPARA=\"URL\",\"xxx.xxx.xxx.xxx:xxxx/xxxxxxxxx/api/iot/v1/save-data/t/h/\""); 

It is storing the value as t and h instead of their real values. I tried some different methods also.

SIM900.println("AT+HTTPPARA=\"URL\",\"xxx.xxx.xxx.xxx:xxxx/xxxxxxxxx/api/iot/v1/save-data/tempData=");

SIM900.print(t);

SIM900.print("&humdData=");

SIM900.print(h);

SIM900.print("\"\r\n");  

But i am getting error.

Can anyone please help me and tell me how should i send my data to make it getting saved successfully. Thanks in advance.

User323693
  • 9,151
  • 4
  • 21
  • 50

1 Answers1

0

When you split the print into several statements, the first one should not be a println, it should be just a print. If you want, the last print statement could be

SIM900.println("\"");

In general, when trying to print a single line with embedded data you will use print() several times but only use println() once, at the end.

Elliot Alderson
  • 31,192
  • 5
  • 29
  • 67