File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
example/Writing_Single_with_Auth Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ #include < ESP8266WiFi.h>
3+ #include < ESP8266WiFiMulti.h>
4+ #include < InfluxDb.h>
5+
6+ #define INFLUXDB_HOST " 192.168.0.32"
7+ #define INFLUXDB_USER " xxx"
8+ #define INFLUXDB_PASS " xxx"
9+ #define WIFI_SSID " xxx"
10+ #define WIFI_PASS " xxx"
11+
12+ ESP8266WiFiMulti WiFiMulti;
13+ Influxdb influx (INFLUXDB_HOST);
14+
15+ void setup () {
16+ Serial.begin (9600 );
17+ Serial.println (" ### Hello ###" );
18+
19+ WiFiMulti.addAP (WIFI_SSID, WIFI_PASS);
20+ Serial.print (" Connecting to WIFI" );
21+ while (WiFiMulti.run () != WL_CONNECTED) {
22+ Serial.print (" ." );
23+ delay (100 );
24+ }
25+ Serial.println (" WiFi connected" );
26+ Serial.println (" IP address: " );
27+ Serial.println (WiFi.localIP ());
28+
29+ influx.setDbAuth (" test" , INFLUXDB_USER, INFLUXDB_PASS);
30+
31+ Serial.println (" Setup done" );
32+ }
33+
34+
35+ int loopCount = 0 ;
36+
37+ void loop () {
38+ loopCount++;
39+
40+ InfluxData row (" temperature" );
41+ row.addTag (" device" , " alpha" );
42+ row.addTag (" sensor" , " one" );
43+ row.addTag (" mode" , " pwm" );
44+ row.addValue (" loopCount" , loopCount);
45+ row.addValue (" value" , random (10 , 40 ));
46+
47+ influx.write (row);
48+
49+ delay (5000 );
50+ }
You can’t perform that action at this time.
0 commit comments