13

If you want to submit sensor data such as temperature to a remote server/database somewhere you need to use some kind of call to a web server since it isn't possible to connect directly to a database from the Arduino.

How do you post data to a JSON web service from an Arduino that's connected to the Internet?

  • What web service are you using? – tstew Feb 13 '14 at 2:13
  • It will be one I write. – HK1 Feb 13 '14 at 12:33
4

There is the aJson library that allows you to work with JSON objects in Arduino.

However, depending on the complexity of your program, I would just do it manually to save memory. You may be able to just copy the functions you want out of the library.

Then check out the WebClient library which has an example for making a POST request at the bottom.

1

Check this from Arduino docs.

In the "Post method request" code example just define your JSON as plain text like char jsonData[] = "{name: 'yourName', data: 'yourData'}" for example, and then call byte postPage(char* domainBuffer,int thisPort,char* page,char* thisData) function passing "jsonData" variable defined before for "thisData" parameter.

It worked for me, hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.