// Networking and Communications - UART Master Node // Board: XIAO ESP32-C3 // TX = D4, RX = D5 // Sends commands to SLAVE01 to control a LED #include #define TX_PIN D4 #define RX_PIN D5 HardwareSerial NodeSerial(1); void setup() { Serial.begin(115200); delay(3000); NodeSerial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN); Serial.println("MASTER NODE READY"); Serial.println("UART communication started"); Serial.println("Sending commands to SLAVE01"); } void loop() { Serial.println("Sending command: SLAVE01:ON"); NodeSerial.println("SLAVE01:ON"); delay(3000); while (NodeSerial.available()) { String response = NodeSerial.readStringUntil('\n'); response.trim(); Serial.print("Response from Slave: "); Serial.println(response); } Serial.println("Sending command: SLAVE01:OFF"); NodeSerial.println("SLAVE01:OFF"); delay(3000); while (NodeSerial.available()) { String response = NodeSerial.readStringUntil('\n'); response.trim(); Serial.print("Response from Slave: "); Serial.println(response); } }