HW-655 ESP-01 Relay Board

HW-655 - 1



This is a HW-655 relay board designed to work with an ESP-01, the nifty tiny embedded WiFi device. It appears to be a clone of a China LC Technology ESP8266 5V WiFi relay module. I found some documentation here and some more details of a similar product from the same vendor here. I also found warnings that some clones did not have programmed STM8 micro controllers so they don’t work.

The missing element in trying to make this device work was the concept that you control the relay by transmitting serial characters from the ESP-01 rather than controlling an OUTPUT pin. There is a STM8 micro controller on the board. Why do this? I’m not sure but it does leave a couple of IO pins you can solder to. One theory is it ensures the relay doesn’t close without something quite deliberate happening in the ESP-01 which could prevent the ESP-01 crashing and leaving your controlled device powered.

The magic string is four bytes long.

A0 01 01 A2 causes the relay to CLOSE.

A0 01 00 A1 causes it to OPEN.

It’s probably a good idea to flush out any crud in the serial port before you send the string. I have noticed that A0 01 A0 01 01 A2 doesn’t cause the relay to CLOSE.

I wanted to test my relay module to see if it was programmed since it was obviously a clone. I couldn’t enter the four byte sequences in my terminal emulator so I wrote a bit of Perl on my Mac:

$| = 1;
sleep 1;
printf(chr(0xa0) . chr(0x01) . chr(0x01) . chr(0xa2) ); # close
sleep 1;
sleep 1;
printf(chr(0xa0) . chr(0x01) . chr(0x00) . chr(0xa1) ); # open
sleep 1;

And ran it like this:

perl < relay-close.pl > /dev/cu.usbserial-A703EA9U

While monitoring the serial being sent like this:

cat /dev/cu.usbserial-A703EA9U | hexdump
0000000 43 6c 6f 73 65 a0 01 01 a2 4f 70 65 6e a0 01 00
0000010 a1 43 6c 6f 73 65 a0 01 01 a2 4f 70 65 6e a0 01

And it worked! (Actually the codes I found online were Open: A0 01 01 A2 and Close: A0 01 00 A1 which are backwards!)

The ESP-01 has an ESP8266 system on chip and some flash. It is also Arduino compatible so you can write C++ code that will execute directly on the device. The next problem is 00 is NULL and strings are terminated with a NULL in C languages so you have apply a bit of effort like:

void setup() {

void loop() {
 Serial.write("\xa0\x01\x01\xa2"); // CLOSE RELAY
 Serial.write("\xa0\x01"); // OPEN RELAY
 Serial.write(0x00); // null terminates a string so it has to be sent on its own

I compiled it for a board type of ESP8266 and uploaded it via my handy little ESP-01 programmer.

ESP-01 programmer - 1

Then plugged the ESP-01 into the HW-655, applied power and the relay will happily turn on and off every second forever.

ESP01 with relay

The ESP-01 is quite clever and can be loaded with some off the shelf firmware that does WiFi and can listen for a TCP connection so you could open a socket and send the four byte sequences from a machine on the same network. If you do some digging you will find some projects using some of Espressif’s IoT tools that let you control these devices from your mobile phone.

Note that there are two versions of the ESP-01. If you’re blowing $3 of your hard earned cash on one or five you should probably buy ESP-01S modules with 1MB of flash rather than the ESP-01 with only 512K of flash. You need the bigger memory for Version 1.5 of the AT “modem” firmware which can remember WiFi and TCP settings.

Other differences between ESP-01 and ESP-01S found online:

– blue PCB vs black
– 512kB flash vs 1MB
– Red power LED vs -No- power LED
– Blue LED on GPIO1 (TX) vs GPIO2 (and low = on)

The difference in LED may cause confusing when using BUILTIN_LED in the Ardunio IDE because the IDE expects the LED on GPIO1 (TX) and it’s inverted so OFF is lit and ON is dark.


25 thoughts on “HW-655 ESP-01 Relay Board”

  1. HI
    Trying to upload to this using Arduino and a USB adapter? but get errors. Can you elaborate on how you uploaded the sketch?

    1. 1. USB adaptor must be in programming mode. If it doesn’t have a switch to do this it probably will not work.
      2. You need to load support for a board type of ESP8266 with the Boards Manager under Tools / Board
      3. A bunch of settings appear which I don’t think I messed with
      4. You can now program the ESP-01

  2. Hi bigjsl,
    Increasing delay don’t mantain the relay closed. Every time the program force to close it, it only remains closed less than a second. Sould it be necessary to send the command continuosly, or?

    best regards

    1. My apologies that I missed this comment three years ago 😦 There are probably several versions of the firmware running on the relay board. I’m sure there are numerous manufacturers in China each with a slightly different clone. In 2021 this family of boards are available: https://www.aliexpress.com/item/4001094436563.html that use the code-turns-on, code-turns-off method.

    1. The only data connection from the ESP-01 is serial out so there is no way of monitoring the relay state. You could connect the relay driver line to a spare input line on the ESP-01 assuming it never gets more than 3.3 volts positive but I think you’re better off sending the ON or OFF command to the relay driver repeatedly.

  3. I am able to flash esp-01 with code been provided but the relay doesnt seems to work with it… Its D2 light keeps flashing much faster then 1sec interval, NOTE: I didnt ran the perl script. Any idea what can be wrong? How can I fix it?

    1. If the code has loaded correctly but the led is blinking faster than once per second you have probably set the ESP clock divider incorrectly in the Arduino IDE board settings. That would also cause the serial baud rate to be wrong (too fast).

      1. How can i get to know the correct settings? Seems the board i bought is generic and has not details printed on it.

      2. By any chance will you be having any connection diagram of hw655 with arduino to flash and configure it properly? I am basically looking to build a custom application and control door lock using this module. I did everything on esp-01(hosting web server etc) but not able to run it when i mount it back on relay module, standalone it worked fine.

      3. I am completely lost on where this conversation has got to. Try stating your original question differently please.

  4. is there a way we can chat.. will be relatively much better.

    Question/Ask is:

    1. I am looking to configure HW655 as web server to turn on and off relay remotely.
    2. I tried to upload sketch on ESP-01 after removing it from HW655 and connecting it to arduino(straight connection) and uploaded my sketch. (code similar to https://www.hackster.io/ROBINTHOMAS/esp8266-esp-01-webserver-7248ca)
    3. I put esp01 back to relay module but the b2 light, relay still keeps blinking(not as per my code)
    4. I did tried to flash esp-01 with basic firmware(from internet) since mine doesnt have any manufacturer name written.(again directly esp-01)

      1. added reset button too and pressed after upload.. still no luck.. Do we need to do something on relay module too? or on ESP flashing is enough?

Leave a Reply to Rajkiran Singh Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s