This is only a preview of the October 2024 issue of Silicon Chip. You can view 45 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "3D Printer Filament Dryer, Part 1":
Items relevant to "8Ch Learning Remote Receiver":
Articles in this series:
Items relevant to "JMP012 - WiFi Relay Remote Control":
Videos relevant to "JMP015 - Analog Servo Gauge":
Articles in this series:
Items relevant to "Dual-Rail Load Protector":
Items relevant to "Micromite Explore-40":
Purchase a printed copy of this issue for $13.00. |
SILICON CHIP
Mini Projects #012 – by Tim Blythman
There are lots of IoT (Internet of Things) gadgets and widgets available,
but many require a subscription to work. The WiFi Relay Remote
Control could be considered one of the simplest IoT devices. You
don’t need to sign up for anything, and you can build it yourself.
WiFi Relay
Remote Control
W
e covered Jaycar’s XC3804
WiFi Relay Module in January
2024 (siliconchip.au/Article/16088).
As the name suggests, it is a small
module containing a relay and a WiFi
radio. The Relay Module can be controlled by sending commands over a
WiFi network. It doesn’t even need an
internet connection to work.
While it’s a handy tool, another
device is required to operate it. You
could use an old mobile phone or similar WiFi-equipped device to control
it, but we think there are better ways.
So we’ve designed the WiFi Relay
Remote Control.
As the name suggests, it is a remote
controller for the Relay Module. Since
the Relay Module uses a dedicated
WiFi network for its operation, it’s
easy to set up a controller dedicated
to that task.
WiFi Relay Module
There are more details on the WiFi
Relay Module in our other article,
but the principle of operation is as
follows. The Relay Module sets up a
WiFi access point, allowing WiFi clients to connect. When it receives particular web page requests, it operates
the relay in response.
So we just need to create a client that
connects to the access point and then
sends the appropriate requests depending on user input, like pushing a button. It would be good if it also indicated if the request has worked or not.
That’s basically how the WiFi Relay
Remote works. It has two pushbuttons
connected to a WiFi Mini Main Board
that connects to the access point provided by the Relay Module. When
the buttons are pressed, it sends commands to open or close the relay.
We’ve used illuminated pushbuttons, so the LEDs light up to show
what is happening. You can see a video
showing the WiFi Relay Remote in
operation at siliconchip.au/link/abx4
Circuit details
Fig.1 shows the circuit diagram.
The pushbutton contacts are each connected between a digital I/O pin and
ground. Internally, the processor on
the WiFi Mini applies a weak pullup
Fig.1: you could easily rig it up on a breadboard if you wanted to test it before
building it. We recommend using the same pins on the D1 Mini as we did, as
some other pins have special functions that might cause a conflict.
Fig.2: how we placed
parts on the underside of
the shield (also refer to
the adjacent photo). The
shield’s top side is bare,
apart from the switches.
The wiring is hidden
on the underside of the shield. We
originally planned to use the D8
pin instead of D1, which would
have made the layout neater.
However, that is impractical, as
D8 has a pulldown instead of a
pullup.
for those pins, so it can sense when
the switch is closed and the I/O pin
is pulled to ground.
Two status LEDs are also provided
that are internal to the illuminated
pushbuttons. Each has a 220W series
resistor to limit the current flow to an
appropriate level for the LEDs. The
WiFi Mini also has an onboard LED
that lights up when pin D4 is driven
low, so we can also use that as an
indicator.
Construction
We intended the Remote to be a compact and self-contained unit, so the
hardware has been assembled onto a
small prototyping shield that can plug
into a WiFi Mini. Fig.2 and the photos
show how it has been laid out.
Start by fitting the switches.
Straighten the leads so that they will
slot straight into the prototyping
shield. To get the orientation correct,
note the longer (LED anode) pins and
place them as shown. Solder them
after making sure the switches are flat
against the shield.
Solder the two resistors as shown,
from the longer anode pin to the pads
for D6 and D7. We use the inside row
of pads so the outer rows are free for
attaching the headers later. Keep the
wire lead offcuts for the next steps.
Next, solder a wire from the D5
pad to the corner lead of the switch
as shown. All three leads on the
other side of both switches connect to
ground, so run a wire from each group
of three back to the ground (G) pin.
Then run a piece of insulated wire
from the switch with the red LED back
to D1. Slot the header pins onto the
WiFi Mini (to align them) and then
solder them to the prototyping shield.
That’s it, the hardware is finished!
Software operation
The software consists of an Arduino
sketch that uses the ESP8266 board
profile. The sketch attempts to connect
to the ‘Duinotech WiFi Relay’ access
The assembled shield
slots onto the top
of the WiFi Mini,
making for a compact
unit. We used a small
breadboard and jumper wires to
power the WiFi Relay Module
from the same supply for testing.
The switch with the red ‘off’
LED is at the top, while the
green ‘on’ LED is at the bottom.
Unfortunately, there is no way
to tell them apart when unlit,
so our software lights both
LEDs dimly so you can tell
which is which.
point created by the Relay Module,
flashing the onboard (D4) LED until
it does.
Both switch LEDs are made to light
dimly by driving them with a low duty
cycle PWM (pulse width modulated)
waveform so you can see which is on
(green) and off (red). The software
then waits until one of the buttons is
pressed and sends the corresponding
request to the Relay Module. Simultaneously, both LEDs switch off to indicate that a request is pending.
If there is a successful response, the
corresponding LED is switched on at
full brightness, and the Relay Module
will have its state set accordingly. If the
request fails, both LEDs will return to
a dim state after a while. The request
can be tried again by pushing one of
the buttons.
Firmware installation
Open the Arduino IDE and check
that you have https://arduino.esp8266.
com/stable/package_esp8266com_
index.json in your list of Board Manager URLs. Next, install the ESP8266
board profile from the Boards Manager
Parts List – WiFi Relay Remote Control (JMP012)
1 Smart WiFi Relay Main Board [Jaycar XC3804]
1 WiFi Mini Main Board [Jaycar XC3802]
1 WiFi Mini Prototyping Shield [Jaycar XC3850]
1 PCB-mounting tactile switch with integrated red LED [Jaycar SP0620]
1 PCB-mounting tactile switch with integrated green LED [Jaycar SP0621]
2 220W ½W 1% axial resistors [Jaycar RR0556]
1 25mm length of insulated wire
2 5V DC power supplies
siliconchip.com.au
Australia's electronics magazine
window. We used
version
3.1.2 of the board profile, but later versions should work too.
Download the software package for
this project from siliconchip.com.au/
Shop/6/460 and then choose the ‘D1 R2
& Mini’ board type and its corresponding serial port in the IDE. Upload the
sketch; no changes need to be made
as the Relay Module uses a fixed WiFi
network.
Operation
The LEDs on both buttons should
light up dimly and the small blue LED
on the WiFi Mini should start flashing. Power on the Relay Module. As
you can see from our video and photo
above, we just used a pair of jumper
wires connected to the WiFi Mini’s 5V
& GND (G) pins to get power for testing.
After a few seconds, the blue LED
will light solidly and you can control
the Relay Module by pressing the buttons. If the blue LED goes out at any
point, the Remote has lost its connection. In that case, check that the Relay
Module is powered correctly.
Note that other devices (such as
a mobile phone or another Remote)
can control the Relay Module. In this
case, the LEDs might not show the correct status. There is no way to get the
Relay Module’s status without triggering it, so there is no workaround for
that without reprogramming the WiFi
Relay Module with altered firmware.
Now you can set up the Relay Module to run off its own power source
and also control something.
SC
October 2024 67
|