Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
BeagleBone Home Automation Blueprints

You're reading from   BeagleBone Home Automation Blueprints Automate and control your home using the power of the BeagleBone Black with practical home automation projects

Arrow left icon
Product type Paperback
Published in Feb 2016
Publisher
ISBN-13 9781783986026
Length 378 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Rodolfo Giometti Rodolfo Giometti
Author Profile Icon Rodolfo Giometti
Rodolfo Giometti
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Dangerous Gas Sensors FREE CHAPTER 2. Ultrasonic Parking Assistant 3. Aquarium Monitor 4. Google Docs Weather Station 5. WhatsApp Laundry Room Monitor 6. Baby Room Sentinel 7. Facebook Plant Monitor 8. Intrusion Detection System 9. Twitter Access Control System with Smart Card and RFID 10. A Lights Manager with a TV Remote Controller 11. A Wireless Home Controller with Z-Wave Index

Final test

Once everything has been connected and the software is ready, it's time to do a little test of our new system. The demonstration can be done by using a lighter. In fact, our system is really sensitive to the gas inside the lighter!

First of all, we have to check the system configuration:

root@beaglebone:~# ./my_dump.sh config
n   v
mq2_gain   0.125
mq2_off   0
mq2_th_ppm   150
mq4_gain   0.125
mq4_off   0
mq4_th_ppm   150
mq5_gain   0.125
mq5_off   0
mq5_th_ppm   150
mq7_gain   0.125
mq7_off   0
mq7_th_ppm   150
sms_delay_s   300

Tip

Note that I used a very weak calibration setting; however, these are okay for a demo.

Then, we can take a look at the system's current status:

root@beaglebone:~# ./my_dump.sh status
n   v
mq2   73.5
mq4   121.75
mq5   53
mq7   80.5
alarm   0

Then, we can do all hardware settings at once by using the chapter_01/SYSINIT.sh script in the book's example code repository as follows:

root@beaglebone:~# ./SYSINIT.sh
done!

Okay, now let's start all the required process daemons:

root@beaglebone:~# ./read_sensors.php -d -T 2
root@beaglebone:~# ./write_actuators.php -d -T 2
root@beaglebone:~# ./monitor.php -d -T 2

Tip

Note that all the daemons are running in background in this way; however, the debugging messages are enabled and they can be viewed into the system log with the following command:

# tail -f /var/log/syslog

Now, we have to approach the lighter to the sensors and press the button on the lighter in order to allow the sensor to detect the gas. After a while, the alarms should be turned on, and looking at the system status, we should get the following:

root@beaglebone:~# ./my_dump.sh status
n   v
mq2   203.875
mq4   166.5
mq5   52.5
mq7   122.625
alarm   1

Also, if we have set up a phone number, we should receive an SMS on the phone!

As last step, let's display the data logged by plotting them. We can use the following command to extract the data from the database:

root@beaglebone:~# ./my_dump.sh mq2_log | awk '{ print $2 " " $3 }' > mq2.log

In the mq2.log file, we should find something like the following:

root@beaglebone:~# cat mq2.log
15:02:07 75.25
15:02:10 74.25
15:02:12 74.25
15:02:14 74.375
15:02:16 74.25
...

Now, using the next command, we're going to create a PNG image holding a plot of our data:

$ gnuplot mq2.plot

Tip

Note that in order to execute this command, you need the gnuplot command, which can be installed by using the following command:

# aptitude install gnuplot

Also, both the mq2.log and mq2.plot files are need. The former is created by the preceding command line, while the latter can be found in the chapter_01/mq2.plot file in the book's example code repository. It holds the gnuplot instructions to effectively draw the plot.

The plot of the MQ-2 data of my test is shown in the following screenshot:

Final test

As you can see, the sensors are very sensitive to the gas; as soon as I opened my lighter and the gas reached them, the ppm concentration went to high values very quickly.

To stop the test, we can use the following commands:

root@beaglebone:~# killall read_sensors.php
root@beaglebone:~# killall write_actuators.php
root@beaglebone:~# killall monitor.php
You have been reading a chapter from
BeagleBone Home Automation Blueprints
Published in: Feb 2016
Publisher:
ISBN-13: 9781783986026
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image