[CODE] add a unique logger ID (additionally to the node name)
This commit is contained in:
parent
fc7c6709ea
commit
e323df1f3f
|
@ -26,7 +26,7 @@ rtcStore_t rtcStore;
|
||||||
/* CONFIGURATION OPTIONS */
|
/* CONFIGURATION OPTIONS */
|
||||||
#ifndef NODENAME
|
#ifndef NODENAME
|
||||||
// #define NODENAME "env-huzzah-01" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
// #define NODENAME "env-huzzah-01" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
||||||
#define NODENAME "env-esp07-01" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
#define NODENAME "env-TODO" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOARD
|
#ifndef BOARD
|
||||||
|
@ -36,21 +36,28 @@ rtcStore_t rtcStore;
|
||||||
#define DB_HOSTNAME "ursaminor.fra80"
|
#define DB_HOSTNAME "ursaminor.fra80"
|
||||||
#define DB_PASSWD "c2Vuc29yczpTZW5zb3JzLXcuaW5mbHV4QGhvbWU" // BasicAuth String
|
#define DB_PASSWD "c2Vuc29yczpTZW5zb3JzLXcuaW5mbHV4QGhvbWU" // BasicAuth String
|
||||||
|
|
||||||
#if BOARD == BOARD_LOLIN
|
#if BOARD == BOARD_HUZZAH
|
||||||
#define BATT_FULL 2812
|
#define BATT_FULL 3400
|
||||||
#define BATT_CUTOFF 2280
|
|
||||||
#elif BOARD == BOARD_HUZZAH
|
|
||||||
#define BATT_FULL 3100
|
|
||||||
#define BATT_CUTOFF 2450 /* 2500=3,0V; 3080=4,0V (Battery Voltage!!!) */
|
#define BATT_CUTOFF 2450 /* 2500=3,0V; 3080=4,0V (Battery Voltage!!!) */
|
||||||
#elif BOARD == BOARD_ESP07S
|
#elif BOARD == BOARD_ESP07S
|
||||||
#define BATT_FULL 3600
|
#define BATT_FULL 3600
|
||||||
#define BATT_CUTOFF 2450 /* 2450=2,7V; 3200=3,5V (VCC Voltage) */
|
#define BATT_CUTOFF 2450 /* 2450=2,7V; 3200=3,5V (VCC Voltage) */
|
||||||
|
#elif BOARD == BOARD_LOLIN
|
||||||
|
#define BATT_FULL 2812
|
||||||
|
#define BATT_CUTOFF 2280
|
||||||
#else
|
#else
|
||||||
#error "unsupported board chosen"
|
#error "unsupported board chosen"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BOARD == BOARD_ESP07S
|
||||||
|
String loggerId = "esp07-"; // UID = this prefix + last 3 octets of the MAC address
|
||||||
|
#endif
|
||||||
|
#if BOARD != BOARD_ESP07S
|
||||||
|
String loggerId = "esp12-"; // UID = this prefix + last 3 octets of the MAC address
|
||||||
|
#endif
|
||||||
|
|
||||||
/* SETTINGS */
|
/* SETTINGS */
|
||||||
float tempOffset = -1.0;
|
float tempOffset = +0.0;
|
||||||
float humiOffset = +0.0;
|
float humiOffset = +0.0;
|
||||||
|
|
||||||
const char* host = "ursaminor.fra80";
|
const char* host = "ursaminor.fra80";
|
||||||
|
@ -62,7 +69,7 @@ const char* wlan_passwd = "IoT-Fra80";
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
String loggerName = NODENAME;
|
String loggerName = NODENAME;
|
||||||
const uint16_t sendInterval_sec = 1800; /* 1800 sec (30 min) */
|
const uint16_t sendInterval_sec = 1800; /* 1800 sec (30 min) */
|
||||||
const uint8_t sampleAvgNum = 1; /* 6 (every 5 minutes) */
|
const uint8_t sampleAvgNum = 6; /* 6 (every 5 minutes) */
|
||||||
const uint16_t sampleInterval_sec = sendInterval_sec / sampleAvgNum;
|
const uint16_t sampleInterval_sec = sendInterval_sec / sampleAvgNum;
|
||||||
String serviceUri = "/write?db=sensors";
|
String serviceUri = "/write?db=sensors";
|
||||||
#else
|
#else
|
||||||
|
@ -89,6 +96,8 @@ RTC_DATA_ATTR uint8_t sampleCnt = 0; // for average value
|
||||||
RTC_DATA_ATTR float tempAccu = 0.0; // for average value
|
RTC_DATA_ATTR float tempAccu = 0.0; // for average value
|
||||||
RTC_DATA_ATTR float humiAccu = 0.0; // for average value
|
RTC_DATA_ATTR float humiAccu = 0.0; // for average value
|
||||||
|
|
||||||
|
uint8_t chipid[6] = {0}; // WiFi MAC address
|
||||||
|
|
||||||
// setup the ADC for VCC measurement
|
// setup the ADC for VCC measurement
|
||||||
ADC_MODE(ADC_VCC);
|
ADC_MODE(ADC_VCC);
|
||||||
|
|
||||||
|
@ -173,12 +182,20 @@ void setupRtcStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
// set logger node unique ID with MAC address
|
||||||
|
char macIdString[6] = {0};
|
||||||
|
WiFi.macAddress(chipid);
|
||||||
|
sprintf(macIdString, "%02x%02x%02x", chipid[3], chipid[4], chipid[5]);
|
||||||
|
loggerId += macIdString;
|
||||||
|
|
||||||
#ifdef PRINT_INFO
|
#ifdef PRINT_INFO
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(100);
|
delay(100);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
Serial.print("[INFO ] Node ");
|
Serial.print("[INFO ] Node ");
|
||||||
|
Serial.print(loggerId);
|
||||||
|
Serial.print(", Name: ");
|
||||||
Serial.print(loggerName);
|
Serial.print(loggerName);
|
||||||
Serial.print(", BoardType: ");
|
Serial.print(", BoardType: ");
|
||||||
Serial.println(BOARD);
|
Serial.println(BOARD);
|
||||||
|
@ -234,7 +251,7 @@ void setup() {
|
||||||
if (wlanConnect()) {
|
if (wlanConnect()) {
|
||||||
|
|
||||||
// send data to influxdb
|
// send data to influxdb
|
||||||
String influxDataLine = "weather,sensor=" + loggerName + " temp=" + String(temp, 2);
|
String influxDataLine = "weather,id=" + loggerId + ",sensor=" + loggerName + " temp=" + String(temp, 2);
|
||||||
influxDataLine += ",hum=" + String(humi, 2);
|
influxDataLine += ",hum=" + String(humi, 2);
|
||||||
influxDataLine += ",batRaw=" + String(battLevel);
|
influxDataLine += ",batRaw=" + String(battLevel);
|
||||||
influxDataLine += ",bat=" + String(battPerc);
|
influxDataLine += ",bat=" + String(battPerc);
|
||||||
|
|
Loading…
Reference in a new issue