#include #include const int ledPin = 4; //b typedef struct struct_message { char message[32]; } struct_message; struct_message myData; uint8_t broadcastAddress[] = {0x74, 0x4d, 0xbd, 0x97, 0x4c, 0x78}; // Replace with the MAC address of the Seeed Xiao ESP32S3 void onReceive(const esp_now_recv_info *info, const uint8_t *incomingData, int len) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Message: "); Serial.println(myData.message); // Respond with "Welcome S3" strcpy(myData.message, "Welcome S3"); esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData)); digitalWrite(ledPin, HIGH); //b if (result == ESP_OK) { Serial.println("Response sent with success"); } else { Serial.println("Error sending the response"); } } void onSent(const uint8_t *mac_addr, esp_now_send_status_t status) { Serial.print("\r\nLast Packet Send Status: "); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); } void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); Serial.print("Receiver MAC Address: "); Serial.println(WiFi.macAddress()); if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } esp_now_register_recv_cb(onReceive); esp_now_register_send_cb(onSent); esp_now_peer_info_t peerInfo; memcpy(peerInfo.peer_addr, broadcastAddress, 6); peerInfo.channel = 0; peerInfo.encrypt = false; if (esp_now_add_peer(&peerInfo) != ESP_OK) { Serial.println("Failed to add peer"); return; } } void loop() { // Nothing needed here }