[CODE] add a unique logger ID (additionally to the node name)
This commit is contained in:
parent
efd7af4b27
commit
28f4ba44c0
|
@ -1,29 +1,29 @@
|
||||||
# ESP32 SensorNode PCB Layout, rev. 2
|
# ESP32 SensorNode PCB Layout, rev. 2
|
||||||
|
|
||||||
## Bill of Materials
|
## Bill of Materials
|
||||||
Type | Qty | Value | Footprint | Mouser
|
Type | Qty | Value | Footprint
|
||||||
----------- | --- | ------- | --------------- | -------------------
|
----------- | --- | ------- | ---------------
|
||||||
Capacitor | 3 | 0.1u | SMD 0805 | 581-08055C104KAZ2A
|
Si7021 | 1 | A20-GM1 | DFN-6
|
||||||
Capacitor | 1 | 0.01u | SMD 0805 | 80-C0805C103K5R7411
|
Switch | 1 | -x- | THT SW_PUSH_6mm
|
||||||
Capacitor | 1 | 4.7u | SMD 0805 | 963-TMK212BBJ475MD-T
|
Resistor | 2 | 22k | SMD 0805
|
||||||
Capacitor | 1 | 1u | SMD 0805 | 963-LMK212B7105KG-T
|
Capacitor | 1 | 0.01u | SMD 0805
|
||||||
Resistor | 2 | 22k | SMD 0805 | 603-RC0805FR-0722KL
|
Capacitor | 3 | 0.1u | SMD 0805
|
||||||
Si7021 | 1 | A20-GM1 | DFN-6 | 634-SI7021-A20-GM1
|
Capacitor | 1 | 1u | SMD 0805
|
||||||
VoltageReg | 1 | TC1262 | SOT-223-3 | 579-TC1262-3.3VDBTR
|
Capacitor | 1 | 4.7u | SMD 0805
|
||||||
Switch | 1 | -x- | THT SW_PUSH_6mm | 506-FSM4JH
|
VoltageReg | 1 | TC1262 | SOT-223-3
|
||||||
Resistor | 3 | 22k | THT L6.3 P10.16 |
|
Resistor | 3 | 22k | THT L6.3 P10.16
|
||||||
Resistor | 1 | 2.7M | THT L6.3 P10.16 |
|
Resistor | 1 | 2.7M | THT L6.3 P10.16
|
||||||
Resistor | 1 | 1M | THT L6.3 P10.16 |
|
Resistor | 1 | 1M | THT L6.3 P10.16
|
||||||
Resistor | 1 | 47R | THT L6.3 P10.16 |
|
Resistor | 1 | 47R | THT L6.3 P10.16
|
||||||
Capacitor | 1 | 1n | THT P7.50 Disk |
|
Capacitor | 1 | 1n | THT P7.50 Disk
|
||||||
Capacitor | 1 | 1u | THT P2.50 Rect |
|
Capacitor | 1 | 1u | THT P2.50 Rect
|
||||||
Capacitor | 1 | 100u | THT P5.00 Elko |
|
Capacitor | 1 | 100u | THT P5.00 Elko
|
||||||
Capacitor | 1 | 460u | THT P5.00 Elko |
|
Capacitor | 1 | 460u | THT P5.00 Elko
|
||||||
Diode | 1 | 1N5400 | THT | TODO
|
Diode | 1 | 1N540x | THT
|
||||||
---- | -- | ---- | ---- | ----
|
---- | -- | ---- | ----
|
||||||
Bat Holder | 1 | 18650 | x | -/-
|
Bat Holder | 1 | 18650 | x
|
||||||
ESP32 | 1 | WROOM | x | -/-
|
ESP32 | 1 | WROOM | x
|
||||||
Pin 2x07 M | 1 | -x- | THT P2.54 2x07 | -/-
|
Pin 2x07 M | 1 | -x- | THT P2.54 2x07
|
||||||
Pin 1x06 M | 1 | -x- | THT P2.54 2x07 | -/-
|
Pin 1x06 M | 1 | -x- | THT P2.54 2x07
|
||||||
Pin 1x04 M | 1 | -x- | THT P2.54 2x07 | -/-
|
Pin 1x04 M | 1 | -x- | THT P2.54 2x07
|
||||||
Pin 1x03 M | 1 | -x- | THT P2.54 2x07 | -/-
|
Pin 1x03 M | 1 | -x- | THT P2.54 2x07
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
/* CONFIGURATION OPTIONS */
|
/* CONFIGURATION OPTIONS */
|
||||||
#ifndef NODENAME
|
#ifndef NODENAME
|
||||||
#define NODENAME "env-esp32-01" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
#define NODENAME "env-TODO" /* IMPORTANT: CHANGE FOR EACH DEVICE */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOARD
|
#ifndef BOARD
|
||||||
|
@ -41,6 +41,8 @@
|
||||||
#error "unsupported board chosen"
|
#error "unsupported board chosen"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
String loggerId = "esp-"; // prefix for the last 3 octets of the MAC address
|
||||||
|
|
||||||
/* SETTINGS */
|
/* SETTINGS */
|
||||||
float tempOffset = +0.0;
|
float tempOffset = +0.0;
|
||||||
float humiOffset = +0.0;
|
float humiOffset = +0.0;
|
||||||
|
@ -66,8 +68,8 @@ String serviceUri = "/write?db=test";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GLOBAL VARIABLES */
|
/* GLOBAL VARIABLES */
|
||||||
const uint16_t wlanConnectCheckInterval = 250; /* milli seconds: poll wifi.state after wifi.begin() */
|
const uint16_t wlanConnectCheckInterval = 250; // milli seconds: poll wifi.state after wifi.begin()
|
||||||
const uint16_t wlanConnectTimeout = 15000; /* milli seconds */
|
const uint16_t wlanConnectTimeout = 15000; // milli seconds
|
||||||
RTC_DATA_ATTR uint8_t wlanConnectFailCnt = 0;
|
RTC_DATA_ATTR uint8_t wlanConnectFailCnt = 0;
|
||||||
|
|
||||||
Si7021 si7021 = Si7021();
|
Si7021 si7021 = Si7021();
|
||||||
|
@ -81,6 +83,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
|
||||||
|
|
||||||
#ifdef PRINT_INFO
|
#ifdef PRINT_INFO
|
||||||
#define INFO_PRINT(x) Serial.print(x)
|
#define INFO_PRINT(x) Serial.print(x)
|
||||||
#define INFO_PRINTLN(x) Serial.println(x)
|
#define INFO_PRINTLN(x) Serial.println(x)
|
||||||
|
@ -161,12 +165,20 @@ extern "C" void app_main() {
|
||||||
pinMode(4, OUTPUT);
|
pinMode(4, OUTPUT);
|
||||||
digitalWrite(4, HIGH);
|
digitalWrite(4, HIGH);
|
||||||
|
|
||||||
|
// set logger node unique ID with MAC address
|
||||||
|
char macIdString[6] = {0};
|
||||||
|
esp_efuse_mac_get_default(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);
|
||||||
|
@ -222,7 +234,7 @@ extern "C" void app_main() {
|
||||||
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