Skip to main content
1-Visitor
May 14, 2017
Solved

Send sensor data to ThingWorx using Arduino and SIM808 GPRS module

  • May 14, 2017
  • 1 reply
  • 7030 views

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

Best answer by vr-6

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

1 reply

vr-61-VisitorAnswer
1-Visitor
May 15, 2017

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

mkhalil11-VisitorAuthor
1-Visitor
May 15, 2017

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

1-Visitor
May 15, 2017

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\