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 7. Facebook Plant Monitor

Social networks are very common nowadays, and having a monitoring (or controlling) system that interacts with them has become a must, especially for consumer systems.

In this chapter, we're going to see how to implement a plant monitor capable of measuring solar light, soil moisture, and the soil temperature (internal and external) along with how to take some pictures at specific intervals via a webcam.

The user will be able to control the monitor through a web interface and they can then decide to publish the plant pictures on their Facebook timeline.

The basics of functioning


In this project, I'm going to present a simple implementation of a plant monitor with the following two special features:

  • The first feature is the ability to measure and estimate the soil moisture according to a direct measurement of the moisture via a dedicated sensor and through the temperature difference between the external soil temperature and the internal soil temperature in the garden pot where the plant lives. This is because the internal resistance of the moisture sensor may change with the temperature; in fact, when the sun beats down on the soil and the soil warms up, the resistance changes and this effect will produce a false dry read. For this reason, we employ two different temperature probes in order to know if the soil is too hot with respect to the internal soil temperature and then we regulate the moisture level.

  • The second feature is the ability to add a webcam to take several pictures of our lovely plant at well-defined intervals and the possibility...

Setting up the hardware


In this project, we are going to use two analog sensors, two digital sensors, and a webcam to take the pictures. The analog sensors are connected to two different ADC channels inputs (as in the previous chapter). The contactless external temperature sensor uses an I2C bus to communicate with the BeagleBone Black, while the waterproof internal temperature sensor uses a 1-Wire bus. Finally, the webcam is connected via the USB bus.

As in the previous chapter, I can add some actuators to flood water the plant and so on; but due to lack of space, I decided to leave these tasks to the reader as an exercise.

Connecting the moisture sensor

The moisture sensor is the device shown in the following image:

Note

The device can be purchased from http://www.cosino.io/product/moisture-sensor, or by surfing the Internet.

The user guide of this device is available at http://seeedstudio.com/wiki/Grove_-_Moisture_Sensor.

This device is quite similar to the water sensor presented in Chapter...

Setting up the software


This time, we monitor (and possibly control) a very slow system (a growing plant). So, using a simple Bash script is more than appropriate, while the web interface can be implemented by using two little HTML (with JavaScript) and PHP scripts. The real difficulty, apart from getting access to the peripherals, is using the Facebook API in order to get access to an account.

Apropos the monitoring loop and the web interface, there is a major issue, that is, the Inter Process Communication (IPC) system to use in order to exchange data between them. In Chapter 1, Dangerous Gas Sensors, we mainly used a MySQL server to store the system's data and configuration settings. But we also used it to exchange data between the different tasks composing the system! However, this time, we have very few data to store and using a database may be very expensive. So, I decided to use a simple way to solve the problem: I'm going to use a file! Yes, by using a normal file with a well-defined...

Final test


To test the prototype, I first executed the chapter_07/SYSINIT.sh file in the book's example code repository to set up all peripherals:

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

Now, after checking that the web server is running, I started the plant_mon.sh plant monitor script, enabling all debugging messages:

root@beaglebone:~# root@beaglebone:~/chapter_07# ./plant_mon.sh -d -l -f
plant_mon.sh: min=10
plant_mon.sh: signals traps installed
plant_mon.sh: lig_levl=442 int_temp=29.50 ext_temp=29.91 msr_mois=0
plant_mon.sh: curr_date=0010 next_date=
plant_mon.sh: start main loop
plant_mon.sh: lig_levl=428 int_temp=29.50 ext_temp=29.25 msr_mois=0
plant_mon.sh: curr_date=0010 next_date=0011
plant_mon.sh: cff_mois=50
plant_mon.sh: est_mois=221
plant_mon.sh: lig_levl=423 int_temp=29.50 ext_temp=27.99 msr_mois=0
plant_mon.sh: curr_date=0010 next_date=0011
plant_mon.sh: cff_mois=50
plant_mon.sh: est_mois=220
...

Then, I set up the web server's root directory in order to implement the web interface...

Summary


This time, we used several sensors to get important data about our lovely plant. Then, we also discovered a simple way to exchange this data between processes by using a normal file. We learned how to use the Facebook PHP API to do a post on a user's timeline by using a simple script.

In the next chapter, we'll try to implement an intrusion alarm system with motion detection sensors that, in case of alarm, will start taking pictures of the intruders and then send them to the user's e-mail address.

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