forked from krvarma/Plotly_SparkCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotly.ino
41 lines (28 loc) · 850 Bytes
/
plotly.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// This #include statement was automatically added by the Spark IDE.
#include "plotly_spark.h"
// This #include statement was automatically added by the Spark IDE.
#include "dht.h"
#define DHTPIN D4
#define SOUNDPIN A0
#define DHTTYPE DHT22
#define NUM_TRACES 1
DHT dht(DHTPIN, DHTTYPE);
char szInfo[64];
char *streaming_tokens[NUM_TRACES] = {"<<streamtoken>>"};
plotly graph = plotly("<<username>>", "<<apikey>>", streaming_tokens, "<<filename>>", NUM_TRACES);
// Publush event
void Publish(char* szEventInfo){
Spark.publish("plotlyinfo", szEventInfo);
}
void setup() {
dht.begin();
graph.init();
graph.openStream();
}
void loop() {
float t = dht.readTemperature();
sprintf(szInfo, "Temperature=%.2f °C", t);
graph.plot(millis(), t, streaming_tokens[0]);
Publish(szInfo);
delay(60000);
}