IOT Home Security System
One of the most useful IoT applications is home security. Imagine a thief cutting your security camera wire while trying to break into your house, this won’t happen if your security system goes wireless and smart.
Buying off-the-shelves home security devices will easily cost you a fortune, but if DIY, the cost become very affordable!
Here I am going to show you how to make one real easy~
Supplies
- Realtek Ameba1 RTL8195AM microcontroller x2
- Reed sensor x1
- Magnet x1
- LED (red) x1
- Buzzer x1 J
- umper wire x6
Prepare a MQTT Server Connection
MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.
We can say MQTT is a protocol designed for IoT. MQTT is based on TCP/IP and transmits/receives data via publish/subscribe.
Since we are using ameba development board, we can register an account on the official website at https://www.amebaiot.com/en/, and get a free MQTT server connection at https://www.amebaiot.com/en/,
Note, once you have registered on AmebaIOT.com and have registered your device for “Cloud Service”, then the username and password you used to log in to AmebaIOT.com is the same for your MQTT connection, details will be explained later in the tutorial.
Software Setup
The center of every IoT (Internet-of-Things) project is a Wi-Fi-enabled microcontroller, our project is no exception. The Wi-Fi microcontroller used here is Ameba-1 RTL8195AM from Realtek, it has got many useful peripherals and a strong Wi-Fi module at a power low enough to run on a cell battery for weeks.
What’s more? This board is programmable on Arduino IDE! Yes, no learning hardcore software is needed, just open your Arduino IDE and paste the following link into the “additional board manager URLs” under “File -> Preferences” and the microcontroller’s entire toolchain and utilities will be downloaded automatically by installing this board from “Board Manager” under “Tools -> Board”
After that, you may download the source code from Github at https://github.com/Realtek-AmebaApp/Ameba_Examples/tree/master/RTL8195AM/006_HOME_SECURITY
Notice there are 2 ino. files in the repository, one for buzzer-connected ameba and another for LED-connected ameba.
The last thing you need to do about the code is to edit the following information on the code you just downloaded and then you are ready to hit that “Upload” button at last and get the code flashed on ameba in seconds.
Hardware Connection
You may refer to supplies section to get a list of things that you need (refer to figure 1).
For demonstration purpose, we built a wall with window using form board bought from DIY shop, and window using scrap transparent plastic box, you can skip this part if wanted.
The circuit connection is rather straightforward, check the connection map below to get everything connected,(refer to figure 2&3)
Here is how it looks when connection is done, (refer to figure 4)
Now apply some adhesives on both the reed switch and magnet and paste them on 2 sides of the window like this, (refer to figure 5)
Then put the buzzer and red LED connected to another ameba through the hole drilled on the board like this, (refer to figure 6)
So, the complete setup will look like this, (refer to figure 7)
Now, power both ameba up and enjoy this super handy and responsive IOT home security system!
PS: Once window is opened by the self-invited, the buzzer will make loudly irritating noises and red LED start flashing like crazy to alert the owner and scare off the self-invited.