Bulk Update json data to Thing Speak with sim 900 module-post request

Hello Everyone,

I’m buliding a IOT project (arduino based) and i have to send sensors data (json) once a day to a server for analyze and have a schematic rapresentation of them. I chose for improve my system: the famous platform:Thing Speak.

I use arduino uno board to comincate with a sim 900 module. When i try to send Post request to the server the response the server response is :

Blockquote

OK
AT+HTTPDATA=147,10000\r\nAT+HTTPDATA=147,10000

DOWNLOAD
data
OK
AT+HTTPACTION=1\r\nAT+HTTPACTION=1

OK

+HTTPACTION:1,601,0
AT+HTTPTERM\r\n

Blockquote

Here my arduino test code:

Blockquote

#include <SoftwareSerial.h>
#include <ArduinoJson.h>
/* Create object named SIM900 of the class SoftwareSerial /
SoftwareSerial SIM900(7, 8);
String data;
void setup() {
SIM900.begin(9600); /
Define baud rate for software serial communication /
Serial.begin(9600); /
Define baud rate for serial communication */

while (!Serial) continue;

const size_t bufferSize = JSON_ARRAY_SIZE(1) + 2*JSON_OBJECT_SIZE(2);
DynamicJsonBuffer jsonBuffer(bufferSize);

JsonObject& root = jsonBuffer.createObject();
root[“write_api_key”] = “my_thing_speak_key”;

JsonArray& updates = root.createNestedArray(“updates”);

JsonObject& updates_0 = updates.createNestedObject();
updates_0[“created_at”] = “2018-06-01 15:15:15-0200”;
updates_0[“field1”] = 3333;

Serial.println();

root.prettyPrintTo(data);

Serial.println(data);

delay (10000);

}

void loop() {

//Serial.print(data);

Serial.println(“HTTP post method :”);
Serial.print(“AT\r\n”);
SIM900.println(“AT”); /* Check Communication /
delay(5000);
ShowSerialData(); /
Print response on the serial monitor /
delay(5000);
/
Configure bearer profile 1 /
Serial.print(“AT+SAPBR=3,1,“CONTYPE”,“GPRS”\r\n”);
SIM900.println(“AT+SAPBR=3,1,“CONTYPE”,“GPRS””); /
Connection type GPRS */
delay(5000);
ShowSerialData();
delay(5000);
/*PROVA
Serial.print(“AT+SAPBR=3,1,“CONTYPE”,“GPRS”\r\n”);
SIM900.println(“AT+CGACT?”);
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+SAPBR=3,1,“CONTYPE”,“GPRS”\r\n”);
SIM900.println(“AT+CGACT=1,3”);
delay(5000);
ShowSerialData();
delay(5000);*/

Serial.print(“AT+SAPBR=3,1,“APN”,“internet.wind”\r\n”);
SIM900.println(“AT+SAPBR=3,1,“APN”,“internet.wind””); /* APN of the provider */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+SAPBR=1,1\r\n”);
SIM900.println(“AT+SAPBR=1,1”); /* Open GPRS context */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+SAPBR=2,1\r\n”);
SIM900.println(“AT+SAPBR=2,1”); /* Query the GPRS context */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPINIT\r\n”);
SIM900.println(“AT+HTTPINIT”); /* Initialize HTTP service */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPPARA=“CID”,1\r\n”);
SIM900.println(“AT+HTTPPARA=“CID”,1”); /* Set parameters for HTTP session */
delay(5000);
ShowSerialData();
delay(5000);

SIM900.println(“AT+HTTPPARA=“URL”,“https://api.thingspeak.com/channels/MYCHANNELID/bulk_update.json””); /* Set parameters for HTTP session */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPPARA=“CONTENT”,“application/json”\r\n”);
SIM900.println(“AT+HTTPPARA=“CONTENT”,“application/json””); /* Set CONTENT Type */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPDATA=147,10000\r\n”);
SIM900.println(“AT+HTTPDATA=147,10000”); /* POST data of size 33 Bytes with maximum latency time of 10seconds for inputting the data*/
delay(2000);
ShowSerialData();
delay(2000);

Serial.print(“data”); /* Data to be sent */
SIM900.println(data);
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPACTION=1\r\n”);
SIM900.println(“AT+HTTPACTION=1”); /* Start POST session */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+HTTPTERM\r\n”);
SIM900.println(“AT+HTTPTERM”); /* Terminate HTTP service */
delay(5000);
ShowSerialData();
delay(5000);

Serial.print(“AT+SAPBR=0,1\r\n”);
SIM900.println(“AT+SAPBR=0,1”); /* Close GPRS context */
delay(5000);
ShowSerialData();
delay(5000);
}

void ShowSerialData()
{
while(SIM900.available()!=0) /* If data is available on serial port /
Serial.write(char (SIM900.read())); /
Print character received on to the serial monitor */

}

I dont’ know if the problem is in my code or in my sim 900 module.

Thank you soo much Ravi, if you’ll help my with my project.

Francesco-Italy

Hi Francesco,

The 601 error occurs when server didn’t respond soon enough or network problem.
Check if the data you are sending is in correct format.

Regards,
Ravi