Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
BeagleBone By Example

You're reading from  BeagleBone By Example

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785285059
Pages 262 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Getting Started with BeagleBone Circuit Fundamentals and GPIO Introduction to Physical Computing Systems Real-time Physical Computing Systems Using BeagleBone Connecting Physical Computing Systems to the Internet Home Automation Using BeagleBone Working with Images Using Computer Vision Home Security Systems Using BeagleBone Black Exploring Robotics Building Your Own Robot Index

Chapter 5. Connecting Physical Computing Systems to the Internet

In this chapter, we will be focusing on connecting the BeagleBone board to the Internet to connect the physical computing systems that we build to the Internet. First we will look into giving Internet access to the BeagleBone board via Ethernet, then we will learn how to add Wi-Fi capability to the BeagleBone board so that the system we build can be placed anywhere where we have Wi-Fi access, and so that we are not restricted to setting up the system only where the Ethernet is available. Once we are done with this, we will go ahead and build two projects; in the first one we will send an e-mail alert whenever the temperature sensor reading goes above a set level in the Python program running on the BeagleBone board. The next one will be a basic beginner project on Internet of Things for you to get started where the BeagleBone board will be uploading the temperature sensor data to a cloud server on the Internet. So basically...

Prerequisites


This topic will cover what parts you need to get started with this chapter. These can be purchased from your favorite electrical hobby store or can simply be ordered online.

Materials needed

Following are the materials that we will need before moving ahead:

  • 1x BeagleBone Black

  • 1x microSD card with latest version of Debian flashed on it to boot the BeagleBone board from the microSD card

  • 1x 5V DC, 2A power supply

  • 1x Ethernet cable

  • 1x LM35 temperature sensor

  • 1x compatible Wi-Fi dongle

  • 1x BreadBoard

  • A few jumper wires

Giving Internet access to your BeagleBone board


Giving Internet access to the BeagleBone board via the Ethernet is very simple. All you need to do is connect one end of Ethernet cable to the BeagleBone board, and the other end to a router with an Internet connection. The BeagleBone board will obtain the IP address dynamically from the router using DHCP and get Internet access. To check this you can just type in the following command:

ping www.google.com

You will get the response as shown in the following screenshot. This means you have a working Internet connection.

Actually, what the ping command does is, it tests the connection and latency between two network connections. The ping command sends packets of data to the other network computer, in our case the www.google.com server, or the IP address of that server. You can see next to www.google.com in the output above, the global IP address of the server is shown. The picture shows how the ping command measures the time taken to get a response...

Adding Wi-Fi to the BeagleBone board


To add Wi-Fi capability to the BeagleBone board, let's connect a Wi-Fi dongle in the USB port available on the BeagleBone board, as shown in the following picture:

Once you have connected the USB Wi-Fi dongle you can check whether it is connected or not by typing the following command:

  • lsusb: This is shown in the following screenshot where the USB Wi-Fi dongle is highlighted, that is Atheros Communications, Inc. AR9271 802.11n:

Then type the following command:

  • iwconfig: iwconfig will show you the details of the wireless LAN connection status, as shown in the previous screenshot, where you can see that wlan1, which is highlighted, shows the detail that is not associated with any access point as of now.

Our next step is to connect the Wi-Fi dongle to the Wi-Fi access point. To do this we will be using a program called wicd-curses, which is available in Debian by default.

To use the program we need to enter the following command:

  • sudo wicd-curses

Once you execute...

Intermediate level project: An e-mail alert fire alarm


First of all, as in the previous chapter, take three berg wires and connect the LM35 temperature sensor to the BeagleBone board, as per the circuit diagram shown in the following image:

Then we will turn on the BeagleBone board and login to the Linux shell to start coding it.

Open the Python console to learn and test how to send an e-mail using Python:

Our first step will be to import the smtplib into Python, which is the mail transfer protocol library with the predefined function that we will be using in the program.

Next create a variable to store the e-mail ID to which you need to send the e-mail:

Then create the variables where you need to store the e-mail ID and password of the account from which you want to send the e-mail:

Create an SMTP object with a Gmail hostname and port number 587:

EHLO is just like HELO except that the server's response text provides computer-readable information about the server's abilities. The response of this...

Advanced level project: Uploading sensor data to a web cloud


The connections are similar to the previous project, the only difference in that will be writing a new Python program to upload data to a freely available cloud server using HTTP call methods.

With the same connections as the previous project, connect the temperature sensor to the BeagleBone board.

Then the first thing we need to do is setup the cloud server to which we need to upload data. We will be using a freely available cloud storage space website specially setup for IoT applications. The website is www.thingspeak.com, We chose to use this cloud solution out of the many available because ThingSpeak makes it very simple to upload data from hardware to a cloud for IoT applications. They have a lot of examples for different hardware development boards used for different applications. Looking at these wide variety of examples and easy APIs will help you experiment a lot more on your own using the BeagleBone board than what we do...

Summary


In this chapter we learnt about giving Internet access to the BeagleBone board through Wi-Fi, and sending an e-mail alert whenever temperature measured, using a temperature sensor connected to BeagleBone board, goes high or low, depending on the threshold value set in the program. We also saw how we can upload data to the cloud web server using HTTP requests made to the server from the BeagleBone board using Python. So, we have learnt how to set up basic level Internet of Things projects in this chapter. You can go ahead and explore the options of using the requests module in Python to use HTTP Put, Post, and Get requests on various freely available open source cloud servers built for IoT which are just like https://thingspeak.com/, which we used in this chapter. There are options where, instead of uploading data using an HTTP post request, you can get data from a cloud server; that is you can read data from the cloud server and print it on the Python program. You can read data from...

lock icon The rest of the chapter is locked
You have been reading a chapter from
BeagleBone By Example
Published in: Aug 2016 Publisher: Packt ISBN-13: 9781785285059
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.
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}