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 10. A Lights Manager with a TV Remote Controller

In this project, we will manage the lights of our home by using a normal TV remote controller.

In reality, we can use any remote controller we have, but the idea is to add remote controlling via the infrared mechanism to any device in our home. In fact, in this chapter I'm going to show how to manage a simple on/off device; but this concept can be easily extended to any other device we can connect to our BeagleBone Black!

We'll see how to capture the infrared messages that a remote controller sends to our BeagleBone Black by using a suitable circuitry, and then, we'll use a dedicated kernel driver in order to manage such messages and convert them into well-defined commands for our userspace programs.

The basics of functioning


The functioning of the prototype we're going to realize is quite simple. We need an electronic circuit that can detect the infrared light emitted by the remote controller and then generate some impulses that are caught by a special software that can detect and store them into a configuration file in order to be used at later time. Then, by using a special daemon, we can convert a button pressed on the remote controller into a suitable command for our BeagleBone Black.

In this scenario, the hardware we have to realize is very simple. We just need a small circuitry with an infrared-capable photo diode (infrared receiver). On the other hand, the software part is a bit more complicated due to the fact that we first need a kernel driver to reliably detect the message from the remote control, and then a user-level program to record it, a program to recognize which button has been pressed, and a last program to convert such pressures into on and off commands (or whatever...

Setting up the hardware


As stated before, the hardware setting is quite simple. The relays array has already been set up in a previous chapter, while the infrared receiver circuitry is really tricky. So, let's go ahead!

Setting up the infrared detector

The infrared detector (or receiver) I used in this prototype is shown in the following image (actually, the receiver is the device with the red dot; the other one is just a transmitter that we're not using here).

Note

The devices can be purchased at the following link (or by surfing the Internet): http://www.cosino.io/product/infrared-emitter-detector.

The datasheet is available at https://www.sparkfun.com/datasheets/Components/LTR-301.pdf.

Tip

Note that the image shows the topmost part only of the infrared devices. In reality, they look similar to a normal diode.

The circuit to manage it is shown in the following diagram:

The infrared receiver (IR) is the diode with the red dot in the preceding diagram and R is a 6.8KΩ resistor. The following table...

Setting up the software


Now, it's time to set up the software to manage our infrared detector, and to do it, we're going to use the LIRC (Linux Infrared Remote Control) subsystem, which is a special code that has been developed for this purpose.

Note

For further information on the LIRC subsystem, you can take a look at http://www.lirc.org/.

We'll need a kernel driver to convert the pulse generated by the infrared detector into well-defined messages, and then to send them, through a LIRC device, to the userspace programs. At userspace level, we're going to use a special tool from the LIRC project in order to convert the infrared messages into input events, that is, the messages that a normal keyboard sends to the kernel.

Note

For further information on the Linux input subsystem, you can take a look at https://www.kernel.org/doc/Documentation/input/input.txt.

Setting up the kernel driver

To set up the kernel driver to manage our infrared receiver, we can use a procedure similar to the one used in...

The final test


As in the previous chapters, we have to first execute the chapter_10/SYSINIT.sh file in the book's example code repository as usual to set up all GPIOs lines and to load the kernel module:

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

Then, we must execute the lircd daemon by using the command line without the --nodaemon option argument:

root@arm:~# lircd --device /dev/lirc0 --driver default --uinputmyremote.conf

Then, we can execute the preceding read_events.py program to manage the relays:

root@arm:~# ./read_events.py /dev/input/event0

Now the trick is done. We simply have to direct the remote controller to the infrared detector and press the 0, 1, 2, or 3 button. When we press the button, the switch turns on, while when we press the button again, the switch also turns off changing the status of the connected relay, and, as a last step, the device connected to it.

Summary


In this chapter, we took a look at a kernel driver to manage an infrared device. Then, we saw how to use the userspace tools from the LIRC project to receive the messages from the remote controller, and then to turn them into specific Linux input events. This allowed us to manage some devices connected with our BeagleBone Black.

In the next chapter, we'll discover how to manage a wireless device to manage a wall plug and to monitor the power consumption of the device connected to it by using a common communication system for the home automation, that is, the Z-Wave protocol.

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