hi.
The slave communicates with the master via WIFI(esp32, SERVER and client), and when receiving the specified serial(0x02), the built-in LED must be turned on. What is wrong?
master(SERVER)
if (currentSensorState != lastSensorState) {
if (currentSensorState == 1) // heat switch off
{
client.write(0x02);
digitalWrite(2, LOW);
delay(1000);
digitalWrite(2, HIGH);
}
slave(client)
{
byte x = client.read(); //expecying numerical value; so, declare byte type variable
if ( x == 0x02
)
{
digitalWrite(led, HIGH);// perform some action
delay(1000);
digitalWrite(led, LOW);
}
else {
digitalWrite(led, LOW);// maybe perform some other action
}
}