![](/media/cache/group/Download_mxxYCWN.jpg.50x50_q85.jpg)
Plotly Cloud Dienst mit Sensorwerten
Dependencies: EthernetInterface mbed-rtos mbed plotly
Fork of Plotly_HelloWorld by
Diff: main.cpp
- Revision:
- 0:c7329ea5d8d5
- Child:
- 1:5e7145bb2184
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 11 10:11:00 2014 +0000 @@ -0,0 +1,72 @@ + +#include "mbed.h" +#include "EthernetInterface.h" +#include "plotly.h" + +Serial pc(USBTX,USBRX); + +EthernetInterface eth; + +// plotly account details +char PlotlyUsername[] = "YoutUsername"; +char PlotlyAPIToken[] = "YourAPIKey"; +char streaming_token[] = "YourStreamToken"; +char fileName[] = "Mbed Test Chart"; + +plotly graph = plotly(PlotlyUsername, PlotlyAPIToken, streaming_token, fileName); + +void plotSetup() +{ + graph.log_level = 2; // turn on status output + graph.maxpoints = 72; + if (graph.init()) { + graph.openStream(); + } + +} + +// Generate a sample chart +void plotGenerateDataPoint() +{ + static int counter = 0; + float yValue = sin(counter*3.14159/180); + graph.plot(counter, yValue); + counter+=5; +} + + +int main() +{ + pc.baud(115200); + + pc.printf("Connecting network...\n"); + + eth.init(); + eth.connect(); + + char *ipAddress = eth.getIPAddress(); + if (ipAddress && (strlen(ipAddress) > 4)) { + + pc.printf("IP Address is %s\n",eth.getIPAddress()); + pc.printf("Initalise plot..\n"); + + plotSetup(); + + pc.printf("Generating data, press any key to abort.\n"); + while (!pc.readable()) { + plotGenerateDataPoint(); + wait(0.5); + } + graph.closeStream(); + + } else + pc.printf("No IP Address\n"); + + eth.disconnect(); + + pc.printf("Done\n"); + + while (1) { + wait(10); + } +} \ No newline at end of file