Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from jotzt/master
InfluxDb authentication support
- Loading branch information
Showing
4 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
example/Writing_Single_with_Auth/Writing_Single_with_Auth.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WiFiMulti.h> | ||
#include <InfluxDb.h> | ||
|
||
#define INFLUXDB_HOST "192.168.0.32" | ||
#define INFLUXDB_USER "xxx" | ||
#define INFLUXDB_PASS "xxx" | ||
#define WIFI_SSID "xxx" | ||
#define WIFI_PASS "xxx" | ||
|
||
ESP8266WiFiMulti WiFiMulti; | ||
Influxdb influx(INFLUXDB_HOST); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
Serial.println(" ### Hello ###"); | ||
|
||
WiFiMulti.addAP(WIFI_SSID, WIFI_PASS); | ||
Serial.print("Connecting to WIFI"); | ||
while (WiFiMulti.run() != WL_CONNECTED) { | ||
Serial.print("."); | ||
delay(100); | ||
} | ||
Serial.println("WiFi connected"); | ||
Serial.println("IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
influx.setDbAuth("test", INFLUXDB_USER, INFLUXDB_PASS); | ||
|
||
Serial.println("Setup done"); | ||
} | ||
|
||
|
||
int loopCount = 0; | ||
|
||
void loop() { | ||
loopCount++; | ||
|
||
InfluxData row("temperature"); | ||
row.addTag("device", "alpha"); | ||
row.addTag("sensor", "one"); | ||
row.addTag("mode", "pwm"); | ||
row.addValue("loopCount", loopCount); | ||
row.addValue("value", random(10, 40)); | ||
|
||
influx.write(row); | ||
|
||
delay(5000); | ||
} |