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 5. WhatsApp Laundry Room Monitor

In this chapter, we'll see how to implement a laundry monitor room with several sensors capable of alerting the user directly on their WhatsApp account when a specific event occurs.

We'll see how to connect a sound sensor and a light sensor to our BeagleBone Black and then how we can monitor our washing machine with them. Also, we'll see how we can interact with the user directly on the user's smartphone by using a WhatsApp account in order to notify them of some events.

The basics of functioning


Let's assume that our laundry room is equipped with a washing machine and a lamp used by the user when they have to pick up the laundry. In these conditions, the BeagleBone Black can be equipped with some special sensors to detect when the washing machine has started or finished its job and when someone goes into the laundry room to pick up the washed clothes.

In this scenario, the BeagleBone Black should detect when the washing machine has been started by the user and then wait until the job has finished. At this point, the system can generate a WhatsApp message to alert the user that they have to pick up their clothes. When the user enters into the room, the light is turned on, and when they leave the room, the light is turned off. In this manner, our BeagleBone Black can detect when the user has done their job and then restart the cycle.

Setting up the hardware


As just stated, in this project we need two different kind of sensors: one to detect when the washing machine starts/stop, and one to detect when someone enters/exits the laundry room. The former task can be achieved by using a sound detector, that is, a device that is able to measure the environment sound level; while the latter task can be achieved by using a light sensor, that is, a device that is able to measure the environment light. Both these signals can be compared with thresholds in order to detect our relevant events.

When the washing machine is running, we should measure a high sound level for a long amount of time; while it is not running, the environment sound should be near to zero for a long time. On the other hand, we can assume that the person designed to pick up the washed clothes has to turn the light on in the laundry room, while the light is normally turned off when there is nobody in the room.

To help the user understand what happens inside the...

Setting up the software


This time, to implement the software of this prototype, we can use a state-machine with the following states and their relative transactions:

Final test


To test the prototype, I used some tricks to simulate the washing machine and the light in the room. The washing machine can be easily simulated by an audio/video played on the host PC with a reasonable volume level, while the room light on/off status can be simulated by using a small cup to cover the light sensor.

To set up all peripherals and drivers, we can use all the preceding commands or the SYSINIT.sh script as follows:

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

Note

This command can be found in the chapter_05/SYSINIT.sh file in the book's example code repository

As an initial state (IDLE), we should cover the light sensor (to simulate that the light is off) and we should stop the video/audio player (to simulate that the washing machine is off). Then, we have to set a low threshold level into the configuration file for both sound and light detection and a very short timeout (5 seconds) in order to speed up the test. The following is my configuration file:

root@beaglebone:~# cat config...

Summary


In this chapter, we discovered how to detect sound and light levels by using specific sensors and how to write a simple Bash script to implement a state machine to manage our laundry room. Also, we discovered how to send some alerting messages to a smartphone through the WhatsApp service.

In the next chapter, we'll try to implement a baby room sentinel to control what happens to our little baby! We'll be able to monitor the room temperature, detect if the baby is crying or if she is actually breathing, and much more.

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 €14.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

State

Description

Actions

Transaction conditions

IDLE

Idle state; the washing machine is not working.

  • LED yellow off

  • LED red off

  • If sound is detected, set t0=t and move state to SOUND.

SOUND

Sound detected! Keep monitoring the environment for a while.

  • LED yellow is blinking

  • LED red is off

  • If sound is detected and t-t0 > timeout, move to RUNNING.

RUNNING

Continuous sound detected so the washing machine has started its job.

  • LED yellow is on

  • LED red is off

  • Alert the user

  • If no sound is detected, set t0=t and move to NO_SOUND.

NO_SOUND

No more sound detected! Keep monitoring the environment for a while.

  • LED yellow is on

  • LED red is blinking

  • If no sound is detected and t-t0 > timeout, move to DONE.

  • If sound is detected, move to RUNNING.

DONE

No more sound for a long delay; the washing machine has finished...