Plotly Online-Analytik und Datenvisualisierungstool Beispiel

Dependencies:   EthernetInterface mbed-rtos mbed plotly

Fork of PlotlySensorChart by th.iotkit2.ch

Plotly ist ein Online-Analytik und Datenvisualisierungstool. Plotly bietet Werkzeuge für Online-Grafiken, Analysen und Statistiken sowie wissenschaftliche Grafik-Bibliotheken für Python , R , MATLAB , Perl , Julia , Arduino und REST.

Weitere Informationen zum Anpassen des Charts etc. siehe Arduino Tutorial (scrollen nach Usage and Docs)

plot.ly verwendet Username, API Key zusammen mit Tokens zur Eindeutigen Authentifizierung.

Das Chart ist nach laden des Programmes auf folgender Adresse abrufbar: https://plot.ly/~mc-b/11

Committer:
stefan1691
Date:
Fri Mar 27 09:57:36 2015 +0000
Revision:
4:ca50b0858165
Parent:
3:f88ff0acc0b1
URL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefan1691 4:ca50b0858165 1 /** Plotly Cloud Dienst mit Sensorwerten
stefan1691 4:ca50b0858165 2 https://plot.ly/~mc-b/11
stefan1691 4:ca50b0858165 3 */
AndyA 0:c7329ea5d8d5 4 #include "mbed.h"
AndyA 0:c7329ea5d8d5 5 #include "EthernetInterface.h"
AndyA 0:c7329ea5d8d5 6 #include "plotly.h"
AndyA 0:c7329ea5d8d5 7
AndyA 0:c7329ea5d8d5 8 Serial pc(USBTX,USBRX);
AndyA 0:c7329ea5d8d5 9 EthernetInterface eth;
stefan1691 2:99852a7499da 10 // Sensoren (Poti, Light, Hall)
stefan1691 2:99852a7499da 11 AnalogIn sensors[] = { A0, A1, A2 };
AndyA 0:c7329ea5d8d5 12
AndyA 0:c7329ea5d8d5 13 // plotly account details
AndyA 1:5e7145bb2184 14 const int numberOfTraces = 3;
stefan1691 3:f88ff0acc0b1 15 const char PlotlyUsername[] = "mc-b";
stefan1691 3:f88ff0acc0b1 16 const char PlotlyAPIToken[] = "ggngm3tplt";
stefan1691 3:f88ff0acc0b1 17 const char *PlotlyStreamingTokens[numberOfTraces] = {"9vdxtza25l","0pfcxy8fp3", "mpyq3oowhe"}; // or {"YourStreamToken"} for a single line. Must match numberOfTraces
AndyA 1:5e7145bb2184 18 const char PlotlyFileName[] = "Mbed Test Chart";
AndyA 0:c7329ea5d8d5 19
AndyA 1:5e7145bb2184 20 plotly graph = plotly(PlotlyUsername,PlotlyAPIToken, PlotlyStreamingTokens, PlotlyFileName, numberOfTraces);
AndyA 0:c7329ea5d8d5 21
AndyA 0:c7329ea5d8d5 22 void plotSetup()
AndyA 0:c7329ea5d8d5 23 {
AndyA 1:5e7145bb2184 24 graph.log_level = 1; // turn on status output
AndyA 0:c7329ea5d8d5 25 graph.maxpoints = 72;
stefan1691 2:99852a7499da 26 if (graph.init())
AndyA 1:5e7145bb2184 27 graph.openStreams();
AndyA 0:c7329ea5d8d5 28 }
AndyA 0:c7329ea5d8d5 29
AndyA 1:5e7145bb2184 30 // Generate some simple sample data points
AndyA 0:c7329ea5d8d5 31 void plotGenerateDataPoint()
AndyA 0:c7329ea5d8d5 32 {
AndyA 1:5e7145bb2184 33 static float counter = 0;
AndyA 1:5e7145bb2184 34
AndyA 1:5e7145bb2184 35 // generate a series of sine waves with slightly different frequencies.
stefan1691 2:99852a7499da 36 for (int i = 0; i < numberOfTraces; i++)
stefan1691 2:99852a7499da 37 graph.plot(counter, sensors[i].read(), i);
AndyA 1:5e7145bb2184 38
stefan1691 2:99852a7499da 39 counter+=0.2f;
AndyA 0:c7329ea5d8d5 40 }
AndyA 0:c7329ea5d8d5 41
stefan1691 2:99852a7499da 42 /** Hauptprogramm */
AndyA 0:c7329ea5d8d5 43 int main()
AndyA 0:c7329ea5d8d5 44 {
AndyA 0:c7329ea5d8d5 45 pc.printf("Connecting network...\n");
AndyA 0:c7329ea5d8d5 46 eth.init();
AndyA 0:c7329ea5d8d5 47 eth.connect();
AndyA 0:c7329ea5d8d5 48
AndyA 0:c7329ea5d8d5 49 char *ipAddress = eth.getIPAddress();
stefan1691 2:99852a7499da 50 if (ipAddress && (strlen(ipAddress) > 4))
stefan1691 2:99852a7499da 51 {
AndyA 0:c7329ea5d8d5 52 pc.printf("IP Address is %s\n",eth.getIPAddress());
AndyA 0:c7329ea5d8d5 53 pc.printf("Initalise plot..\n");
AndyA 0:c7329ea5d8d5 54
AndyA 0:c7329ea5d8d5 55 plotSetup();
AndyA 0:c7329ea5d8d5 56
AndyA 0:c7329ea5d8d5 57 pc.printf("Generating data, press any key to abort.\n");
stefan1691 2:99852a7499da 58 while ( !pc.readable() )
stefan1691 2:99852a7499da 59 {
AndyA 0:c7329ea5d8d5 60 plotGenerateDataPoint();
stefan1691 2:99852a7499da 61 wait(2.0);
stefan1691 2:99852a7499da 62 }
AndyA 1:5e7145bb2184 63 graph.closeStreams();
AndyA 0:c7329ea5d8d5 64
stefan1691 2:99852a7499da 65 }
stefan1691 2:99852a7499da 66 else
AndyA 0:c7329ea5d8d5 67 pc.printf("No IP Address\n");
AndyA 0:c7329ea5d8d5 68
AndyA 0:c7329ea5d8d5 69 eth.disconnect();
AndyA 0:c7329ea5d8d5 70 pc.printf("Done\n");
stefan1691 2:99852a7499da 71 return ( 0 );
AndyA 0:c7329ea5d8d5 72 }