Search This Blog

Wednesday 1 November 2017

Testbed 5 - The "business end"

The whole point about most IOT devices is that the switch on a mains-powered appliance. In the real world (and my "Chez Toi ioT" home automation system) this will be done by commercially available Sonoff devices. The main ones are the S20 sockets, but I'm also going to deploy a few "Basic" modules in places where I'm never likely to change appliances (dusty corners, overhead lights atop beams, for example) and the low-voltage (or "safe voltage" as ITEAD call it) SV model.



The SV will be powered from a 12v battery and kept "topped up" by a solar powered controller. These units will be set up on buildings away from the main house, driving PIR lights so I don't have to go running for a half-dead torch every time I hear wild boar ripping up my lawns. I'd also like to be able to switch them on remotely before going out as there is a lot of ground to cover in the dark in some parts of the "estate" before the sensors will pick me up.

 So the "business end" of all my devices (apart from the wall switches) is a power relay and so my testbed has to have one. I have chosen the ubiquitous (on ebay at least) Omron G3MB-202P which is only rated at 2A, but I'm only going to be testing it with a single low-wattage lamp plugged in: all I need is to see it go on or off at the right time.

Now then, here's the thing with 3.3v devices: the solid-state G3MB needs 5v to switch cleanly and it also "draws" way more current than a GPIO pin can give or take for long periods, i.e. it needs about 20mA. So a "driver" is essential. A single 2N2222 is wired with a 10k base resistor into the GPIO. The "top end" of the G3MB relay is wired to 5v and through the LED to the collector of the 2222. The "bottom end" is wired - with the 2222 emitter to GND. It's about as simple as you can get, providing both the necessary level conversion and sufficient drive current.

Now we are almost ready to go...

No comments:

Post a Comment