Internet of Things (IoT) is currently one of the rapidly expanding uses of embedded processors in smart monitoring and control applications. In this chapter we shall be briefly looking at the principles of the IoT and give the complete design of a simple home IoT system.
The IoT is a new concept in intelligent automation, monitoring, and control. It is the network of home appliances, vehicles, and any other physical devices connected together with sensors, actuators, and displays, which enables these devices to connect and exchange data. It is estimated that in 2017 there were around 9 billion IoT devices in the world and this number is estimated to grow over 30 billion by 2020.
The word “things” in IoT usually refers to devices that have unique identifiers, connected to the Internet to exchange information with each other in real time. Such devices have sensors and/or actuators that can be used to collect data about their environments and to monitor and control these environments as required. The collected data can be processed locally, or alternatively, it can be sent to centralized servers or the cloud for remote storage and processing.
Some IoT home applications include wireless or Internet connected smart appliances that can be turned on and off remotely using, say, a mobile phone or a tablet. For example, a small device can be used to collect data about temperature, humidity, and atmospheric pressure inside the house. This data can then be accessed at any time and from anywhere, provided there is Internet connectivity. Smart refrigerators can keep track of items stored and place orders automatically through the Internet with little or no interaction from their owners. Smart televisions can learn their owners’ watching habits and inform them when a new show is available. Smart home lighting systems can turn on and off automatically and can change light intensities to adapt to the environment. For example, the light intensity can be reduced automatically in the day to save energy. Tea or coffee makers can turn on automatically when the owner wakes up. Smart smoke detectors can raise alarms in a friendly human voice, describing where the fire is and what actions to take. Smart car parks can inform drivers looking for a space to park and inform them the availability of the closest space. Smart roads can send messages to drivers to inform them about the road and weather conditions. Emergency services can use IoT technology to save lives and improve the environment. For example, gas leakage details can be sent automatically to emergency gas service departments to prevent any explosions or deaths. Forest fires can be detected by early warning IoT systems. There are also many applications of the IoT in the retail industry. For example, purchasing habits of customers can be stored by IoT systems which then inform them of special offers and discounts. IoT systems can be used in airports to inform passengers of flight delays before they leave their homes. Flight tickets and hotels can be booked automatically with simple voice commands. Wearable IoT devices can be used to monitor the health of the users, such as the blood pressure, temperature, heart beats, etc. Health centers can automatically be informed of patients’ locations if a serious condition such as a heart attack is detected. There are many more examples of the use of IoT in present day.
There is no standard IoT architecture. An IoT system can make use of any technology to read sensors and send data to users. We can basically define two possible IoT architectures as far as the processor architecture is concerned: distributed processors and common processor.
Fig. 16.1 shows a typical distributed processor based IoT architecture. Here, each IoT device sends its data to local processors using a communication technology, such as Wi-Fi, Bluetooth, or simple RF. The actuators of the IoT devices are also connected to the same processors. These local processors then communicate with a central processor which can, for example, be a PC. The PC can send the data to a cloud so that the IoT devices can be monitored and controlled remotely from anywhere in the world and at any time of the day. Users can access the IoT devices through the Internet using their mobile phones, laptops, or tablets.
There can be several variations of the basic distributed processors architecture. In shared distributed processors architecture shown in Fig. 16.2, a group of IoT devices can share a local processor. This architecture has the advantages that it is simpler and also the cost is less since the local processor count is reduced. The disadvantage of this architecture is that some IoT devices may be located far away from the shared processors and it may not be possible to make direct connections. In this architecture the IoT devices can be connected directly to the local processors with wires and only one wireless communication device can be used.
Fig. 16.3 shows the IoT common processor architecture. Here, all the sensors as well as the actuators are connected to a local common processor using wires. The common processor can then send the collected data to a cloud so that users can access the system from anywhere on Earth and at any time. The users can also access the system locally through the common processor.
This is a simple home IoT project. In this project three Nucleo-F411RE-type development boards are connected to three Bluetooth modules. One of the development boards (node: IoTTemperature) measures the ambient temperature in the living room through a temperature sensor chip. The second development board (node: IoTLight) measures the light level in children’s room and sends messages ON or OFF to informs the user about the light state. The third development board (called node: IoTWindow) is connected to a switch in the kitchen window and it checks whether or not the window is open and it sends messages OPEN or CLOSED to inform the user about the window state. A PC receives information from all three development boards through Bluetooth and displays this information on the screen every 5 s.
The aim of this project is to show how a simple IoT project can be developed using Nucleo-F411RE development boards and Bluetooth modules.
The block diagram of the project is shown Fig. 16.4. The project consists of three development boards, three Bluetooth modules, a temperature sensor chip, a light dependent resistor (LDR), and a switch.
The circuit diagram of the project is shown in Fig. 16.5. Temperature sensor chip TMP102 is connected to I2C port of node IoTTemperature. A LDR is connected to analog input PA_0 of node IoTLight. The LDR resistance is low at daylight and it becomes very high at dark. By measuring the voltage across the LDR we can tell whether the lights are ON or OFF in childrens’ room. A switch mounted on the kitchen window is connected to digital port pin PC_0 of node IoTWindow. Normally the state of this switch is at logic HIGH to indicate that the window is open, and it goes to logic LOW when the window is closed. Bluetooth modules are connected to UART ports of all three development boards so that they can communicate with the PC.
Fig. 16.6 shows the project built using three Nucleo-F411RE development boards.
Fig. 16.7 shows the program PDL of each node.
There are three programs in this project, one for each node. Fig. 16.8 shows the program (program: IoTTemperature) for node IoTTemperature. At the beginning of this program the Bluetooth port is defined where TX is PA_9 and RX is PA_10 respectively. The I2C interface between the development board and the TMP102 temperature sensor chip is defined. As explained in Chapter 11, the program reads the ambient temperature. The temperature is converted into degrees Centigrade and is sent through the Bluetooth module every 15 s using statement bluetooth.printf as a floating point data in the format %5.2f, that is, in the form nn.nn.
Fig. 16.9 shows the program (program: IoTLight) for node IoTLight. At the beginning of this program the Bluetooth port is defined where TX is PA_9 and RX is PA_10, respectively. PA_0 is used as the analog port to read voltage across the LDR. The light level is converted into lux. It is found by experiment that when the room is dark the light level is below 50. Therefore, the message Lights are OFF is displayed if the room is dark, otherwise message Lights are ON is displayed through the Bluetooth module every 15 s.
Fig. 16.10 shows the program (program: IoTWindow) for node IoTWindow. At the beginning of this program the Bluetooth port is defined where TX is PA_9 and RX is PA_10, respectively. PC_0 is used as digital input port to read the state of the window switch. If the switch is at logic HIGH then the message Window is OPEN is displayed, otherwise message Window is CLOSED is displayed through the Bluetooth module every 15 s.
It is necessary to pair the Bluetooth modules with the PC before they can exchange data with the PC. The steps for this are given in the following (these steps are for Window 7.0 operating system, but similar steps should work for other versions of Windows). It is assumed in the following that the Bluetooth modules are attached to all the development boards:
The TeraTerm terminal emulation program is used in this project for the PC. This emulation program has the option that it can connect to the PC Bluetooth ports and receive or send data through these ports. TeraTerm can be downloaded free of charge from several sources on the Internet.
Before using the TeraTerm we have to know the port addresses of the connected Bluetooth devices. These can be found as follows:
Now we can display the data received from the development boards on TeraTerm terminals. The steps are as follows:
You can see all the TeraTerm windows by clicking on Window and then for example clicking Side by Side in any of the TeraTerm windows. Fig. 16.15 shows the three windows displaying the living room temperature, children’s room lighting, and state of the kitchen window.
IoT has become one of the most important topics in the computer industry with an estimated usage of over 9 billion devices by 2017. In this chapter we have learned the following: