hardware Home Automation software

Home Automation and the Internet of Things – The Start

IoT_IconI have wanted to experiment with home automation and Internet of Things (IoT) for a while and recently came across an inexpensive WiFi relay/switch combination on AliExpress that seemed a reasonable place to start. So after waiting a few weeks for delivery, my adventure into IoT-land started.

Hardware Module

The hardware module (also known as a Yunshan ESP8266 WiFi Relay) is a generic module available from a number of suppliers for a few dollars (mine was around AUD$6.00). It has some interesting specifications:

  • ESP8266 MCU with built-in Wifi
  • Board dimensions 65×40mm (2.56″×1.57″), 20mm (0.75″) high
  • Input voltage DC 5-25V
  • Input overvoltage and overcurrent protection
  • Relay output rated 250V 10A with NO-Com-NC screw terminals
  • Optocoupler isolated input with overvoltage protection.
  • LED status indicator for digital input and relay output


The board should be useful for simple IoT projects controlling household AC power, as the on-board relay is rated at 250V 10A (the same as a single household circuit in Australia). Also, as seen in the figure above, the PCB has slots between the high voltage PCB traces for circuit isolation and arc-over protection.

The boards arrived, were powered up and … nothing happened (no LEDs, no flashing, no nothing). The multimeter told me that I was getting power on the board (good!) and eventually I noticed that there was a new Wifi connection available from my Windows PC (SSID ESP8266), but no clue as to the password.

As with most of these generic boards, there is little/no information from the supplier. However, I eventually managed to uncover these were called Yunshan boards and got onto a site (here) that had some information on the board and links to more info in Chinese. Unfortunately, the posted Wifi password (yunshan123456789) did not work. After more digging I found someone had posted feedback on AliExpress suggesting ‘1234567890’,  which worked for my board. However, once the Wifi connection was established, it became clear that no application software was loaded.

For the record, here is the board, with its connections, connectors labelled, and cross referenced to the circuit diagram.



Of note:

  • The Digital In screw terminals are connected to the optocoupler. The board provides +5V output to the digital device but the ground terminal is not connected to the ground for the rest of the board, just to the low side of the optocoupler. The output from the optocoupler is connected to the ESP8266 GPIO5 pin.
  • The ESP8266 output controls the relay through a switching transistor connected to GPIO4.
  • Not shown in the circuit schematic, there is also a LED connected to GPIO2 on the ESP8266 MCU board.
  • There are 2 headers that can be used to reprogram the device – the Serial Port and the Boot Jumper (more on these below).

Making something happen

In all the research I had been doing, I came across the ESP Easy firmware designed for ESP8266 MCU home automation devices.

The ESP Easy firmware turns the ESP module into a multifunction sensor device for home automation solutions. As ESP Easy firmware configuration is web based, once the firmware is loaded the only additional tool needed is a web browser.

The ESP Easy site has a lot of information about the types of devices supported, and it happens that these relay modules are on the list. A “no custom programming” solution sounded like it was worth a try.

An entire section of the ESP Easy Wiki is devoted to how to load the firmware, and following the instructions worked for me – one tutorial here and another here. I opted to use the flash tool to download the firmware. There is a link to download a zip file that contains various versions of the boot binaries and the flashing application. Once  downloaded, unzip the file to a convenient location. You will also need a USB-TTL serial converter that operates at 3.3V.

The basic sequence for flashing is:

  1. Plug in the converter and note its COM port. If you have no other tools, you can do this using the Arduino IDE or any Serial communications program. The new port will be auto-detected and appear on the list of available ports.
  2. Make sure the module is powered down.
  3. IoT_WiFi_Relay_Module_Detail1Connected the Tx, Rx and Ground pins of connector the Serial Port header to the USB-TTL, swapping the RxTx line between the two (ie, Tx on the module is connected to Rx on the converter, and Rx to Tx). The Ground connection is essential or the serial link will not work reliably.
  4. Short the pins on the Boot Jumper header. This makes the ESP8266 power up ready to receive a new boot program.
  5. Run the flashing application. This will open the small dialog window shown below. Select your COM port and, for this Wifi Relay, select the normal_ESP8266_4096 version of the firmware.IoT_Flashing1
  6. Turn on power to the Wifi Relay Module.
  7. When you press Flash in the dialog box, a command window appears to run the flashing application. It provides feedback on progress and ends with small pop-up dialog box to tell you it is finished.IoT_Flashing_Detail2
  8. Power down the Wifi Relay module and remove the boot jumper.
  9. If you want to follow the initialisation process, you can connect a serial terminal (the Arduino IDE Serial Monitor works) set to 115,000 bps, no handshake. You should see something like as the unit starts:IoT_Flashing_Detail3
  10. At this point you connect to Wifi SSID ESP_Easy_0 using password configsp, and the set then open IP address using your web browser. Depending on your network, you may need to tweak the network settings so that you can access the device. When you are successful, you will get the initial configuration page similar to that shown below, to set up credentials for joining an existing Wifi network.IoT_Flashing_Detail4
  11. Select the network you want to join, enter your password and you should see an update in the browser and on the serial monitor outputIoT_Flashing_Detail5

In the next part we’ll explore how to configure and use ESP Easy to operate the Wifi relay.

3 replies on “Home Automation and the Internet of Things – The Start”

Hi, IoT expert.I am from Slovakia. I´m reading your older blog from this page( excellent.I bought this module ESP8266 with relay and flash Tasmota firmware works good in internal wifi LAN with browser connecting (internal IP address)

But I have question. I can not connect with app Smartlife (android).
For pairing with other devices app (ADD new devices to Smartlife) used reset button and led. How can i add function or settings to simulate this pairing steps.Thank You for you answer.
PS:Sorry my English is no good.
Braňo from Slovakia.


Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s