-->
Page 1 of 1

ESP8266 and Relay board - How to activate relay?

PostPosted: Thu Dec 21, 2017 7:06 am
by Charliep
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

Re: ESP8266 and Relay board - How to activate relay?

PostPosted: Fri Dec 22, 2017 11:50 pm
by icons
seems like there's no easy way... have you read this thread? http://www.esp8266.com/viewtopic.php?f=160&t=13164&hilit=relay+board&start=52

Re: ESP8266 and Relay board - How to activate relay?

PostPosted: Tue Dec 26, 2017 2:28 pm
by dinorex
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
...
}

Re: ESP8266 and Relay board - How to activate relay?

PostPosted: Wed Dec 27, 2017 11:08 am
by dinorex
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.