3

(coco) #1
FORGE

Live wire of
mains lead
(220V)

YOU’VE GOT MAIL
The full code for this project is available at
hsmag.cc/CZSPYm, so cross-check your code with
that when you’re done editing. To make the code run
as the Raspberry Pi starts up, use the Terminal to edit
the file rc.local. Enter sudo nano /etc/rc.local, and
add the line sudo python /home/pi/IoTea.py & at the
end of the file, but before the exit 0 line. If you saved
your file somewhere else or under a different name,
modify that line to point to your file.
The last code step is to refine the variables. This
will likely get messy – make sure your electronics
are well away from the setup and in a water-resistant
place when you do this! There’s a lot of trial and
error involved. You need the value for the filling to be
conservative, so there’s no risk of the cup overflowing
(but not too conservative or you’ll have a glass half
empty). If you can do this near your screen it saves a lot
of time. Test it by putting the input tube in your water
tank and the output in a mug. Then test the kettle.
You’ll need to fill it to the bottom of the valve, and then
empty the mug of water in. Plug it into the mains, and
time how long it takes to boil. Add a few seconds (we
aren’t bypassing the kettle’s in-built switch so there’s
no need to be exact here – the kettle will turn off when
it’s boiled). The final step is to see how long it takes to
empty the kettle. Again, you can add a few seconds on
here. Change the variable values within the code, save
it, and then shut down the Raspberry Pi.


ALL ABOUT TIMING
Now you just need to wire up the kettle. Unplug it from
the mains, and re-route the live (brown in the UK) wire
to pass through the NO contacts of the Beefcake relay.
Do not undertake this if you don’t know what you’re
doing – if in doubt, consult someone qualified! You’ll
also need to connect your 12 V power supply to the
regulator board if you haven’t already done that.
Now it’s time to test! Make sure the switch on
the kettle is pressed down so that when the relay


activates, the kettle will actually turn on. Place a cup
containing the teabag of your choice underneath the
kettle’s spout, and unplug the Raspberry Pi from your
programming setup.
You’ll need to make sure there’s enough water in the
kettle so that it just reaches the bottom of the valve.
Plug the 12 V power supply in, wait a couple of minutes
for the Pi to boot up, and press the button. You should
get a freshly made cup of tea!
Now the moment of truth – try firing off an email to
the Gmail address you created earlier, and you should
get another piping hot cuppa!
The final part of the puzzle is going to be to add
the I in IoT. It’s all very well being able to send off an
email to make yourself a cuppa, but even that is a bit
too much of a faff when you’re desperate to quench
your thirst after an evening’s hacking. Set up an IFTTT
account using the Gmail address you created earlier
(it’s important to do this with the specific email address


  • even if you’ve already got another account). Click
    the ‘create a new applet’ button, and pick ‘Google
    Assistant’ as the IF skill. Set it up with the Google
    account you use every day, and enter values so that
    you can ask it to make a cuppa. Then, for the THAT
    skill, select ‘Email’. Enter whatever subject and
    content you like, as that’s invisible to the code. Save
    the applet.
    The final step is to package everything up into a
    case. We used an old chocolate tin, spray-painted
    black. This serves two purposes: keeping the
    electronics dry, and lifting the kettle above the cup so
    it pours out properly into the mug. Now you can make
    a cup of tea by simply talking to your phone! Welcome
    to the future – two lumps for us, thanks.


Whilst this
project uses a
Raspberry Pi
as the brain,
there are lots of
other boards you
can use for IoT
projects like this.
An Arduino would
work well and
ESP8266 boards
would be a good
choice if you
want to connect it
to a network.

BRAINS


OTHER


Raspberry Pi Zero W

GPIO 2

+V COM +V COM +V

NO NO COM

Pump Valve

NO

gnd gnd

gnd

Control Control

Control

GPIO 3

Ground

+
12V
Power
Supply


  • Pump Relay Valve Relay kettle relay‘Beefcake’


5V
regulator

To Kettle

Button

GPIO 5
+5VGPIO 26

Above
The system is a
complicated one,
but well within
the realm of the
average maker

Above
And there you have it: an IoT connected, Raspberry Pi Powered
tea machine, complete with steampunk spout!
Free download pdf