To make the example more interesting, I decided to display the data on a chart.
For PHP, a good opensource charting library is available: JpGraph. To use it on your website, you have to upload the library files in a subfolder of your site, usually /jpgraph:
In the PHP code, you then have to include the needed libraries, depending on the type of chart you’re going to create:
sensors.requestTemperatures(); float float_temp = sensors.getTempCByIndex(0); char string_temp; dtostrf(float_temp, 4, 2, string_temp); Stash stash; byte sd = stash.create(); stash.print(string_temp); stash.save();
dtostrf(float_temp, 4, 2, string_temp);
byte sd = stash.create();
JpGraph does not take care of getting the data for the chart: the PHP code have therefore to open the file and – row by row – save the data in two arrays:
Stash::prepare(PSTR("GET /demo/saveTemp.php?temp=$H&pwd=$F HTTP/1.0" "\r\n" "Host: $F" "\r\n" "\r\n"), sd, password, website); session_id = ether.tcpSend();
With JpGraph you can create many different types of charts and – for each of them – you can make many customizations: refer to the official manual for examples and tutorials about using the library.
The source code of Arduino’s sketch and PHP pages is available in my GitHub’s repository; here are two screenshots about the example working:
Pages: 1 2