Arduino project 1b: relay switch
I’m doing small Arduino projects to become better at working with Arduino. Today: a relay switch!
As you may know from my last post about an Arduino parking sensor, I’m working on a project with which can boost my Arduino skills. The project being a domotica system which can make the lights in my home switch on/off using my smartphone. It’s an ambitious goal since I’m an Arduino rookie, but we’ll get there eventually. Making this first project with my novice Arduino skills will be very hard. Therefore I decided it would be better to separate Project 1 (which I officially called it) into smaller chunks I can work on, and merge these chunks together later on.
Since my last post about an Arduino parking sensor I’ve been looking at relay switches. Relay switches are essential for domotica projects, because they can control high voltage appliances like lights or your toaster. Basically everything you use in your house that has a switch on it can be controlled. The problem with high voltage is that it’s dangerous. In my research I’ve found multiple warnings about high voltage, one of them being that it can kill you if you’re not careful. Since I’m a (nearly semi-)professional I decided to order a relay anyway. The fact the relay can handle high voltage doesn’t mean I’m immediately going to use it for that purpose, so we’re safe. For now.
The relay board I ordered has 4 switches, all with the same part number: Songle SRD-05VDC-SL-C. It cost me about €13,-. I’ve had tips from colleagues that Chinese web shops are much cheaper, but ever since I’ve ordered a malfunctioning/sort-of-melting iPhone charger I avoid buying electronics from these kind of sites. Chances are these are the same parts for a higher price, but it gives me some comfort.
Connecting the relay wasn’t hard at all. It has 2 connections on which you can attach a GND and VCC and 4 connections for every relay module on the board. If a current is applied to one of these ‘control wires’ the relay opens or closes, depending on which configuration you want. Nice detail: you can hear it click, which I think is awesome:
- Working with relays is very simple! Link the correct pins in your code, and send hihg/low commands to it to activate the relay.
- My Github project, containing all code for these Arduino blogposts: Github: ArduinoProjects
Off to project 1c! I think I’ll try to connect the Arduino to the internet using something called websockets. If I can pull that off it will be possible to control electrical appliances in my home via the internet. Exciting times!