Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
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
up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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