cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

SOLVED
Highlighted
Level 1

Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Dear All,

I need to send sensor data to ThingWorx through GPRS module SIM808 connected to Arduino UNO. This requires using AT Command to start REST API (HTTP).I need support on how to form the below information in one http url to send it using AT Command AT+HTTPPARA

POST /Thingworx/Things/mything/Services/AlarmService HTTP/1.1

Host: academic.cloud.thingworx.com

appKey: b73a20dd-e142-4017-8eyy-a26xx

Content-Type: application/json

Cache-Control: no-cache

Postman-Token: add4f5b4d-ferf8-8e52-31ds-10ad6571asdsd

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Hi,

"AT+HTTPINIT" // Initiate

"AT+HTTPPARA"="CID",1

"AT+HTTPPARA=\"URL\",\"http://www.yourdomain.com/Thingworx/Things/<ThingName>/Services/<ServiceName>?appKey=XXXXXXXXXX\"""

"AT+HTTPPARA=\"Content\",\"application/json\"" // Content type

"AT+HTTPDATA=357, 40000"; // Size of the data

Use buffer to construct your data in JSON format.

Example: {"Temp1":"23","Temp2":"24"}


AT+HTTPACTION=1 // POST Data

AT+HTTPREAD // Read Response

AT+HTTPTERM // Terminate

10 REPLIES 10

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Hi,

"AT+HTTPINIT" // Initiate

"AT+HTTPPARA"="CID",1

"AT+HTTPPARA=\"URL\",\"http://www.yourdomain.com/Thingworx/Things/<ThingName>/Services/<ServiceName>?appKey=XXXXXXXXXX\"""

"AT+HTTPPARA=\"Content\",\"application/json\"" // Content type

"AT+HTTPDATA=357, 40000"; // Size of the data

Use buffer to construct your data in JSON format.

Example: {"Temp1":"23","Temp2":"24"}


AT+HTTPACTION=1 // POST Data

AT+HTTPREAD // Read Response

AT+HTTPTERM // Terminate

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Thanks Velkumar R​ for your response
All is clear except attaching Thing name as mentioned in your Example: {"Temp1":"23","Temp2":"24"}


if i have two Things and need to update their values top platform, how can i attach them with your mentioned flow

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Hi Mohamed,

{"Temp1":"23","Temp2":"24"}  ​is Tag and its Data. Tag must be identical to inputs of service.

TWXCo.png



If you need to update two things you need to change "Thing Name" in URL

www.yourdomain.com/Thingworx/Things/<ThingName>/Services/<ServiceName>?appKey=XXXXXXXXXX\


Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Thanks Velkumar R​, could you please share PUT code as well

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Hi Mohamed,

I think SIM 808 support only 3 HTTPACTION

AT+HTTPACTION = 0 // Read

AT+HTTPACTION = 1 //Post

AT+HTTPACTION = 2 // Head

Please check, I am not sure about that.

For REST API calls in thingworx, check below link

ThingWorx REST API Cheat Sheet

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

To invoke service, post is working fine, Thanks for support Velkumar R
For updating certain SENSOR DATA, I have constructed JSON and attached it as below, but still not reflecting in sensor value, still service only is invoked, but sensor data is not updated on ThingWorx

  StaticJsonBuffer<200> jsonBuffer;

  JsonObject& rootdata = jsonBuffer.createObject();

  rootdata["Name"] = "52";

mySerial.println("AT+HTTPPARA=\"USERDATA\",rootdata");

Could you please assess?

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Velkumar R

Could you please check this way of attaching data to my Thing

For updating certain SENSOR DATA, I have constructed JSON and attached it as below, but still not reflecting in sensor value, still service only is invoked, but sensor data is not updated on ThingWorx

  StaticJsonBuffer<200> jsonBuffer;

  JsonObject& rootdata = jsonBuffer.createObject();

  rootdata["Name"] = "52";

mySerial.println("AT+HTTPPARA=\"USERDATA\",rootdata");

Could you please assess?

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Hi Mohamed,

Did you find any error in applicaion log (TWX Platform) and what is the response code in SIM 808 while posting data.

Re: Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

Velkumar R

here is the error from ThingWorxs ,

[context: com.thingworx.webservices.context.HttpExecutionContext@78cb6519][message: Entity Not Found : [ConfiguredThing]]

from Arduino, i receive DOWNLOADas response to AT+HTTPACTION=1