0% found this document useful (0 votes)
366 views

Internet of Things With Raspberry Pi

Uploaded by

Arslan Coskun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
366 views

Internet of Things With Raspberry Pi

Uploaded by

Arslan Coskun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Internet of Things With the

Raspberry Pi
Build Internet of Things Projects Using
the Raspberry Pi Platform
Marco Schwartz, PhD

Contents
Legal
Acknowledgments
About the Author
About the Companion Website
Introduction
1 Who Is This Book For?
2 Organization Of The Book
3 Prerequisites
Chapter 1 Building a Cloud Data Logger
1.1 Hardware & Software Requirements
1.2 Hardware Configuration
1.3 Sending Data to the Cloud
1.4 Visualizing Data
1.5 How to Go Further
Chapter 2 Controlling a Lamp From Anywhere
2.1 Hardware & Software Requirements
2.2 Hardware Configuration
2.3 Creating Your Lelylan Dashboard
2.4 Controlling Your Lamp From Anywhere
2.5 How to Go Further
Chapter 3 Making a Cloud Security Camera
3.1 Hardware & Software Requirements
3.2 Hardware Configuration
3.3 Testing the Camera
3.4 Local Video Streaming
3.5 Cloud Video Streaming
3.6 How to Go Further
Chapter 4 Conclusion
4.1 How to Go Further
Chapter 5 Resources
5.1 General Information About the Raspberry Pi
5.2 Components
5.3 Suggested Reading

Legal
Copyright © 2015 by Marc-Olivier Schwartz

All rights reserved. No part of this book may be used or reproduced in any
manner whatsoever without permission except in the case of brief quotations
embodied in critical articles or reviews.

First edition: May 2015

Acknowledgments
To all my friends who encouraged me while writing this book.

To my parents who supported me during all projects I worked on in my life,


even in tough times.

To my girlfriend Sylwia for supporting me and encouraging me in


everything I do. You are my source of inspiration I need to get up every
day and continue to work hard to become a better entrepreneur and a
better person. Thank you.
About the Author
I am Marco Schwartz, and I am an electrical engineer, entrepreneur and
author. I have a Master’s degree in Electrical Engineering & Computer
Science from one of the top Electrical Engineering school in France, and a
Master’s degree in Micro Engineering from the EPFL university in
Switzerland. I also own a PhD from the University of Heidelberg in
Germany, where I worked in microelectronics.

I have more than 5 years of experience working in the domain of electrical


engineering. My interests gravitate around electronics, home automation,
the Arduino & Raspberry Pi platforms, open-source hardware projects, and
3D printing.

Since 2011 I have been working full-time as an entrepreneur, running


websites with information about open-source hardware and building my
own open-source hardware products.

About the Companion Website


This book has a companion website, Open Home Automation, which you can
easily find by going at http://www.openhomeautomation.net. On this
website you will find even more projects and resources around home
automation and open-source hardware.

All the code that can be found in this book can also be accessed online at
https://github.com/openhomeautomation/iot-raspberry-pi-book. This
GitHub repository for the book contains all the latest up-to-date code for all
the projects you will find in this book.
To download the code from GitHub, you can simply go on the GitHub page
and click on the “Download ZIP” button.

Also, if at any moment you are encountering an issue while reading this
book, like some code that won’t compile or a project that doesn’t work,
please contact me directly on the following email:

[email protected]

Introduction
You probably have heard all about what you can do with the Raspberry Pi.
This credit-card sized computer can be plugged into your TV or any HDMI
monitor to replace a typical computer. This little device is used in many
computer projects, DIY electronics projects and even as a learning tool for
kids who want to learn the basics of computer programming.

But among all, the Raspberry Pi is the perfect board for the Internet of
Things. It is cheap, powerful, and can be interfaced with many sensors and
actuators that can be used for Internet of Things applications. By using the
Raspberry Pi, you can easily build Internet of Things projects.

We will see that as we can install a full Linux distribution on our Rasperry Pi,
it allows us to use powerful frameworks like Node.js, which is a JavaScript
framework used to build server-side applications. This might sound a little
complicated, but this will make it really easy to interface with cloud-based
services in order to build Internet of Things applications.

The Raspberry Pi also have an amazing online community that are already
building Internet of Things projects, so you can be sure to get immediate
help in case you need some.
All of these points make the Raspberry Pi the ideal platform to build Internet
of Things projects, and this is exactly what you will learn to do in this book.
1 Who Is This Book For?
This book is for all the people who want to use the Raspberry Pi platform to
build Internet of Things projects.

This book is also for the people who are currently building Internet of Things
projects with other platforms like Arduino, and who want to extend their
knowledge, for example by using the Raspberry Pi for more advanced
Internet of Things projects.

Finally, this book is also for people who just want to learn more about how to
use the Raspberry Pi and get knowledge in electronics & programming.

2 Organization Of The Book


The book is organized in 3 projects. We will start with a quite basic project,
and then gradually move to more complex projects using the Raspberry Pi.

In the first chapter, Building a Cloud Data Logger, we are going to connect a
basic temperature & humidity sensor to the Raspberry, and monitor the data
from an online dashboard, that is accessible from anywhere in the world.

In the second chapter, Controlling a Lamp From Anywhere, we are going to


connect a lamp to the Raspberry Pi. Then, we will configure an online
dashboard so this lamp can be switched on & off from any web browser.

Finally, in the third chapter, Making a Cloud Security Camera, we are going
to make our own DIY version of a security camera, so you can monitor your
home for example from anywhere in the world.
3 Prerequisites
To use this book, you will need to have some basic skills in programming &
electronics. It is recommended that you have some basic experience with
JavaScript and with client/server interactions.

On the electronics side, a basic experience is required, as you will need to


connect sensors to the Raspberry Pi. However, with the detailed
explanations that you will find in every chapter of the book, you will be able
to follow the different projects without difficulties.

To use all the projects found in this book, you will also need a fully
functioning Raspberry Pi, configured with the Raspbian Linux distribution,
and connected to the Internet. If you need help doing that, you will find all
the required resources on the official Raspberry Pi webite:

https://www.raspberrypi.org/

In this book, I will also usually access my Raspberry Pi via SSH, from my
own computer. You can learn more about how to do that here:

https://www.raspberrypi.org/documentation/remote-access/ssh/

However, you can perfectly do all the projects of this book directly on your
Raspberry Pi, for example if it is connected to an external display.
Chapter 1
Building a Cloud Data Logger
In this first project of the book, we will learn how to use the Raspberry Pi to
monitor some data remotely, from anywhere in the world. This is a project
that you can use for any monitoring applications, as you will be able to
change the sensors used in the project by your own sensors, to monitor the
data that you need.

We will start by connecting a simple temperature & humidity sensor to your


Raspberry Pi. Then, we will use a service called Dweet.io to store data in the
cloud. Finally, we will integrate these measurement in the cloud to another
service called Freeboard.io. This one will allow us to graphically monitor the
data coming from your Raspberry Pi.

1.1 Hardware & Software


Requirements
First, you will need a Raspberry Pi. Basically, every model of Raspberry Pi
will work, so you can use Raspberry Pi A/A+, B/B+/2, it will works just as
well.

Then, you will need all the supporting hardware to make the Pi work: a
microSD card, a microUSB power supply, and an HDMI cable if you want to
connect the Pi to a screen. If you want to use WiFi for this project, you will
also need an USD WiFi dongle.
You will also need a DHT11 sensor to measure the temperature & humidity.

Finally, you will need a Raspberry Pi cobbler kit, jumper wires and
breadboard to make the connections between the Raspberry Pi and the
sensor.

This is a list of all the components you will need in this projects:

Raspberry Pi (https://www.adafruit.com/product/2358)
DHT11 sensor with 4.7K Ohm resistor
(https://www.adafruit.com/product/386)
USB WiFi dongle (https://www.adafruit.com/product/1012)
Adafruit Raspberry Pi Cobbler kit
(https://www.adafruit.com/product/1754)
Jumper wires (https://www.adafruit.com/products/758)
Breadboard (https://www.adafruit.com/products/64)

Note that the Raspberry Pi has to be fully configured with the Raspbian
distribution in order to start this project.

On the software side, you will also need to install several components. The
first one is driver for the BCM chip of the Raspberry Pi. You can install it by
following the instructions from this link:

http://www.airspayce.com/mikem/bcm2835/

Finally, you will also need to have Node.js installed on your Pi. You can get it
by typing the following commands in a terminal:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

1.2 Hardware Configuration


We are now going to connect the sensor to your Raspberry Pi. This is a
schematic to help you out:

The DHT sensor signal pin (pin number 2 of the sensor) has to be connected
on pin 4 of the Raspberry Pi. Also connect the VCC pin (pin number 1 of the
sensor) of the sensor to the RPi 3.3V, and GND to GND. Finally, insert a 4.7K
Ohm resistor between pin number 1 and 2.

This is the final result, without the connection between the Raspberry Pi and
the breadboard:
This is a top view of the whole system:
1.3 Sending Data to the Cloud
We are now going to configure the project so it sends data to the cloud. For
that, we will a cloud service called Dweet.io. This is a very simple way to store
data in the cloud, as it doesn’t require any registration. You can find more
information about Dweet.io at:

http://dweet.io/

This is the main page of Dweet.io, where you can find more information
about their API:
We are now going to write the code that we will use to send data to Dweet.io.
This code will be based on Node.js that we installed earlier. This is the
complete code for this part:

// Include required modules


var sensorLib = require('node-dht-sensor');
var dweetClient = require("node-dweetio");

// Create Dweet.io client


var dweetio = new dweetClient();

// Read from sensor & send to Dweet.io


var sensor = {
initialize: function () {
return sensorLib.initialize(11, 4);
},
read: function () {

// Read from sensor


var readout = sensorLib.read();
var temperature = readout.temperature.toFixed(2);
var humidity = readout.humidity.toFixed(2);
console.log('Temperature: ' + temperature + 'C, ' +
'humidity: ' + humidity + '%');

// Send to Dweet
dweetio.dweet({temperature: temperature,
humidity: humidity}, function(err, dweet){

console.log(dweet.thing); // The generated name


console.log(dweet.content); // The content of the dweet
console.log(dweet.created); // The create date of the dweet
});

setTimeout(function () {
sensor.read();
}, 10000);
}
};

// Initialize DHT11 sensor


if (sensor.initialize()) {
sensor.read();
} else {
console.warn('Failed to initialize sensor');
}

Let’s now see the details of this code. It starts by importing the required
modules, a module for the DHT sensor, and a module for Dweet.io:

var sensorLib = require('node-dht-sensor');


var dweetClient = require("node-dweetio");

Then, we initialize the Dweet.io client:

var dweetio = new dweetClient();

After that, every 10 seconds, we read data from the DHT11 sensor:

var readout = sensorLib.read();


var temperature = readout.temperature.toFixed(2);
var humidity = readout.humidity.toFixed(2);

Then, we send this data to Dweet.io using the instance we defined before:

dweetio.dweet({temperature: temperature, humidity: humidity},


function(err, dweet){

console.log(dweet.thing); // The generated name


console.log(dweet.content); // The content of the dweet
console.log(dweet.created); // The create date of the dweet
});

Note that the complete code is also available inside the GitHub repository of
the book:

https://github.com/openhomeautomation/iot-raspberry-pi-book

Now, put all this file inside a folder on your Pi, and access this folder via a
terminal. Then, type this in a terminal:

npm install node-dht-sensor


Then type:

npm install node-dweetio

And finally launch the app with:

sudo node app.js

You should see the following being printed in the terminal:

Write down the name of your Dweet.io device (here, “instinctive-horses”) that
is created automatically. Now, as long as this Node.js app is running, data is
logged on Dweet.io every 10 seconds.

1.4 Visualizing Data


Logging data on the cloud is good, but we would like to see the data
graphically as it is measured by the Raspberry Pi board.

To do that, we are going to use Freeboard.io, which is the perfect solution to


create Internet of Things dashboards. You can find it at:

https://www.freeboard.io/

The first step is to create an account there:


Then, create a new dashboard, and inside this new datasource. This is where
you can enter the Dweet.io thing name that you got before:

After that, you should see that data is coming from the board:
Then create new Pane, and then new widget. We are going to create a Gauge
widget to visualize the current temperature:

These settings will link the widget to the datasource we created before, and to
the temperature field sent by the Raspberry Pi.

Then, you can do the same for humidity:


This is the final result inside the dashboard:

Congratulations, you just built your own Internet of Things dashboard! You
will then see that the two gauges are automatically updated every 10 seconds,
as data comes from the Raspberry Pi. Also note that this dashboard is
available from any web browser, so you can monitor this data from anywhere!
1.5 How to Go Further
Let’s first summarise what we did in this chapter. We connected a
temperature & humidity sensor to your Pi, and then monitored this data from
a cloud dashboard that can be accessed from anywhere in the world.

There are many things you can do to use what you learned in this project and
to build your own projects. You can for example add more sensors to the
project to monitor other variables, like the barometric pressure. You could
also add several of these projects at different locations, and then monitor all
of them from a single dashboard.
Chapter 2
Controlling a Lamp From
Anywhere
In this chapter, we are going to do a completely different project using your
Raspberry Pi. We are not going to send any data from your Raspberry Pi to
the cloud, but on the contrary we are going to send data from the cloud to
your Raspberry Pi. As an example, we are going to see how to control a lamp
from anywhere in the world.

To do so, we are first going to connect a component called the PowerSwitch


Tail Kit, which makes it really easy to connect a lamp or other electrical
appliances to your Pi. Then, we will create an online dashboard to control the
Raspberry Pi remotely. Finally, we will build the code that will connect our Pi
the online dashboard we just created.

2.1 Hardware & Software


Requirements
The first thing that you will need for this project, except the Raspberry Pi and
all the supporting components, is the PowerSwitch Tail Kit. Here is a picture
of this component:
Note that there are many of these kits available, whether you want a EU or US
version for example. I used the EU version for all these tutorials, but any
version will work just fine as well.

This is a list of all the components you will need in this projects:

Raspberry Pi (https://www.adafruit.com/product/2358)
PowerSwitch Tail Kit (https://www.adafruit.com/product/268)
USB WiFi dongle (https://www.adafruit.com/product/1012)
Adafruit Raspberry Pi Cobbler kit
(https://www.adafruit.com/product/1754)
Jumper wires (https://www.adafruit.com/products/758)
Breadboard (https://www.adafruit.com/products/64)
Note that the Raspberry Pi has to be fully configured with the Raspbian
distribution in order to start this project.

2.2 Hardware Configuration


Let’s now see how to connect the PowerSwitch Tail Kit to your Pi. This will be
really simple. This a schematic to help you out:

The first step is to place the cobbler kit on the breadboard. Then, connect the
pin number 1 of the PowerSwitch to pin number 23 of the cobbler kit. Finally,
connect the two other pins of the PowerSwitch to the GND pin of the cobbler
kit.

This is a picture of the fully assembled project:

You can now connect an electrical device (I used a 30W desk lamp) to the
PowerSwitch, and then also connect it to the mains electricity.

2.3 Creating Your Lelylan


Dashboard
Now that our hardware is ready, we are going to create an online dashboard
so we can control our electrical device from anywhere in the world. For that,
we will use a service called Lelylan, that will allow us to create a dashboard
easily. This is the link where you can register for an account:

http://lelylan.github.io/devices-dashboard-ng/#/login

When you have an account, you will be redirected to your dashboard which is
empty for now. You can then create a new device and give it a name:

After that, you will be asked to choose the device type. Select Basic Light.
Then, on the next page, choose Connect with MQTT, as we will use the MQTT
protocol to connect our Raspberry Pi to the cloud.

Once the device is created, you will be able to get the details of your new
device:
Write down the ID & Secret of the device, you will need them in a moment to
modify the code on the Raspberry Pi.

You will also see that your lamp is turned off for now:
2.4 Controlling Your Lamp
From Anywhere
It’s now time to write some code, to link the Raspberry Pi to the Lelylan
dashboard. As I mentioned before, we are going to use the MQTT protocol
for that purpose. MQTT is a lightweight protocol that was designed
specifically for the Internet of Things. You can find more information about it
on:

http://mqtt.org/
This is the complete code for this part:

// Device ID & secret


var device_id = "device_id";
var device_secret = "device_secret";

// Required modules
var gpio = require('rpi-gpio');
var mqtt = require('mqtt');

var client = mqtt.createClient(1883, "178.62.108.47", {


username: device_id,
password: device_secret,
clientId: "7393956449"
});

// Topics
in_topic = 'devices/' + device_id + '/get';
out_topic = 'devices/' + device_id + '/set';

// Set output pin


gpio.setMode(gpio.MODE_BCM);
gpio.setup(23, gpio.DIR_OUT);

// Connect event
client.on('connect', function () {
client.subscribe(in_topic);
});

// When message is received


client.on('message', function (topic, message) {

// Message is Buffer
console.log(message.toString());

json_data = JSON.parse(message.toString());

// Check the status property value


var value = json_data['properties'][0]['value']

if (value == 'on') {
gpio.write(23, true, function(err) {
if (err) throw err;
console.log('Written to pin');
});
}

if (value == 'off') {
gpio.write(23, false, function(err) {
if (err) throw err;
console.log('Written to pin');
});
}

// Confirm to Lelylan
client.publish(out_topic, message.toString())
});

Let’s now see the important parts of this code. The code starts by declaring
the device ID and device secret, which you need to modify with your own data
you got before from Lelylan:
var device_id = "device_id";
var device_secret = "device_secret";

Then, we import the two required modules for this project: the rpi-gpio
module to control the GPIO pins of the board, and the MQTT module. This is
done by the following lines of code:

var gpio = require('rpi-gpio');


var mqtt = require('mqtt');

Then, we connect the MQTT client to the Lelylan MQTT broker:

var client = mqtt.createClient(1883, "178.62.108.47", {


username: device_id,
password: device_secret,
clientId: "7393956449"
});

After that, we set pin 23 of the Raspberry Pi (on which the PowerSwitch is
connected) as an output:

gpio.setup(23, gpio.DIR_OUT);

Then, we check what are the incoming messages from the online dashboard.
If it’s a ‘on’ message, we set pin 23 to 1, which will activate the lamp
connected to the PowerSwitch. If we receive the off message, it will set the
pin to 0:

if (value == 'on') {
gpio.write(23, true, function(err) {
if (err) throw err;
console.log('Written to pin');
});
}

if (value == 'off') {
gpio.write(23, false, function(err) {
if (err) throw err;
console.log('Written to pin');
});
}
Note that the complete code is also available inside the GitHub repository of
the book:

https://github.com/openhomeautomation/iot-raspberry-pi-book

It’s now time to test the project. Make sure you put the app.js file in a folder
on your Raspberry Pi, and then go to this folder via a terminal. Then, simply
type:

sudo npm install mqtt pi-gpio

And after that launch the app with:

sudo node app.js

You can now go back to the dashboard you created before. Test the project by
clicking on the button to turn the lamp on:
You should see that the lamp is turning on immediately. You will also see
some feedback coming from the Raspberry Pi, as the status of the lamp will
be set to “on” inside the dashboard. You can now access this dashboard from
anywhere in the world and control your lamp.

2.5 How to Go Further


Let’s first summarise what we did in this project. We connect a component
called the PowerSwitch Tail to the Raspberry Pi, so we can control most
electrical devices. Then, we created an online dashboard, and connected the
Pi to this dashboard via the MQTT protocol. This allowed us to control an
electrical device from anywhere in the world.

You can of course have several of these modules in different places, and
control them all from a single interface. It’s then easy to control a whole
lighting system in a home from a remote location. You can also mix this
project with sensors, that you can also monitor from the dashboard we
created in this chapter.
Chapter 3
Making a Cloud Security Camera
In this chapter we will use the Raspberry Pi camera module and stream the
video so it can be accessed anywhere in the world. This will transform your
Raspberry Pi in a customizable video surveillance camera that you can place
anywhere you want.

To do that, we will first connect the Raspberry Pi camera module to your Pi,
and then test if it works correctly. After that, we will configure the Raspberry
Pi so it streams the video continuously on a web page. Finally, we will see
how to access this video stream from anywhere.

3.1 Hardware & Software


Requirements
Apart from the Raspberry Pi itself, the most important component of this
chapter will be the Raspberry Pi camera. This module is specifically made for
the Raspberry Pi module, and is really easy to use. This camera can take
pictures at a resolution up to 2592x1944, and can take videos in full HD
format.

This is a close-up view of the Raspberry Pi camera module:


This is the list of the components you will need for this project:

Raspberry Pi (https://www.adafruit.com/product/2358)
Raspberry Pi camera module
(https://www.adafruit.com/products/1367)
USB WiFi dongle (https://www.adafruit.com/product/1012)

In order to enable the camera, you need to open the config tool from a
terminal:

sudo raspi-config

3.2 Hardware Configuration


The hardware configuration is really simple: you just need to plug the camera
in your Pi, using the connector available on the Raspberry Pi itself.

This is a close-up of the final result:

3.3 Testing the Camera


We are now going to test the camera. Again this is really easy to do. Just type
this in a terminal:

raspistill -o cam.jpg

The camera LED should turn red, which means it is active and currently
taking a picture. Then, simply check the image that was created by the
command.
3.4 Local Video Streaming
We will now stream video locally using the mjpg-streamer module. This
module is really great for video stream, as it will create a nice web page from
which you can access the video stream.

However, the module is not available for the Raspberry Pi camera in the
official repository. But luckily for us, a developer made a version available for
the Raspberry Pi camera, and we are going to install it now. You can find all
the details at:

https://github.com/jacksonliam/mjpg-streamer

First type the following command in a terminal from your Pi:

git clone https://github.com/jacksonliam/mjpg-streamer

Then type this command to install required modules:

sudo apt-get install cmake libjpeg62-dev

After that, type this command to build the mjpg-streamer package:

sudo make clean all

And then type this command:

export LD_LIBRARY_PATH=.

And finally type this command to start the streaming:

./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"


You will see that a lot of text will be printed inside the terminal, which means
the streaming is active. Then, go to this URL from a computer:

http://rpi_ip_address:8080

This is the web page you should get:

Simply go on ‘Stream’ in the menu, and you should see live streaming from
your Pi!
3.5 Cloud Video Streaming
That’s good, but we are not there yet. We now want to make this page
accessible from anywhere in the world, so you can monitor your video stream
from any web browser just by having an URL.

To do that, we are going to use ngrok, which is a simple utility that takes a
local web server (here, the streaming server we accessed before) and makes it
available on the web. You can download it from:

https://ngrok.com/

Then, simply put it inside a folder on your Pi, and make sure streaming is still
active. Then, go to this folder and type the following command:

./ngrok 8080

This will basically tell ngrok to take the server running on port 8080 (our
mjpg-streamer app) and make it available on the web. You will be taken to
the following inside the terminal:

See the “Forwarding” URL? This is the address on which your streaming web
page is available now. Then, just copy this URL in a browser. You should see
your stream just as before:
Of course, you are probably seeing this from your computer, but note that this
can be done from anywhere in the world!

3.6 How to Go Further


In this chapter, we built a basic surveillance camera using the Raspberry Pi
camera module and some open-source software.
You can now of course add more Raspberry Pi modules in the game, to make
a whole surveillance system! From the mjpg-streamer module it is easy to get
a piece of code that can be embedded in another web page. From that, it is
easy to build a page where you have the pictures from all your camera
modules, and monitor them from anywhere in the world!
Chapter 4
Conclusion
Let’s first summarize what we learned in this book. We built several Internet
of Things projects using the Raspberry Pi.

First, we built a cloud data logger project, that allowed us to monitor data
coming from your Pi, from anywhere in the world.

Then, we built a project to control a lamp, or any electrical appliance, from


anywhere in the world using the MQTT protocol.

Finally, we built a DIY version of a video security camera, that can stream
video and can be accessed from any web browser.

4.1 How to Go Further


I hope you enjoyed reading this book and I also hope you learned a lot by
doing so. There are of course many things you can do right now to build
Internet of Things projects based on what we saw in this book.

You can add more sensors to your projects, and put your projects around
your home to monitor data from anywhere in the world. You can also
perfectly mix what you learned in the different projects of this book, for
example to have a project that logs data in the cloud & stream live video at
the same time. Thanks to the power of the Raspberry Pi, this is perfectly
possible.
Using the Raspberry Pi 2, you can also exploit the computing power of the
board to do amazing applications, like live a face detection application that
you could monitor from anywhere.

You can also use what you learned about Node.js to interface your projects
with web APIs, like Twitter. I also recommend checking out the Temboo
(https://temboo.com/) website, that makes it really easy to interface your
projects to web APIs. Really, the only limit is your imagination, so
experiment, and have fun!
Chapter 5
Resources
The following is a list of the best resources concerning Internet of Things
with the Raspberry Pi. I organized this chapter in different categories so it is
easier for you to find the information you need.

5.1 General Information About


the Raspberry Pi
Open Home Automation (http://www.openhomeautomation.net/): The
companion website of this book, where you will find many more
projects using Raspberry Pi & open-source hardware to build Internet
of Things projects.
Raspberry Pi Foundation (http://www.raspberrypi.org/): The official
website of the Raspberry Pi, packed with lots of additional resources
and tutorials.
Adafruit Learning System (https://learn.adafruit.com): An online
learning platform with a selection of high-quality step-by-step articles
on making things in general. Many projects use the Raspberry Pi, and
some are about the Internet of Things.

5.2 Components
SparkFun (https://www.sparkfun.com/): A website selling many
components that can be interfaced with the Raspberry Pi. All their
products are open-source and you can download the source files
directly from their product descriptions.
Adafruit (http://www.adafruit.com/): A company based in New York
that sells high quality products for the Raspberry Pi platform.
SeeedStudio (http://www.seeedstudio.com/): A Chinese company that
sells many original products for the Raspberry Pi platform. They also
offer their own PCB production & assembly services.

5.3 Suggested Reading


Raspberry Pi Cookbook (http://amzn.to/1E3f3Jy): An excellent in-
depth book about how to use the Raspberry Pi. Perfect if you never
used the Raspberry Pi before.
Raspberry Pi with Java: Programming the IoT
(http://amzn.to/1HbeHFt): Another book on the theme of the Internet
of Things with the Raspberry Pi.

You might also like