This is the chapter web page to support the content in Chapter 12 of the book: Exploring Raspberry Pi – Interfacing to the Real World with Embedded Linux. The summary introduction to the chapter is as follows:

This chapter describes how the Raspberry Pi can be used as a core building block of the Internet of Things (IoT). In this chapter, you are introduced to the concepts of network programming, the IoT, and the connection of sensors to the Internet. Several different communications architectures are described: The first architecture configures the RPi to be a web server that uses various server-side scripting techniques to display sensor data. Next, custom C/C++ code is described that can push sensor data to the Internet and to platform as a service (PaaS) offerings, such as ThingSpeak and the IBM Bluemix IoT service (using MQTT). Finally, a client/server pair for high-speed Transmission Control Protocol (TCP) socket communication is described. The latter part of the chapter introduces some techniques for managing distributed RPi sensors, and physical networking topics: setting the RPi to have a static IP address; and using Power over Ethernet (PoE) with the RPi. By the end of this chapter, you should be able to build your own full-stack IoT devices.

After completing this chapter, you should hopefully be able to do the following:

  • Install and configure a web server on the RPi and use it to display static HTML content.
  • Enhance the web server to send dynamic web content that uses CGI scripts and PHP scripts to interface to RPi sensors.
  • Write the code for a C/C++ client application that can communicate using either HTTP or HTTPS.
  • Interface to platform as a service (PaaS) offerings, such as ThingSpeak and IBM Bluemix IoT, using HTTP and MQTT.
  • Use the Linux cron scheduler to structure workflow on the RPi.
  • Send e-mail messages directly from the RPi and utilize them as a trigger for web services such as IFTTT.
  • Build a C++ client/server application that can communicate at a high speed and a low overhead between any two TCP devices.
  • Manage remote RPi devices, using monitoring software and watchdog code, to ensure that deployed services are robust.
  • Configure the RPi to use Wi-Fi adapters and static IP addresses, and wire the RPi to utilize Power over Ethernet (PoE).


Updates to the Paho Project

The paho project that is described on page 514/515 has moved from to You can follow the steps in the chapter by changing the git URI as follows:

Digital Media Resources

Below are some high-resolution images of the circuits described in the book. They are reproduced in colour and can be printed at high resolution to facilitate you in building the circuits.

The Client/Server Models Described in the Chapter

Heatsinks and the RPi

The IBM Watson Bluemix IoT Example


None for the moment

Recommended Books on the Content in this Chapter