I ended up ordering a micro
USB microphone from Amazon
which didn’t work too well. The
PocketSphinx Python API
(application program interface)
didn’t recognize the mic, which
was due to system
misconfiguration. Therefore, I
ended up moving the voice
recognition to an old laptop I never
use that has an awesome built-in
mic.
The voice recognition consists
of a Python program that uses the
PocketSphinx API, which is
supposed to send a POST request
to the rails server and synchronize
the phones, as well as send a signal
to the wireless switch. It instead
sends a signal directly to the
wireless breakout board attached directly to the light for
now, and does not work with the central brain of the
framework.
As you can see, the voice recognition portion of the
project is a work in progress. Getting the speech
recognition to be accurate is a bit tricky, too. It works well
at the moment, but will need some fine-tuning before it’s
fully deployable and ready. I would like to eventually get
the speech recognition working on the RaspPi 3, but using
my laptop to interface with the lights via voice will have to
do for now.
The Switch Schematic
and Disambiguation
The schematic of my wireless switch is shown in
Figure 7. The wireless breakout board grounds out the BJT
(bipolar junction transistor) in this common-emitter circuit
and provides a 3. 3 base voltage from one of its GPIO pins
(which are the only dynamic and changeable factor on
this board and/or circuit). The GPIO pin is either on or off,
and this solely depends on the signal coming in from the
phone that is controlled by the state of the toggle button.
The board also powers the relay coil with a five volt
constant GPIO pin. This board even has a small server
written in the C programming language that handles the
incoming signals with general C compare functions that
have bounds checking.
The BJT is probably my favorite component in this
build and by far the most fascinating! Applying the right
amount of current to the base and collector of the BJT will
allow you to switch high current devices. The breakout
board’s 3. 3 volt GPIO pin is what’s used to saturate this
small signal transistor.
The 520 ohm resistor at the base brings the current to
the required 5 mA, as well as the 30 ohm resistor at the
collector that brings the current to the required 50 mA
needed to saturate the BJT. All of these factors can easily
be calculated by using Ohm’s Law, of course.
The relay is almost an equally impressive device that
has a coil that is magnetized once the coil is powered.
Once this happens, it closes the armature on this
normally-open SPST relay. It surprisingly only takes five
volts to power the 70 ohm coil, which again is provided
by the wireless breakout board. The other two contacts
allow high current to flow through the relay (which is 110
VAC, in this case), but the relay is rated to handle much
higher current if necessary.
Once the armature closes on the relay, it completes
the extension cord’s circuit and allows power to flow.
Conclusion
Though it was a lot of work, I learned a lot by building
this DIY home automation project. Though similar systems
are available commercially, I wanted to re-create this
particular device mainly because I have a fascination with
January 2018 27
QTY ITEM
1 2N3904 small signal NPN BJT
1 510 ohm carbon film resistor
1 10 ohm carbon film resistor
1 30 ohm carbon film resistor
1 1N4004 flyback diode
1 SPST-NO 5V 70 ohm coil relay
1 Adafruit ESP8266 wireless breakout board
1 FTDI cable
1 Raspberry Pi 3
1 Extension cord
1 Terminal block
1 Printed circuit board
PARTS
LIST
■ FIGURE 7.
Switch schematic