Hello everyone,
This is the final post. Which is good. Now that the project is complete I can think of enough enhancements to keep me busy for another 11 weeks.
Goal of this project was to see if I could use Bluetooth technology to implement a home security system. I originally wanted to use Bluetooth BLE for the project. When I saw all of the coding required and the steep learning curve I decided to go with legacy Bluetooth. Considering the small footprint that my HSS application covers there is no real disadvantage for me using legacy Bluetooth modules.
Even without Bluetooth BLE I accomplished my goal. I was able to create a network of switches and sensors to monitor and control devices in my house using Bluetooth modules. The application can:
- Turn lights and appliances on and off.
- Monitor for CO and Natural Gas leaks.
- Detect movement within the house.
- Provides outside camera surveillance.
- Open and close the garage door.
I do have one problem to solve. The video from the cameras are jerky. However, it is not the fault of the cameras, its app, or the BeagleBone black. The problem is my Internet service. I do not have enough upload bandwidth. I have considered upgrading my Internet service but could not cost justify it since the current service was good enough. Now I finally have a good reason to upgrade to a faster speed.
Developing and implementing this project in eleven weeks was very challenging. But well worth it. I learned a lot. Although I have developed a lot of web pages and have supported application web servers, I have never created a web server before. Also, I never developed a web page that I could modify without doing a get or post. I think I have done more soldering the past couple of weeks than I have done my entire life.
I did learn a little about Bluetooth BLE and a whole lot about legacy Bluetooth. I learned how difficult it is to use gas sensors. This was the first time I ever implemented a relay. Also, it is the first time I built a circuit using a transistor.
The rest of this post covers a demo video, the final hardware list, a list of the software used, the major problems I encountered, what went right during development, and future enhancements. Also, you find the code on GitHub athttps://github.com/kedwards999/BluetoothChallengehttps://github.com/kedwards999/BluetoothChallenge.
Congratulations to all of you who finished the Challenge!!!
Quote of the Moment –
We do these things not because they are easy but because they are hard
-- John F Kennedy - 35th President of the United States
Previous Bluetooth Challenge Home Security System Posts |
Bluetooth Challenge - Home Security System - Blog Post X |
Demo
Figure 1 shows what the screen looks like when I have two cameras connected. Since my Internet bandwidth is too low to handle two cameras. I will turn off the Backyard for the demo.
Figure 1.
My video editing skills are null and void so I ended up with 4 separate file for the demo.
Video 1 contains the demo for the smart plugs, which control a light and a fan. Note that there is a delay from the time I press the button to manipulate the switch and when the switch activates. The delay is caused by the mechanical relay.
Video 1.
Video 2 demonstrates how to open and close the garage door.
Video 2.
Video 3 demonstrates how the motion sensor works.
Video 3
Video 4 Demonstrates how the camera works. The video taken by the camera is jerky due to my Internet service as low bandwidth. Also, notice that the person's face is too dark to identify because it is in the shadows. This camera does not adjust when the background is bright and the object of interest is in the shadows.
Video 4.
Hardware List
Quantity | Device Name | Manufacturer | Part/Model Number |
1 | BeagleBone Black Wireless | Texas Instruments | BBBWL-SC-562BBBWL-SC-562 |
7 | Pro Trinket - 5V 16MHz | Adafruit | 2000 |
7 | HC-05 Bluetooth Module | DSD Tech | HC-05 |
2 | Enclosed High-power Power Relay | Digital Loggers | IoT |
1 | Emic 2 Text-to-Speech Module | Parallax | #30016 |
1 | Speaker | iHome | iM60 |
2 | Home camera/1080P/WiFi camera/Security camera system | Siepem | G7001Y-WR |
1 | ½” Brass Electric Solenoid Value 12 VDC Normally Open | US Solid | USS2-00078 |
1 | 5v Relay Module | Tolako | BJ-DT0Y-001 |
1 | PIR Sensor | Parallax |
|
1 | MQ-4 Gas Sensor | WINGONEER | JT0796 |
1 | MQ7 Carbon Monoxide Detection Sensor | WINGONEER | JT0794 |
1 | HC-SR04 Ultrasonic Sensor | Sparkfun | SEN-13959 |
1 | Garage Door Remote | Chamberlain | 953EV-P |
7 | Solderless Breadboards | Michael josh | LYSB01DDI54II-ELECTRNCS |
7+ | To power devices: USB plugs, micro USB to USB cables, AC/DC Adapters. Whatever I had laying around the house. | Different Manufacturers |
|
Software
- Arduino Sketch (C++)
- CSS
- Bluetoothctl
- Filezilla
- HTML
- jquery-3.3.1
- javascript
- nodejs
- PyBluez
- pyserial
- Python 2.7
Problems
I planned on using a Bluetooth mesh network. I went on the assumption that I could find a public API for building out a mesh network. I was wrong. I did not find an API. Everyone selling devices that used Bluetooth mesh used a proprietary protocol. Therefore, I could not acquire off-the-shelf Bluetooth enabled devices and connect them to my network. So, I used legacy Bluetooth modules (HC-05). Fortunately, I found a central location in my house that I could place the BeagleBone Black so that all Bluetooth modules could reach the BeagleBone Black in a single hop.
I ran out of space on the eMMC so I had to install a version of Linux on a micro SD card and boot from the SD card. It took several attempts for me to find a Debian image that was compatible with all of the software I was using. Then I had to reload the required software onto the new image.
I had problems accessing the UARTs on the new image. After a few days I finally figured out the changes I need to make to the /boot/uEnv.txt file.
I was going to connect the cameras using Bluetooth but decided against it after reading articles that suggested using Wi-Fi because Bluetooth was too slow. I had problems with the first set of cameras I acquired. I decided on buying different cameras. The new cameras contain more features than the old ones, so it worked out better in the long run.
The first smart plug I acquired contained proprietary protocols so I could not connect it to my network. It required me to use the smart plug’s mobile app to use it. I found a High-power Power Relay that was designed to hookup to an Arduino, so I used the Power Relay instead of the smart plug.
What Went Right
Other than running out of space (which was my fault) the BeagleBone Black Wireless worked great. I never had any problems with the Wi-Fi or Bluetooth modules. It had enough horsepower to run the HSS application. It never crashed even when I had it running over a week without re-booting.
I have no complaints about the Adafruit Pro Trinket either. All seven of them have been working flawlessly.
All of the HC-05 Bluetooth module have been working with out a problem. Not to mention, HC-05 is easy to configure.
I like the High-power Power Relays. The models I bought have an “always on” plug. I can use that plug to plugin the power source for the Pro Trinket instead of using a battery for a power source.
I found that I could power the Adafruit Pro Trinket with a USB charger or any AC/DC adapter that I had laying around. There was no need for me to use batteries or buy additional adapters to power my devices.
Future Enhancements
I have a satellite service hooked up to my TV. I noticed during testing that if I power off the set top box the system resets itself, which takes a about 10 minutes. Also, when the TV is powered off it does not automatically display a channel when it is powered back on. Therefore, I think the best approach is to use an IR transmitter to send signals to the TV/set top box. I have used IR for controlling mobile robots and it is not hard to setup.
If you noticed in my pictures all of the components are just setting on an open breadboard. I need to build cases for them to protect the components from damage. Also, I need to replace some of the long jumper wires with short wires.
Currently, the cameras are controlled by a separate app from the hss devices. I would like to be able to start the camera app from my web page so that I have only one user entry point for the hss application.
I used legacy Bluetooth instead of Bluetooth BLE. It worked. I did not have to contend with Bluetooth devices making multiple hops to get to the BeagleBone Black, which made the coding simpler and required less hardware. However, to make the application more robust, at some point I should switch to Bluetooth BLE.
I need to encrypt the Bluetooth data to prevent hackers from gaining access to the network. I also should add a log on feature to gain access to the web page.
If a Bluetooth device is not open when the hss controller starts the controller program will abort. I should make is more robust by spawning a thread which waits for the Bluetooth device to come online instead of aborting the hss controller.
Top Comments