So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Charliep
#72629 Hello,

I'm new to the whole 8266 world, and got my hands one of the ESP8266 chips that comes with the relay on a board. This thing: (https://www.aliexpress.com/item/ESP8266-5V-WiFi-Relay-Module-Things-Smart-Home-Remote-Control-Switch-Phone-APP/32812495091.html?traffic_analysisId=recommend_3035_null_null_null&scm=1007.13338.80878.000000000000000&pvid=08f3ea1d-125e-4f6e-963c-94fe8e92543e&tpp=1)

I can connect to a network, the status is ok, I.P address is getting assigned etc, but how do I actually trigger the relay to turn on and off? I saw some documentation mentioning a hex command.

I've got a serial connection to it through Termite and everything is going to plan on that end, no error messages or anything.

I'm new to this and seem to be stuck on this bit. Any advice would be great!

Thanks
User avatar
By dinorex
#72717 To control the relay use this code:

byte relON[] = {0xA0, 0x01, 0x01, 0xA2}; //Hex command to send to serial for open relay
byte relOFF[] = {0xA0, 0x01, 0x00, 0xA1}; //Hex command to send to serial for close relay

void loop() {
...
Serial.write(relON, sizeof(relON)); // turns the relay ON
....
Serial.write(relOFF, sizeof(relOFF)); // turns the relay OFF
...
}
User avatar
By dinorex
#72731 Just want to add to the previous post that the esp relay is very nice thought. The relay is controlled with simple uart command which leaves both IO pins free to be use for general purposes. The command is send to a small uC that controls the coil and can be generated from esp or any other device connected to the device's rx pin.