O'Reilly logo

Arduino Networking by Marco Schwartz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Plotting the data locally

To end the chapter, we are going to see how to plot data measured by the Arduino board. To do so, we will modify the Arduino sketch a little bit, and then use part of the code from the previous chapter to plot the data right in your web browser.

First, we are going to modify the Arduino sketch so that it returns data in a more useful format; in the present case, the JSON format. In place of the code responsible to print out the measurements, we are going to simply print the data in the JSON format. This is done using the following piece of code:

client.println("HTTP/1.1 200 OK"); client.println("Content-Type: application/json"); client.println("Connection: close"); client.println(); client.print("{\"temperature\": "); client.print(temp); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required