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

User avatar
By liderbug
#73808 "No trouble mate" - I've got it - it's working - from Android app, from command line, from crontab, browser, program. YaaaHooo! Thanks to the person(s) who did some earlier posting on this subject. Owe ya a beer. Thanks :D

Some of you will look at this and "not like my code" - then modify it. My end goal is to be able to take a standard electrical outlet box, a 110-usb module, this relay board, a duplex outlet and supplement/replace my X10 modules in my hydroponic greenhouse.

Now the STC15F104 (SOP8 = package type) chip works by sending 4 bytes to pin 6(?) saying +voltage on pin 7 or ground to pin 7. But that whole chip, 4k flash, 128 bytes ram .... I'm thinking there's got to be more than just "on"/"off". Status? Delay? There's prob 2 people in the world that know.

My testing: on, sleep 3, off, sleep 3 - works as expected. Changing sleep to 1 works, to .1 works to .01 not so much - think the .01 kinda out runs the relay. :roll:

Code: Select all/*
 *  This sketch demonstrates how to set up a simple HTTP-like server.
 *  The server communicates with the relay board via the Serial port
 *    http://server_ip/on will turn the relay on
 *    http://server_ip/off will turn the relay off
 *    There are no Serial.print lines of code

#include <ESP8266WiFi.h>

  const char* ssid = "MyCasesenSssID";
  const char* password = "mYpassw0rd";
  IPAddress ip ( 192, 168, 0, 131 );  //131=sw1, 132=sw2, etc
  IPAddress gateway ( 192, 168, 0, 1 );
  IPAddress subnet ( 255, 255, 255, 0 );
  WiFiServer server (80);

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

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

void setup ()
  delay (10);
  Serial.begin (9600);
  WiFi.config (ip, gateway, subnet);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  // Start the server

void loop() {
  int val;

  // Check if a client has connected
  WiFiClient client = server.available();
  if ( ! client ) {
  // Wait until the client sends some data
  while ( ! client.available () )
    delay (100);
  // Read the first line of the request
  String req = client.readStringUntil ('\r');
  client.flush ();
  // Match the request
  if (req.indexOf ("/on") != -1)
    Serial.write (relON, sizeof(relON));
    val = 1; // if you want feedback see below
  } else {
    if (req.indexOf ("/off") != -1)
      Serial.write (relOFF, sizeof(relOFF));
      val = 0; // if you want feedback

  client.flush ();

   // only if you want feedback - see above
  // Prepare the response
  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
  s += (val)?"on":"off";
  s += "</html>\n";

  // Send the response to the client
  client.print (s);
  delay (10);

User avatar
By alsesp
#73861 I've been pulling my hair out over this module. Would love to get it to work without resorting to ripping off the MCU and using GPIO to drive the relay as I like the idea of still having both GPIO to play with

When I power up the relay board, with or WITHOUT the esp-01 installed, the LED flashes and you can hear the relay oscillating slightly. Seems other people have also had this problem.

I've been messing around trying to send hex characters just in case the MCU woke up and sorted itself out, but no luck, LED just keeps on flickering.

Did those of you who have working boards ever see this issue with the flashing LED with no data sent to the MCU, or is my unit knackered ?
User avatar
By pilol34
#74262 Hello;

I too was very disappointed when buying this module. When I connected it for the first time, it is flashing as shown on this link ( and it was not responding at any of my orders.

After a rechere on the web, I found on the website of the manufacturer ... &p_id=1204
this note:
For this wifi relay module, because there are some counterfeit on other sales platform. So if the LED on-board (D2) are blink constantly (I guess the reason is the STC15F104W have not been programmed), it means the module were not produced in our factory, maybe you need to contact the seller directly. Best regards!

And then I realized that I had to program the module to solve the problem (I not found the original firmware).

Here are the results of my work after several days of work.

ATTENTION, The programming and or the alteration is under your resposability because it is always possible to do an error or mishandling that may endanger the module.

1. An FTDI232 interface is required to connect the USB protector to the module's RX TX pins. Here we use an interface to 5V.

2. Software is required to program the module's STC15F104W. Here I used stc-isp.exe (v6.86E) found on the site (Hey yes, I work under windows).

3. Create a program and compile it in .HEX format. Here I create a .asm program that I compile thanks to the AS31.exe utility from Paul's 8051 Tools at

4.The program must be transferred to the module. It is necessary to think to cross the cables TX RX and one does not branch 5V power supply.

With the programe STC-ISP.exe we load the proramme .hex, we set the clock at 11.0592 MHz, and press the button DOWNLOAD / PROGRAM, Connect the 5V power supply of the module and wait until the transfert is finished.

5. In the COM Helper tab, test the module with commands A0 01 01 A2 and A0 01 00 A1 in HEX-Mode.

6. If the led lights up but the relay does not work, it will alter the module by swapping the resistors R3 and R4. This is probably the most delicate operation you will have to do.

7. Afterwards, follow the setup for the ESP-01 module.

To speed up your work, I give you my version of the program in .HEX format Which will save you from making the item 3. This program is transmitted as-is and without guarantee. I have not done advanced testing and it is not optimized.

I added to the program relay status reading commands.

B0 01 01 B2 -> Reading relay in text format ("ON" and "OFF" ending with a linefeed).
B0 01 00 B1 -> Relay reading in binary format (00 = ON and 01 = OFF).

B0 00 01 B1 -> Reading the firmware version in text format ending with a linefeed.

You just have to copy and paste into a text file with the extension .hex.

File: LcWifiRelayUartV1_0_9600_11mhz.hex

Code: Select all:0300000002017387

Now it's up to you to do the rest.

Good luck.
Last edited by pilol34 on Tue Apr 24, 2018 9:13 pm, edited 1 time in total.