Feature

Home Automation Shield for Arduino

Arduino Uno Shield with Bluetooth

Krrish Verma

Issue 58, May 2022

A custom-made Arduino Uno shield with four relays, Bluetooth connectivity and power failure support.

To control power in an Arduino Uno project, many makers would use a commercially available relay module. These are commonly available with one, two, four or eight relays on board, and include all the electronics needed to be compatible with an Arduino board.

Maker, Krrish Verma, has made his own 4-way relay module which can be controlled using a Smartphone app, and uses the EEPROM function so that the relays can return to their on or off state in the case of a power failure.

We caught up with Krrish to find out more about his shield.

Thank you for submitting your project via our website, Krrish. Please introduce yourself to our readers.

Greetings to everyone. My name is Krrish Verma, and I am a 17-year-old high school senior from India. I have a strong interest in electronics and have built several projects over the past six years. I am a maker and love self-learning and exploring new things.

What first got you interested in electronics?

The origins of my interests can be traced back to my childhood. Curiosity about how things work has always piqued my interest. Because of my insatiable curiosity, I had opened every toy and other electronic items I could find by the time I was twelve years old. Having no family background in tech, I had to be a self-learner. Earlier I wasn't aware of the name or types of components used and had no one to guide me, but after exploring and learning more (thanks to the internet), I believe I have equipped myself with a good amount of knowledge and hands-on experience.

Getting hands-on is the best way to learn, we reckon. Tell us about your project and what motivated you to make it?

My project is a Bluetooth home automation shield for the Arduino Uno board. It can be placed on top of the Arduino very easily and can be used to control four devices via the smartphone.

How does it differ from any commercially available products, if any?

Consider working on a project and encountering long wires everywhere. Every tutorial that you can find on YouTube shows how to build a home automation project using messy jumper wires. Those designs are not practically usable at all. It not only makes it messy and difficult to troubleshoot, but it also looks terrible as it cannot be used practically in-home or in any other workspace. So I decided to build a better solution, which is the Home Automation Shield for Arduino Uno, that eliminates the need for messy wires and can be placed in a nice 3D printed case so it can be used anywhere. As per my research, commercially, there is no other shield for the Arduino Uno for Bluetooth home automation. So mine is the first one from what I can see. However, one can find the PCBs for other Arduino boards, such as the Arduino Nano. There are also a lot of cheap, commercially available boards that don't have EEPROM, which makes it hard for them to be used in homes.

In your application, what kinds of devices are you switching?

Through the mobile application for my personal use, I have configured it to control one fan and three LED bulbs. However, one can customize what device they want to use according to their requirements. This board supports four appliances rated at up to 6 amps. I also added an option to control appliances using voice commands in the mobile app, which is a plus. If someone chooses to control the board using other apps available out there, they can do so by just customizing the commands.

Voice control is a nice touch. Can you give us an overview of how it all works?

The working of the project is quite simple. The main important components are the Bluetooth module and the relay.

When power is applied to the shield on the Arduino, the HC05 Bluetooth module starts and enters pairing mode, and the onboard LED begins blinking with a much longer time interval, indicating that the HC05 has been successfully connected. Once the user opens the smartphone app and selects the button, a command predefined in the app is sent to the HC05. HC05 then sends it to Arduino, which further checks the action to be performed by checking the variable defined for that command, and then tells the relays to turn on or off according to the command.

The board currently supports the HC05 Bluetooth module, which is one of the most commonly used ones out there. It can be controlled by any smartphone using Bluetooth. One just needs to download the mobile application. I created one that people can use. They can download it using the link in my Instructables.

If anyone does not want to use my application, they can download alternative apps such as Arduino Home Automation by Unica Robotics or Arduino Bluetooth Control by Broxcode. Both of the apps work fine and can be used as an alternative. One just needs to customize the buttons in the app.

Please explain to our readers who may be new to electronics why you needed to include transistors, resistors, and diodes to control the relays.

First of all, hi everyone. It’s great that you want to learn and explore more about electronics. So, as we are dealing with high voltage and the need to control appliances, I have used a relay in this project. A relay is similar to a mechanical switch, except that it can be controlled electrically rather than manually. The diode's purpose is to suppress the voltage that occurs when there is a sudden change in current flowing across the relay so that it does not cause harm to any components in the vicinity of the relay, such as the transistor and the external power source. The resistors have been used in two places: one for the power LED and another with relays. The resistor in a relay absorbs the excess voltage generated when the relay is actuated. This will protect the circuit's other components from voltage spikes. As a microcontroller pin cannot generate enough current to switch on a relay, transistors are employed. The microcontroller pin can generate enough current to turn on a transistor, and a transistor can provide enough current to turn on a relay.

Great. What prototyping did you need to do before you started your PCB design?

Before the development of PCB, I had built the project using the regular method with jumper cables. I had prepared the project and placed it inside my switchboard by wiring it to the appliances. It was a fundamental design similar to other automation projects on the internet, but it had EEPROM functionality.

Is there any special code you needed to write or re-mix, or was it just using existing libraries?

The code I wrote uses only one library, the EEPROM.h, which I used for the functioning of the EEPROM. The rest of the code is pretty simple as it has basic things defined in it, such as PINs of relays, TX and RX pins of the HC05 Module, and the variables for the Bluetooth commands.

It’s great that you have thought about power failures and the state the relay when the power dropped. Can you go into further detail about this?

Arduinos and other automation projects have a problem with power failures since the relays remain in either an on or off state after a power outage. The coder has already defined this in the code. But the problem is that we don't want to leave all of the lights on all the time. This is where EEPROM comes in. EEPROM stands for electronically erasable programmable read-only memory. Its values are kept even when the board is turned off. In the event of a power outage, it stores the current status of all of the relays in memory. So when the power returns, the relays are in the same state they were in before the outage.

Very clever. Were there any design challenges you needed to overcome to make it all work?

It is true that great things do not happen overnight. This was one of my first experiences designing a PCB board that I sent for manufacturing. Given the size of the Arduino Uno board, it is reasonable to assume that putting components for the Arduino Shield into such a small space will be a difficult task. I spent days figuring out the correct placement for the components so the design could be completed. Even though I could have used surface-mount components, I wanted the project to be simple enough that even a complete novice could put it together from the ground up. So I used through-hole components.

How did you go about designing and manufacturing the PCB? And, what did you learn during this process that our readers should know if they want to make their own PCBs?

EasyEDA was the software I used to design the printed circuit board. This software is helpful for anyone who wants to design sophisticated or simple printed circuit board projects, and it is even utilized by companies all over the world.

I placed an order with PCBway for the PCB manufacturing since they offered me a competitive price for the PCB. One tip for anyone interested in making their own printed circuit boards is that you should simply practice and persist. After a few weeks of daily practice, it becomes second nature. Apart from that, I suggest that you look at a few online tutorials to assist you in learning the PCB design rules.

Our readers could also consider our tutorial on using EAGLE in Issue 34. Is your bill of materials, code, and PCB files available if our readers want to make one for themselves?

Yes, if you want to create the project on your own, you can follow the instructions on my Instructables, which include detailed step-by-step instructions and illustrations. It also contains the PCB Gerber files, the Arduino code, and a bill of materials for your convenience.

Instructables Link: https://www.instructables.com/First-Ever-Bluetooth-Home-Automation-Shield-for-Ar/

Is there anything we haven't discussed that our readers should know about your project?

I feel I've covered everything there is to know about the project. Still, if your readers have any questions or need assistance, they can contact me via the social media handles mentioned on my website
https://www.krrishverma.com.

The Build:

Parts Required:JaycarAltronicsPakronics
1 x Arduino Uno or compatible boardXC4410Z6280ARD-A000066
1 x HC05 Bluetooth ModuleXC4382Z6365-
4 x BC547 TransistorsZT2152Z1040DF-FIT0322
4 x 1N4004/1N4007 Diodes or equivalentZR1004Z0109DF-FIT0323
1 x 100Ω ResistorsRR0548R7534SS110990043
4 x 220Ω ResistorsRR0556R0542SS110990043
1 x 5mm LEDZD0150Z0800DF-FIT0242
4 x 5V Relays^-Element14: 1798616-
1 x Header PinsHM3212P5430DF-FIT0084
1 x 6-Way Header SocketHM3230P5390ADA2886
4 x 2-Way Screw TerminalsHM3130P2040A-

Parts Required:

* Quantity used, item may only be available in packs.

^ Not identical to the relay used in the project, however, should be suitable.

The PCB

You will need to order the PCB board by uploading the Gerber file to a PCB manufacturing company, like JLCPCB, PCBWay, etc. I personally used PCBWay for ordering my PCBs.

Assembly

Follow the schematic and labels on the PCB board to place all the components and solder them accordingly.

Note: The shield has a place to solder an LED to indicate whether the board is receiving power or not. This is optional.

Placing the shield on the Arduino board

Place the shield on the Arduino with the help of male headers located on the shield so that all the connections get completed.

The Code

The code is available for download on the DIYODE website or my Instructables page. Upload this sketch to your Arduino Uno board.

Bluetooth control

To control the relays using Bluetooth, we need to set up the mobile application according to our needs.

For controlling the relays, you can use different apps. My personal favorites are:

1. Arduino Bluetooth Control By broxcode

2. Arduino Home Automation

You can use any of them, but the second one has a nice interface.

After installing, you have to edit buttons so you can set their value according to the code. For example, to turn relay one on, "A" has to be sent and to turn it off, "a" has to be sent. Similarly, you can set other buttons but make sure to follow the characters defined in the code for that.

A note from the editor

Even though the relays are rated to handle mains power, it is important that you only work with low power to avoid being electrocuted. In Australia, a person cannot legally work on voltages above 50Vac without a license. Any mistake made by any person working on lethal voltage equipment can lead to their own death, or that of another person.