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:07 2015 +0000
Revision:
3:f88ff0acc0b1
Parent:
2:99852a7499da
Child:
4:ca50b0858165
API Key

Who changed what in which revision?

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