Reader small image

You're reading from  BeagleBone Home Automation Blueprints

Product typeBook
Published inFeb 2016
Publisher
ISBN-139781783986026
Edition1st Edition
Right arrow
Author (1)
Rodolfo Giometti
Rodolfo Giometti
author image
Rodolfo Giometti

Rodolfo Giometti is an engineer, IT specialist, GNU/Linux expert and software libre evangelist. He is the author of the books BeagleBone Essentials, BeagleBone Home Automation Blueprints and GNU/Linux Rapid Embedded Programming by Packt Publishing and maintainer of the LinuxPPS projects. He still actively contributes to the Linux source code with several patches and new device drivers for industrial applications devices. During his 20+ years of experience, he has worked on the x86, ARM, MIPS, and PowerPC-based platforms. Now, he is the co-chief at HCE Engineering S.r.l., where he designs new hardware and software systems for the quick prototyping in industry environment, control automation, and remote monitoring.
Read more about Rodolfo Giometti

Right arrow

Chapter 3. Aquarium Monitor

In this chapter, we'll see how to realize an aquarium monitor where we'll be able to record all the environment data and then control the life of our loved fish from a web panel.

By using specific sensors, you'll learn how to monitor your aquarium with the possibility to set alarms, log the aquarium data (water temperature), and to perform actions such as cooling the water and feeding the fish.

Simply speaking, we're going to implement a simple aquarium web monitor with a real-time live video, some alarms in case of malfunctioning, and a simple temperature data logging that allows us to monitor the system from a standard PC as well as from a smartphone or tablet, without using any specifying mobile app, but just using the on-board standard browser only.

The basics of functioning


This aquarium monitor is a good (even if very simple) example about how a web monitoring system should be implemented, giving to the reader some basic ideas about how a mid-complex system works and how we can interact with it in order to modify some system settings, displaying some alarms in case of malfunctioning, and plotting a data logging on a PC, smartphone, or tablet.

Despite these aspects, the basic functioning of this project is similar to what we've already done in previous chapters: we have a periodic task that collects the data and then decides what to do. However, this time, we have a user interface (the web panel) to manage, and a video streaming to be redirected into a web page.

Note also that in this project, we need an additional power supply in order to power and manage 12V devices (such as a water pump, a lamp, and a cooler) with the BeagleBone Black, which is powered at 5V instead.

Note

Note that I'm not going to test this prototype on a real aquarium...

Setting up the hardware


About the hardware, there are at least two major issues to be pointed out:

  • Power supply: We have two different voltages to use due to the fact the water pump, the lamp, and the cooler are 12V powered, while the other devices are 5V/3.3V powered. So, we have to use a dual output power source (or two different power sources) to power up our prototype.

  • Interface: The second issue is about using a proper interface circuitry between the 12V world and the 5V one in such a way that it doesn't damage the BeagleBone Black or other devices. Let me point out that a single GPIO of the BeagleBone Black can manage a voltage of 3.3V, so we need a proper circuitry to manage a 12V device.

Setting up the 12V devices

As just stated, these devices need special attention and a dedicated 12V power line which, of course, cannot be the one we wish to use to supply the BeagleBone Black. On my prototype, I used a 12V power supplier that can supply a current till 1A. These characteristics should...

Setting up the software


Regarding the software, this time the major part is covered by the web interface, which is the real core of the project, and the acquisition and controlling process to get the aquarium data and managing the actuators. Then, a dedicated monitor script will be used to implement the communication between the web interface and the internal database.

Managing the system status and configuration

To manage the status of all devices and to do the data logging, we can use a database again to store all the relevant data, as we did in Chapter 1, Dangerous Gas Sensors. So, we can use the chapter_03/my_init.sh file in the book's example code repository to set up the database. The following snippet shows the relevant code where we define the tables used in the project:

# Select database
USE aquarium_mon;

#
# Create the system status table
#

CREATE TABLE status (
        n VARCHAR(64) NOT NULL,
        v VARCHAR(64) NOT NULL,
        PRIMARY KEY (n)
) ENGINE=MEMORY;

# Setup default...

Final test


To test the prototype, I turned on the board, and after the login, I set up the system by using the commands discussed before, or by using the chapter_03/SYSINIT.sh script in the book's example code repository, as follows:

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

Then, I executed the aquarium_mon.php command as follows:

root@beaglebone:~# ./aquarium_mon.php -d -f -l

Also, I executed the video streamer with the following command:

root@beaglebone:~# LD_LIBRARY_PATH=/usr/local/lib/ mjpg_streamer -i "input_uvc.so -y -f 10 -r QVGA" -o "output_http.so -w /var/www/"

Then, I pointed my browser to the aquarium.php file on the BeagleBone Black's IP address (that is, the URL http://192.168.7.2/aquarium.php) and the game is done!

Note that at this point, we can try to force some settings or try to change some configuration variables by using the chapter_03/my_dump.sh and chapter_03/my_set.sh scripts in the book's example code repository, as follows:

root@beaglebone:~# ./my_dump.sh config
n  ...

Summary


In this chapter, we discovered how to interface our BeagleBone Black to several devices with a different power supply voltage, and how to manage a 1-Wire device and a PWM one. Also, we presented the Drinks toolkit to realize a web control panel that can be used equally from a PC, smartphone, or tablet.

In the next chapter, we'll see how to realize a weather station that can store its collected data locally, which can not only show them in a nice manner on a web browser, but also can send its data to a Google Docs document!

Simply speaking, we're going to realize a simple Internet-of-Things (IoT) machine.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
BeagleBone Home Automation Blueprints
Published in: Feb 2016Publisher: 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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Rodolfo Giometti

Rodolfo Giometti is an engineer, IT specialist, GNU/Linux expert and software libre evangelist. He is the author of the books BeagleBone Essentials, BeagleBone Home Automation Blueprints and GNU/Linux Rapid Embedded Programming by Packt Publishing and maintainer of the LinuxPPS projects. He still actively contributes to the Linux source code with several patches and new device drivers for industrial applications devices. During his 20+ years of experience, he has worked on the x86, ARM, MIPS, and PowerPC-based platforms. Now, he is the co-chief at HCE Engineering S.r.l., where he designs new hardware and software systems for the quick prototyping in industry environment, control automation, and remote monitoring.
Read more about Rodolfo Giometti