/************************************************************************************************* PROGRAMMINFO ************************************************************************************************** Funktion: ESP32 Sender Code (ESP-NOW) ************************************************************************************************** Version: 18.09.2021 ************************************************************************************************* Board: ESP36 Dev Module ************************************************************************************************** C++ Arduino IDE V1.8.13 ************************************************************************************************** Einstellungen: https://dl.espressif.com/dl/package_esp32_index.json http://dan.drown.org/stm32duino/package_STM32duino_index.json https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json ************************************************************************************************** Librarys - WiFi.h V0.16.1 **************************************************************************************************/ #include #include #include #include #include // Board ID festlegen: #define BOARD_ID 1 // DHT Sensor PIN #define DHTPIN 4 // Sensortype auswählen: //#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); //Receiver MAC Addresse uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; typedef struct struct_message { int id; float temp; float hum; int readingId; } struct_message; struct_message myData; unsigned long previousMillis = 0; const long interval = 10000; // Sensor Intervall unsigned int readingId = 0; constexpr char WIFI_SSID[] = "R2-D2"; int32_t getWiFiChannel(const char *ssid) { if (int32_t n = WiFi.scanNetworks()) { for (uint8_t i=0; i= interval) { previousMillis = currentMillis; myData.id = BOARD_ID; myData.temp = readDHTTemperature(); myData.hum = readDHTHumidity(); myData.readingId = readingId++; esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData)); if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); } } }