From 27bcaf16cc1165a49be1a7f35bbd1b2cdb8fc193 Mon Sep 17 00:00:00 2001 From: sensorsiot Date: Sat, 21 May 2022 17:32:54 +0200 Subject: [PATCH 1/4] Credentials cleaned up Only one set of credentials is used (according the #define CREDENTIALS) --- Examples/1_LoRa_Sensor/fdrs_sensor.h | 29 +++++++++++++++------- Examples/4_UART_Gateway/4_UART_Gateway.ino | 2 ++ Examples/4_UART_Gateway/defaults.h | 4 --- Examples/4_UART_Gateway/fdrs_config.h | 19 +++++++++----- Examples/5_MQTT_Gateway/defaults.h | 4 --- Examples/5_MQTT_Gateway/fdrs_config.h | 8 ++++++ Examples/5_MQTT_Gateway/fdrs_functions.h | 2 +- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/Examples/1_LoRa_Sensor/fdrs_sensor.h b/Examples/1_LoRa_Sensor/fdrs_sensor.h index 6010e70..7c9b973 100644 --- a/Examples/1_LoRa_Sensor/fdrs_sensor.h +++ b/Examples/1_LoRa_Sensor/fdrs_sensor.h @@ -12,7 +12,7 @@ #define DEEP_SLEEP //#define POWER_CTRL 14 #define DEBUG -#define CREDENTIALS +#define CREDENTIALS #define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE //LoRa Configuration @@ -22,13 +22,23 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 //May be overwritten if CREDENTIALS is set + #ifdef CREDENTIALS #include +#define WIFI_NET mySSID +#define WIFI_PASS myPASSWORD +#define MQTT_ADDR MQTT_BROKER +#define BAND myBAND +#else +#define WIFI_NET "Your SSID" +#define WIFI_PASS "Password" +#define MQTT_ADDR "192.168.0.8" + +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +#define BAND 915E6 #endif typedef struct __attribute__((packed)) DataReading { @@ -97,7 +107,7 @@ void beginFDRS() { #ifdef DEBUG Serial.begin(115200); #endif - DBG("FDRS Sensor ID " + String(READING_ID)+ " initializing..."); + DBG("FDRS Sensor ID " + String(READING_ID) + " initializing..."); DBG(" Gateway: " + String (GTWY_MAC, HEX)); #ifdef POWER_CTRL DBG("Powering up the sensor array!"); @@ -136,6 +146,7 @@ void beginFDRS() { #endif #ifdef USE_LORA DBG("Initializing LoRa!"); + DBG(BAND); #ifndef __AVR__ SPI.begin(SCK, MISO, MOSI, SS); #endif @@ -181,9 +192,9 @@ void loadFDRS(float d, uint8_t t) { data_count++; } void sleepFDRS(int sleep_time) { -DBG("Sleepytime!"); + DBG("Sleepytime!"); #ifdef DEEP_SLEEP -DBG(" Deep sleeping."); + DBG(" Deep sleeping."); #ifdef ESP32 esp_sleep_enable_timer_wakeup(sleep_time * 1000000); esp_deep_sleep_start(); @@ -192,6 +203,6 @@ DBG(" Deep sleeping."); ESP.deepSleep(sleep_time * 1000000); #endif #endif -DBG(" Delaying."); + DBG(" Delaying."); delay(sleep_time * 1000); } diff --git a/Examples/4_UART_Gateway/4_UART_Gateway.ino b/Examples/4_UART_Gateway/4_UART_Gateway.ino index c851532..ee4f44d 100644 --- a/Examples/4_UART_Gateway/4_UART_Gateway.ino +++ b/Examples/4_UART_Gateway/4_UART_Gateway.ino @@ -51,6 +51,7 @@ void setup() { client.setServer(mqtt_server, 1883); if (!client.connected()) { DBG("Connecting mqtt..."); + DBG(mqtt_server); reconnect(); } client.setCallback(mqtt_callback); @@ -59,6 +60,7 @@ void setup() { #endif #ifdef USE_LORA DBG("Initializing LoRa!"); + DBG(BAND); SPI.begin(SCK, MISO, MOSI, SS); LoRa.setPins(SS, RST, DIO0); if (!LoRa.begin(BAND)) { diff --git a/Examples/4_UART_Gateway/defaults.h b/Examples/4_UART_Gateway/defaults.h index e1cdabc..c80a912 100644 --- a/Examples/4_UART_Gateway/defaults.h +++ b/Examples/4_UART_Gateway/defaults.h @@ -25,10 +25,6 @@ //#define RXD2 21 //#define TXD2 22 -#define WIFI_NET "Your SSID" -#define WIFI_PASS "Password" -#define MQTT_ADDR "192.168.0.8" - //#define USE_LORA #define SCK 5 #define MISO 19 diff --git a/Examples/4_UART_Gateway/fdrs_config.h b/Examples/4_UART_Gateway/fdrs_config.h index 3f2aaaa..dc494b5 100644 --- a/Examples/4_UART_Gateway/fdrs_config.h +++ b/Examples/4_UART_Gateway/fdrs_config.h @@ -32,16 +32,23 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 //WiFi Configuration -- Needed only if is using MQTT + + +#ifdef CREDENTIALS +#include +#define WIFI_NET mySSID +#define WIFI_PASS myPASSWORD +#define MQTT_ADDR MQTT_BROKER +#define BAND myBAND +#else #define WIFI_NET "Your SSID" #define WIFI_PASS "Password" #define MQTT_ADDR "192.168.0.8" -#ifdef CREDENTIALS -#include +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +#define BAND 915E6 #endif diff --git a/Examples/5_MQTT_Gateway/defaults.h b/Examples/5_MQTT_Gateway/defaults.h index e1cdabc..c80a912 100644 --- a/Examples/5_MQTT_Gateway/defaults.h +++ b/Examples/5_MQTT_Gateway/defaults.h @@ -25,10 +25,6 @@ //#define RXD2 21 //#define TXD2 22 -#define WIFI_NET "Your SSID" -#define WIFI_PASS "Password" -#define MQTT_ADDR "192.168.0.8" - //#define USE_LORA #define SCK 5 #define MISO 19 diff --git a/Examples/5_MQTT_Gateway/fdrs_config.h b/Examples/5_MQTT_Gateway/fdrs_config.h index 8d4483c..9765aba 100644 --- a/Examples/5_MQTT_Gateway/fdrs_config.h +++ b/Examples/5_MQTT_Gateway/fdrs_config.h @@ -44,4 +44,12 @@ #ifdef CREDENTIALS #include +#define WIFI_NET mySSID +#define WIFI_PASS myPASSWORD +#define MQTT_ADDR MQTT_BROKER +#define BAND myBAND +#else +#define WIFI_NET "Your SSID" +#define WIFI_PASS "Password" +#define MQTT_ADDR "192.168.0.8" #endif diff --git a/Examples/5_MQTT_Gateway/fdrs_functions.h b/Examples/5_MQTT_Gateway/fdrs_functions.h index d22d552..afedd47 100644 --- a/Examples/5_MQTT_Gateway/fdrs_functions.h +++ b/Examples/5_MQTT_Gateway/fdrs_functions.h @@ -9,7 +9,7 @@ const uint8_t espnow_size = 250 / sizeof(DataReading); const uint8_t lora_size = 256 / sizeof(DataReading); const uint8_t mac_prefix[] = {MAC_PREFIX}; - esp_now_peer_info_t peerInfo; +// esp_now_peer_info_t peerInfo; uint8_t broadcast_mac[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; uint8_t selfAddress[] = {MAC_PREFIX, UNIT_MAC}; From aee0ada35e1bbb37a876f8c27632e25f94781e23 Mon Sep 17 00:00:00 2001 From: sensorsiot Date: Sat, 21 May 2022 23:50:45 +0200 Subject: [PATCH 2/4] Debugging enhanced Definition of DEBUG in the main sketch (easy to change) DBG definition Use Serial2 instead of Serial1 for the ESP32 Changed the concept of UART.IF in the -5 sketch: Debug is always Serial and the ESP32 gets an additional Serial2 for communication esp_now_peer_info_t peerInfo; seems not needed anymore added a ROLE definition. With this definition it should be possible to have the same directory for all roles. We can discuss this in Skype if you want --- Examples/1_LoRa_Sensor/1_LoRa_Sensor.ino | 3 ++ Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino | 4 +++ Examples/2_ESPNOW_Sensor/fdrs_sensor.h | 27 ++++++++++-------- .../3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino | 2 ++ Examples/3_ESPNOW_Gateway/defaults.h | 4 --- Examples/3_ESPNOW_Gateway/fdrs_config.h | 28 +++++++++++-------- Examples/3_ESPNOW_Gateway/fdrs_functions.h | 10 +++---- Examples/4_UART_Gateway/4_UART_Gateway.ino | 1 + Examples/4_UART_Gateway/defaults.h | 1 - Examples/4_UART_Gateway/fdrs_config.h | 8 ++++-- Examples/4_UART_Gateway/fdrs_functions.h | 7 ++--- Examples/5_MQTT_Gateway/5_MQTT_Gateway.ino | 13 +++++++-- Examples/5_MQTT_Gateway/defaults.h | 4 --- Examples/5_MQTT_Gateway/fdrs_config.h | 21 +++++++------- Examples/5_MQTT_Gateway/fdrs_functions.h | 8 ++---- 15 files changed, 78 insertions(+), 63 deletions(-) diff --git a/Examples/1_LoRa_Sensor/1_LoRa_Sensor.ino b/Examples/1_LoRa_Sensor/1_LoRa_Sensor.ino index 0b4fe79..a783669 100644 --- a/Examples/1_LoRa_Sensor/1_LoRa_Sensor.ino +++ b/Examples/1_LoRa_Sensor/1_LoRa_Sensor.ino @@ -5,6 +5,9 @@ // Developed by Timm Bogner (bogner1@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. // An example of how to send data using "fdrs_sensor.h". // +#define DEBUG + +#define ROLE LORA_SENSOR #include "fdrs_sensor.h" diff --git a/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino b/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino index 0b4fe79..f5be8e2 100644 --- a/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino +++ b/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino @@ -6,6 +6,10 @@ // An example of how to send data using "fdrs_sensor.h". // +#define DEBUG + +#define ESPNOW_SENSOR + #include "fdrs_sensor.h" float data1 = 42.069; diff --git a/Examples/2_ESPNOW_Sensor/fdrs_sensor.h b/Examples/2_ESPNOW_Sensor/fdrs_sensor.h index 69d9cfc..b3bb7fe 100644 --- a/Examples/2_ESPNOW_Sensor/fdrs_sensor.h +++ b/Examples/2_ESPNOW_Sensor/fdrs_sensor.h @@ -11,8 +11,7 @@ //#define USE_LORA #define DEEP_SLEEP //#define POWER_CTRL 14 -#define DEBUG -//#define CREDENTIALS +#define DEBUG #define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE //LoRa Configuration @@ -22,13 +21,22 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 //May be overwritten if CREDENTIALS is set #ifdef CREDENTIALS #include +#define WIFI_NET mySSID +#define WIFI_PASS myPASSWORD +#define MQTT_ADDR MQTT_BROKER +#define BAND myBAND +#else +#define WIFI_NET "Your SSID" +#define WIFI_PASS "Password" +#define MQTT_ADDR "192.168.0.8" + +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +#define BAND 915E6 #endif typedef struct __attribute__((packed)) DataReading { @@ -74,13 +82,10 @@ typedef struct __attribute__((packed)) DataReading { #include #endif -#define DBG(a) -#ifdef ESP8266 -#define UART_IF Serial -#else #ifdef DEBUG #define DBG(a) (Serial.println(a)) -#endif +#else +#define DBG(a) #endif const uint16_t espnow_size = 250 / sizeof(DataReading); diff --git a/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino b/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino index eab7793..d649334 100644 --- a/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino +++ b/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino @@ -4,6 +4,8 @@ // // Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. // + +#define DEBUG #include "fdrs_config.h" #include "DataReading.h" #ifdef ESP8266 diff --git a/Examples/3_ESPNOW_Gateway/defaults.h b/Examples/3_ESPNOW_Gateway/defaults.h index e1cdabc..1e788c6 100644 --- a/Examples/3_ESPNOW_Gateway/defaults.h +++ b/Examples/3_ESPNOW_Gateway/defaults.h @@ -36,10 +36,6 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 //#define USE_LED #define LED_PIN 32 diff --git a/Examples/3_ESPNOW_Gateway/fdrs_config.h b/Examples/3_ESPNOW_Gateway/fdrs_config.h index 1811940..f4c9d28 100644 --- a/Examples/3_ESPNOW_Gateway/fdrs_config.h +++ b/Examples/3_ESPNOW_Gateway/fdrs_config.h @@ -19,16 +19,13 @@ #define CREDENTIALS -//ESP32 Only -- Define UART pins and interface. +#if defined (ESP32) #define RXD2 14 #define TXD2 15 -#define UART_IF Serial1 -#define DEBUG - -//WiFi Configuration -- Needed only if this device is using MQTT -#define WIFI_NET "Your SSID" -#define WIFI_PASS "Password" -#define MQTT_ADDR "192.168.0.8" +#define UART_IF Serial2 +#else +#define UART_IF Serial +#endif ////LoRa Configuration -- Needed only if using LoRa #define SCK 5 @@ -37,11 +34,20 @@ #define SS 18 #define RST 14 #define DIO0 26 + +#ifdef CREDENTIALS +#include +#define WIFI_NET mySSID +#define WIFI_PASS myPASSWORD +#define MQTT_ADDR MQTT_BROKER +#define BAND myBAND +#else +#define WIFI_NET "Your SSID" +#define WIFI_PASS "Password" +#define MQTT_ADDR "192.168.0.8" + //433E6 for Asia //866E6 for Europe //915E6 for North America #define BAND 915E6 - -#ifdef CREDENTIALS -#include #endif diff --git a/Examples/3_ESPNOW_Gateway/fdrs_functions.h b/Examples/3_ESPNOW_Gateway/fdrs_functions.h index d22d552..7b6d230 100644 --- a/Examples/3_ESPNOW_Gateway/fdrs_functions.h +++ b/Examples/3_ESPNOW_Gateway/fdrs_functions.h @@ -1,15 +1,13 @@ -#define DBG(a) -#ifdef ESP8266 -#define UART_IF Serial -#else #ifdef DEBUG #define DBG(a) (Serial.println(a)) +#else +#define DBG(a) #endif -#endif + const uint8_t espnow_size = 250 / sizeof(DataReading); const uint8_t lora_size = 256 / sizeof(DataReading); const uint8_t mac_prefix[] = {MAC_PREFIX}; - esp_now_peer_info_t peerInfo; +// esp_now_peer_info_t peerInfo; uint8_t broadcast_mac[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; uint8_t selfAddress[] = {MAC_PREFIX, UNIT_MAC}; diff --git a/Examples/4_UART_Gateway/4_UART_Gateway.ino b/Examples/4_UART_Gateway/4_UART_Gateway.ino index ee4f44d..a52c345 100644 --- a/Examples/4_UART_Gateway/4_UART_Gateway.ino +++ b/Examples/4_UART_Gateway/4_UART_Gateway.ino @@ -4,6 +4,7 @@ // // Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. // +#define DEBUG #include "fdrs_config.h" #include "DataReading.h" #ifdef ESP8266 diff --git a/Examples/4_UART_Gateway/defaults.h b/Examples/4_UART_Gateway/defaults.h index c80a912..e143c85 100644 --- a/Examples/4_UART_Gateway/defaults.h +++ b/Examples/4_UART_Gateway/defaults.h @@ -42,4 +42,3 @@ #define NUM_LEDS 4 #define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE -#define UART_IF Serial1 diff --git a/Examples/4_UART_Gateway/fdrs_config.h b/Examples/4_UART_Gateway/fdrs_config.h index dc494b5..75ad250 100644 --- a/Examples/4_UART_Gateway/fdrs_config.h +++ b/Examples/4_UART_Gateway/fdrs_config.h @@ -19,11 +19,13 @@ #define CREDENTIALS -//ESP32 Only -- Define UART pins and interface +#if defined (ESP32) #define RXD2 14 #define TXD2 15 -#define UART_IF Serial1 -#define DEBUG +#define UART_IF Serial2 +#else +#define UART_IF Serial +#endif //LoRa Configuration -- Needed only if this device is using LoRa #define SCK 5 diff --git a/Examples/4_UART_Gateway/fdrs_functions.h b/Examples/4_UART_Gateway/fdrs_functions.h index 47c4f6b..44770bf 100644 --- a/Examples/4_UART_Gateway/fdrs_functions.h +++ b/Examples/4_UART_Gateway/fdrs_functions.h @@ -1,10 +1,7 @@ -#define DBG(a) -#ifdef ESP8266 -#define UART_IF Serial -#else #ifdef DEBUG #define DBG(a) (Serial.println(a)) -#endif +#else +#define DBG(a) #endif const uint8_t espnow_size = 250 / sizeof(DataReading); const uint8_t lora_size = 256 / sizeof(DataReading); diff --git a/Examples/5_MQTT_Gateway/5_MQTT_Gateway.ino b/Examples/5_MQTT_Gateway/5_MQTT_Gateway.ino index 34c3bde..12945d0 100644 --- a/Examples/5_MQTT_Gateway/5_MQTT_Gateway.ino +++ b/Examples/5_MQTT_Gateway/5_MQTT_Gateway.ino @@ -4,8 +4,14 @@ // // Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. // + +#define DEBUG + +#define ROLE MQTT_GATEWAY + #include "fdrs_config.h" #include "DataReading.h" + #ifdef ESP8266 #include #include @@ -29,12 +35,11 @@ void setup() { #if defined(ESP8266) - UART_IF.begin(115200); + Serial.begin(115200); #elif defined(ESP32) Serial.begin(115200); UART_IF.begin(115200, SERIAL_8N1, RXD2, TXD2); #endif - DBG("Initializing FDRS Gateway"); DBG("Address:" + String (UNIT_MAC, HEX)); #ifdef USE_LED FastLED.addLeds(leds, NUM_LEDS); @@ -48,11 +53,13 @@ void setup() { DBG("Connecting to Wifi..."); delay(500); } + DBG("WiFi Connected"); client.setServer(mqtt_server, 1883); if (!client.connected()) { DBG("Connecting mqtt..."); reconnect(); } + DBG("MQTT Connected"); client.setCallback(mqtt_callback); #else begin_espnow(); @@ -68,6 +75,8 @@ void setup() { #endif // UART_IF.println(sizeof(DataReading)); + client.publish("esp/fdrs/status", "FDRS initialized"); + } void loop() { diff --git a/Examples/5_MQTT_Gateway/defaults.h b/Examples/5_MQTT_Gateway/defaults.h index c80a912..aa6abd4 100644 --- a/Examples/5_MQTT_Gateway/defaults.h +++ b/Examples/5_MQTT_Gateway/defaults.h @@ -22,9 +22,6 @@ #define LORA1_ACT #define LORA2_ACT -//#define RXD2 21 -//#define TXD2 22 - //#define USE_LORA #define SCK 5 #define MISO 19 @@ -42,4 +39,3 @@ #define NUM_LEDS 4 #define MAC_PREFIX 0xAA, 0xBB, 0xCC, 0xDD, 0xEE -#define UART_IF Serial1 diff --git a/Examples/5_MQTT_Gateway/fdrs_config.h b/Examples/5_MQTT_Gateway/fdrs_config.h index 9765aba..6e4cafa 100644 --- a/Examples/5_MQTT_Gateway/fdrs_config.h +++ b/Examples/5_MQTT_Gateway/fdrs_config.h @@ -19,16 +19,13 @@ #define CREDENTIALS -//ESP32 Only -- Define UART pins and interface. +#if defined (ESP32) #define RXD2 14 #define TXD2 15 #define UART_IF Serial1 -#define DEBUG - -//WiFi Configuration -- Needed only if this device is using MQTT -#define WIFI_NET "Your SSID" -#define WIFI_PASS "Password" -#define MQTT_ADDR "192.168.0.8" +#else +#define UART_IF Serial +#endif ////LoRa Configuration -- Needed only if using LoRa #define SCK 5 @@ -37,10 +34,7 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 + #ifdef CREDENTIALS #include @@ -52,4 +46,9 @@ #define WIFI_NET "Your SSID" #define WIFI_PASS "Password" #define MQTT_ADDR "192.168.0.8" + +//433E6 for Asia +//866E6 for Europe +//915E6 for North America +#define BAND 915E6 #endif diff --git a/Examples/5_MQTT_Gateway/fdrs_functions.h b/Examples/5_MQTT_Gateway/fdrs_functions.h index afedd47..b07dc96 100644 --- a/Examples/5_MQTT_Gateway/fdrs_functions.h +++ b/Examples/5_MQTT_Gateway/fdrs_functions.h @@ -1,10 +1,7 @@ -#define DBG(a) -#ifdef ESP8266 -#define UART_IF Serial -#else #ifdef DEBUG #define DBG(a) (Serial.println(a)) -#endif +#else +#define DBG(a) #endif const uint8_t espnow_size = 250 / sizeof(DataReading); const uint8_t lora_size = 256 / sizeof(DataReading); @@ -102,6 +99,7 @@ void getSerial() { } void mqtt_callback(char* topic, byte * message, unsigned int length) { String incomingString; + DBG(topic); for (int i = 0; i < length; i++) { incomingString += (char)message[i]; } From 25f9d8bd5d3cb33a1dda224a3027769a253f47cd Mon Sep 17 00:00:00 2001 From: sensorsiot Date: Sun, 22 May 2022 00:19:41 +0200 Subject: [PATCH 3/4] WiFi-NET not relevant for ESP-NOW --- Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino | 3 +++ Examples/3_ESPNOW_Gateway/fdrs_functions.h | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino b/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino index d649334..cc8123f 100644 --- a/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino +++ b/Examples/3_ESPNOW_Gateway/3_ESPNOW_Gateway.ino @@ -6,6 +6,9 @@ // #define DEBUG + +#define ROLE ESPNOW_GATEWAY + #include "fdrs_config.h" #include "DataReading.h" #ifdef ESP8266 diff --git a/Examples/3_ESPNOW_Gateway/fdrs_functions.h b/Examples/3_ESPNOW_Gateway/fdrs_functions.h index 7b6d230..295e829 100644 --- a/Examples/3_ESPNOW_Gateway/fdrs_functions.h +++ b/Examples/3_ESPNOW_Gateway/fdrs_functions.h @@ -494,5 +494,4 @@ void begin_espnow() { #endif DBG(" ESP-NOW Initialized."); -DBG(WIFI_NET); } From 5500ab271b8563502d0f78c3b17dc3bdd8175b1e Mon Sep 17 00:00:00 2001 From: sensorsiot Date: Sun, 22 May 2022 01:16:14 +0200 Subject: [PATCH 4/4] Added an example to the sensor sketch --- Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino | 14 ++++++++++++-- Examples/4_UART_Gateway/4_UART_Gateway.ino | 2 ++ Examples/4_UART_Gateway/defaults.h | 4 ---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino b/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino index f5be8e2..b9163d8 100644 --- a/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino +++ b/Examples/2_ESPNOW_Sensor/2_ESPNOW_Sensor.ino @@ -12,15 +12,25 @@ #include "fdrs_sensor.h" -float data1 = 42.069; -float data2 = 21.0345; +float data1; +float data2; void setup() { beginFDRS(); } void loop() { + data1=readHum(); loadFDRS(data1, HUMIDITY_T); + data2=readTemp(); loadFDRS(data2, TEMP_T); sendFDRS(); sleepFDRS(10); //Sleep time in seconds } + +float readTemp(){ + return 42.069; +} + +float readHum(){ + return 21.0345; +} diff --git a/Examples/4_UART_Gateway/4_UART_Gateway.ino b/Examples/4_UART_Gateway/4_UART_Gateway.ino index a52c345..9acd2e3 100644 --- a/Examples/4_UART_Gateway/4_UART_Gateway.ino +++ b/Examples/4_UART_Gateway/4_UART_Gateway.ino @@ -5,6 +5,8 @@ // Developed by Timm Bogner (timmbogner@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA. // #define DEBUG + +#define ROLE UART_GATEWAY #include "fdrs_config.h" #include "DataReading.h" #ifdef ESP8266 diff --git a/Examples/4_UART_Gateway/defaults.h b/Examples/4_UART_Gateway/defaults.h index e143c85..d0b22a1 100644 --- a/Examples/4_UART_Gateway/defaults.h +++ b/Examples/4_UART_Gateway/defaults.h @@ -32,10 +32,6 @@ #define SS 18 #define RST 14 #define DIO0 26 -//433E6 for Asia -//866E6 for Europe -//915E6 for North America -#define BAND 915E6 //#define USE_LED #define LED_PIN 32