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 9. Twitter Access Control System with Smart Card and RFID

Identifying people or objects with a computer may seem like an easy task, but, in reality, there is a lot of technology behind the devices used to accomplish this task.

In this chapter, we are going to use a smart card reader and two kinds of RFID readers (a Low Frequency or LF reader suitable for short ranges and an Ultra High Frequency or UHF reader suitable for long ranges) in order to show different possibilities to implement a minimal identifying system for access control.

Once the detection has been done, the system will send a message to our Twitter account informing our followers about what is happening (in a normal case, we may lock or unlock something, but I decided to do something different).

The basics of functioning


The smart cards and the smart card readers, for example, are complex devices that are used everywhere nowadays, from our credit cards to our smartphones. The term smart card implies a set of technologies, including integrated circuits, microprocessors, memories, antennas, and so on, in the same integrated circuit, to form a microchip that is the heart of a smart card. On the other hand, the smart card readers are complex devices that can communicate with the cards and save data on it or return data to a computer.

Note

The reader can get more information regarding the smart card world by taking a look at https://en.wikipedia.org/wiki/Smart_card.

The evolution of smart cards are the Radio-Frequency Identification (RFID) devices that can be used to identify people or objects in a contactless form, starting from a few centimeters to several meters. The RFID readers and the corresponding tags (or transponders) are high technology radio devices that can exchange data to...

Setting up the hardware


As just said in the previous section, this time we have to connect a USB device and two serial devices. Regarding the USB device, the main problem is that it has a nonstandard USB connector, so we have to find a trick to solve the problem (see the following part); while for the serial devices, we have to find two free serial ports on the BeagleBone Black's expansion connectors.

Regarding this last issue, we should remember that the BeagleBone Black has six on-board serial ports that are disabled by default, except the /dev/ttyO0 device, which is coupled to the serial console. If we do log in into the system, we can easily verify it by using the following command:

root@BeagleBone:~# ls -l /dev/ttyO*
crw-rw---- 1 root tty 248, 0 Apr 23 20:20 /dev/ttyO0

To enable the other serial ports, we need to modify the kernel settings in order to enable the serial port that we wish to use. The choice of which ports to enable depends on the pins we'd like to use to connect our devices...

Setting up the software


After the hardware has been set up, most of the job is done; to finish our job, we need to first install a tool to get access to our Twitter account, and then we have to add a mechanism to call it each time a successful identification process is accomplished. So, in the following sections I'm going to show how to install and correctly set up a command line tool to communicate with Twitter and then how to call it in three different programming languages for three different identification systems.

To simplify the project a bit, we can use a static list of known IDs stored in each program, but you can understand that this list can be easily managed by an external database. So, I leave this implementation as an exercise for you.

Setting up the Twitter utility

The utility I'm going to use to get access to a Twitter account is named with the single character t. The t program, as reported on its home page, derives from the Twitter SMS commands:

The CLI takes syntactic cues from...

Final test


To test our prototype, we have to run the three different programs presented in the preceding section. As in the previous chapters, I first executed the chapter_09/SYSINIT.sh file in the book's example code repository as usual to set up all peripherals:

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

Then, let's start the smart card program and insert the smartcard as follows:

root@beaglebone:~/smart_card# ./smart_card2twitter.py
INFO:root:got tag ID 3B BE 11 00 00 41 01 38 00 00 00 00 00 00 00 00 01 90 00
INFO:root:Twitting that Rodolfo Giometti was arrived!
Tweet posted by @RodolfoGiometti.

Run `t delete status 649586168313552896` to delete.

Now, press the CTRL + C keys to stop the program, and let's try the RFID LF program as follows by approaching the relative tag:

root@beaglebone:~/rfid_lf# ./rfid_lf2twitter.sh /dev/ttyO1
rfid_lf2twitter.sh: got tag ID 6F007F4E1E40
rfid_lf2twitter.sh: Twitting that Rodolfo Giometti was arrived!
Tweet posted by @RodolfoGiometti.

Run `t delete status...

Summary


In this chapter, we discovered how to publish a message to a Twitter account and three different ways to identify people or objects by using different identification technologies and programming languages.

In the next chapter, we'll discover how to manage some lights by using a common remote controller (or any infrared capable device). We'll see how our BeagleBone Black board can receive some commands by using our TV remote.

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