I looked at other protocols, and realized that I could
easily implement my timer system using Hypertext Transfer
Protocol (HTTP) based commands since I would simply be
transmitting on and off requests.
Therefore, I chose to develop my timer using the
HTTP protocol to send an on or off command using two
independent on/off zones. Each zone could communicate
with up to 10 Wi-Fi modules, or the 10 modules could be
divided among the two zones. More Wi-Fi modules could
be added by expanding the Arduino software, but for my
purposes 10 modules met my need.
In addition, each zone would communicate with X- 10
modules configured to a selected channel and house
code, and many X- 10 modules could be utilized in my
house in areas that have demonstrated reliable X- 10
powerline communication. More timing zones can be
added (if desired) by including the needed timing sections
and menus to the Arduino software.
I envisioned designing a Wi-Fi based wall switch using
the ESP8266, so I purchased several of these modules and
3. 3 volt relay modules. During my research, I found several
brands of Wi-Fi switches already on the market, but all of
them were programmed to communicate with the
manufacturer’s website for control.
I was concerned with network security, so I did not
want a web service to have access to my router SSID and
password (if the web service was attacked, the hacker
would have access to my home network). I also did not
want any web service having control capability or access
inside my house network. The beauty of the ESP8266 is
that it can easily be reprogrammed utilizing the Arduino
Integrated Development Environment (IDE). After much
research, I settled on the S20 Smart Socket Wi-Fi module
by Itead because it is designed with an internal header
that can be utilized to easily reprogram the modules. The
price of these modules was reasonable and would provide
a professional looking unit to be deployed around my
If a particular application would benefit from installing
the remote control modules in a central location, Itead
also offers a Sonoff Wi-Fi switch in a configuration that
has screw terminals for the power in and out that also has
the reprogramming header. The two Itead modules are
slightly different in configuration, so I have a slightly
different programming sketch for each when using the
During my research, I discovered that Itead had
incorrectly configured their S20 Smart Socket Wi-Fi
modules (made for the US market) with the fuse and relay
on the neutral wire. I contacted Itead and discussed the
wiring error, and they agreed to reconfigure the circuit
board to fuse and switch the line wire instead of the
neutral wire. There are many other Wi-Fi switches that can
be reprogrammed, but identifying the power, ground,
send, and receive lines may be difficult depending on how
the manufacturer configured and mounted the internal
circuit boards. Refer to Figures 1 and 2.
Where Should I Begin?
I decided to develop replacement code for the Itead
Wi-Fi switch modules as my first step, to confirm the
reliability of communications and control. I chose the
aREST library for ease of communication with the
switches. The aREST library is available on GitHub as a
free download and was ported to Arduino by Marco
Schwartz. Please download aREST and aREST_UI from
GitHub.com to ensure you have the latest version, and
add them to your Arduino IDE library.
I chose to assign fixed Internet Protocol (IP) addresses
to each switch so I didn’t have to worry about my home
router arbitrarily changing the IP address of a switch. My
timer issues commands to these fixed IP addresses. This
adds a small complication in Wi-Fi switch programming
where different IP addresses must be programmed into
each switch, but this is very easy during the programming
The IP addresses I chose to use are outside the range
August 2017 25
To post comments on this article and find any associated files and/or
downloads, go to www.nutsvolts.com/magazine/issue/2017/08.
■ FIGURE 2. Itead Sonoff Wi-Fi switch.
■ FIGURE 1. Itead S20 Smart Socket Wi-Fi switch.