/* RECEPTEUR Raccorder la led sur la sortie 34 Apres le telechargement du programme sur l'ESP32, faire un reset de l'esp32 */ #include #include int led1 = 34; int tempo = 50; // Structure example to receive data // Must match the sender structure typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message; // Create a struct_message called myData struct_message myData; // callback function that will be executed when data is received void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Char: "); Serial.println(myData.a); Serial.print("Int: "); Serial.println(myData.b); Serial.print("Float: "); Serial.println(myData.c); Serial.print("Bool: "); Serial.println(myData.d); Serial.println(); } void setup() { // Initialize Serial Monitor Serial.begin(115200); pinMode(led1, OUTPUT); // Set device as a Wi-Fi Station WiFi.mode(WIFI_STA); // Init ESP-NOW if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } } void loop() { esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataRecv)); delay(1000); if (myData.d == true) { digitalWrite(led1, HIGH); } if (myData.d == false) { digitalWrite(led1, LOW); } }