Guard Bulb - Protects Your House When You Are Away

by Arpan Mondal in Circuits > Arduino

2590 Views, 21 Favorites, 0 Comments

Guard Bulb - Protects Your House When You Are Away

Black White Minimalist We Are Hiring Facebook Post.png
IMG20230228101208-01.jpeg
IMG20230228101120-01.jpeg

Picture this. You have just returned from a party, late at night. You loved meeting your old friends and were excited about the trip you guys planned for next week. But when you return home, you find the door open and everything inside messed up. Many of your precious items are missing. In less than a second, your happiness turned into terror. "If only I had a security system", you tell yourself as tears roll down your eyes. Well, everything I just wrote is not fiction. This is the true story of my neighbor!

But the problem is, home security systems are too expensive for most people to afford. That's when I got the idea to build this Guard Bulb! This is an extremely simple and inexpensive solution to increase the level of security at home when you are away. The concept is very simple. This is a replacement LED light that you plug in when you leave home at night. The light will turn on and off at random intervals. This will make people outside think that there's someone inside. It's that simple. No fancy security cameras or motion sensors. This is a cheap solution for people who cannot afford home security systems.

EDIT: I later added an additional feature with a speaker that makes dog barking sounds at random intervals. I haven't explained the procedure to add this feature in this Instructable. This is to keep the project beginner friendly.

Supplies

IMG20230228093140-01.jpeg
IMG20230228093310-01.jpeg

Arduino UNO / NodeMcu Link to buy

Light bulb Link to buy

Light bulb holder Link to buy

5V DC relay Link to buy

Wires Link to buy

5V power adapter (A smartphone charger will work) Link to buy

Design the Circuit

Screenshot from 2023-02-28 09-43-51.png
Screenshot from 2023-02-28 09-44-15.png

I used the Tinkercad circuit and code blocks editor to design the circuit and develop the code. This makes it easier for beginners to get into the fantastic world of Arduino.

The circuit is very simple. We are using pin 2 of the Arduino as the output. Since the Arduino cannot power the bulb directly, we take help from a relay. You can follow the diagram above for reference. In any case, I will embed my Tinkercad circuit in the next step for you to play around with and have a closer look at the connections and working.

The relay connections might look confusing at first, but it is straightforward when you look at the diagram. The coil (rightmost pins) is where the input goes. So one side will be connected to pin 2 of the Arduino and the other will go to GND. Now we need to pass one terminal of the power supply through the relay to the bulb. These will be the normally open (NO) pins of the relay. That will be the second and last pins on the top row. The other terminal of the power supply will be directly connected to the bulb.

Coding

Screenshot from 2023-02-28 09-45-44.png
Screenshot from 2023-02-28 09-56-08.png
Screenshot from 2023-02-28 09-57-20.png

I would suggest you use code blocks to develop the code if you are a beginner.

Let's start easy. First, we need to develop the logic behind its working. We want the bulb to turn ON at random intervals. For this, we can use the random() function in the code. Then we can assign a limit below which if the random number is present, the bulb turns ON. Then we need to assign a random duration for which the bulb will stay ON. This is simple. We just multiply the already generated random number by 10 and keep the bulb ON for that many seconds. Now let's have a look at the code.

Arduino has two functions by default. The SETUP and LOOP. Or in code blocks, we can call them ON START and FOREVER. The ON START part will run only once when you power the Arduino ON. The FOREVER part will run continuously until you power the Arduino OFF.

In the ON START section, we turn on pin 2, wait for 1 second and turn it off. This will blink the light bulb once to give a visual indication that the Guard Bulb is active now (I call it "Armed")

Then in the FOREVER section, we generate a random number between 1 to 200. This range defines how often the bulb will turn on. If you need the bulb to turn on more often, reduce the range. If you want it to turn on less often, increase the range. Then if the random number is less than 20, the bulb turns on. This is just a random number, the lower the number, the less often will the bulb turn on.

To test it, you can give my circuit a try. Below, you will find my Tinkercad simulation. When you press "Start simulation", the bulb will blink once to indicate it is now active. Then the bulb will turn on and off at random intervals. I have reduced the turn on and off delays to make sure you don't have to wait too long to see it working. In the actual code, the bulb turns on less frequently and stays on for a few seconds to a few minutes (chosen at random)

Build the Circuit

IMG20230228100844-01.jpeg
relay.jpg
IMG20230228093353-01.jpeg

Just follow the circuit you made on Tinkercad. I have assembled my circuit inside a black cardboard box to make it look cleaner and hide all the messy wiring. I have added an additional LED to have a visual indication of when the Guard Bulb is armed. There are two wires coming out of the box. One is to power the Arduino (Which powers the tiny LED too) and the other goes to mains to power the bulb. Make sure the Arduino is powered by a DC power adapter that supplies between 5V to 12V. Anything more might burn the Arduino! To keep it simple, you can power it with a 5V smartphone charger.

For the relay, I would suggest using a relay module that has built-in power supply circuitry (Like the one in the link in the "Supplies" section). This avoids the need for additional circuitry to power it and any kind of soldering. Since I had a bare relay lying around, I have used that for this project. Again, the Arduino input goes to the coil of the relay (Usually labeled as IN). One of the bulb wires goes through the Normally open (NO) terminal and the Common (COM) terminal of the relay. Some relays require additional 5V power which goes into the VCC terminal (Sometimes also labeled as 5v)

Confused? No worries, just refer to the simple diagram in the images above! Oh by the way, if you are curious about how I made the diagram - I used a free tool called draw.io

Final Thoughts and Improvements

IMG20230228101206-01.jpeg
IMG20230228101101-01.jpeg
IMG20230228101103-01.jpeg

And there you have it! This is quite a simple project and very good for beginners in the Arduino world. But make sure to keep in mind that you are dealing with mains voltage here. So be super careful. This project is not for kids to try alone. So kids, make sure you have adult supervision if you try to do this!

Now there might be a few questions. Why not integrate the circuit with an existing light bulb on the ceiling? Well, that's actually a better way to do it. But handling mains wires with DIY circuits is a risk. So unless you are an electrician, I'd suggest you make a separate module as I did.

But this is not it, you can customize it to your heart's content to make it better and more secure. For example, the dog bark sound I mentioned in the intro. You can also add microphones to detect sounds inside the house when you are out or heat sensors to detect fire. The possibilities are endless in the world of Arduino!

If you would like to explore more Arduino projects, here's one. This is a smart bedside mat that is also an alarm clock. When the alarm rings, you have to get up and stand on the mat for 10 seconds to stop it. It is also very simple to make for Arduino beginners. Have fun, and make sure to be super careful while handling mains voltage.