A common introduction to electronic switching is the mechanical relay—a device that operates like a common switch, only it's turned on and off by applying power to it. Unfortunately, connecting a relay directly to a Raspberry Pi is dangerous! Relays commonly require too much current and voltage and (if they do switch) can damage your Raspberry Pi. So, we need a driver circuit that sits between your Raspberry Pi and the relay. An example of this circuit is shown in Figure 7.1:
This is the circuit we will build, piece-by-piece during this chapter. This circuit is representative of the many relay control modules that you will find on eBay, Banggood, and similar web sites. These boards are certainly convenient to use—when you get them to work. Unfortunately, all too often, a lack of clear documentation can make getting them to work fiddly and difficult, especially if you are new to electronics...