Open access peer-reviewed chapter - ONLINE FIRST

Smart Home Monitoring System Using ESP32 Microcontrollers

By Marek Babiuch and Jiri Postulka

Submitted: October 6th 2020Reviewed: October 22nd 2020Published: November 11th 2020

DOI: 10.5772/intechopen.94589

Downloaded: 33

Abstract

This chapter deals with the implementation of our own monitoring system with home security. The system is designed using IoT modules and uses ESP32 microcontrollers. The chapter describes the design of the system, its hardware components, software implementation, security solutions, communication, the collecting and monitoring of processed data, as well as the quantification of costs for the production and deployment of this system. The proposed system secures a house by detecting an intruder in the building, triggering an alarm and capturing it all with camera images, and then sending data to the owner’s smart mobile phone. The secondary task of the system is to collect data from sensors for monitoring the temperature of an object and presenting it via a web server.

Keywords

  • ESP32
  • microcontroller
  • MQTT
  • IoT
  • monitoring systems

1. Introduction

The main idea was to use the ESP32 chip, which we have installed with a camera module to monitor a house, as well as to monitor the temperature of individual rooms such as the corridor and boiler room. The proposed system contains PIR sensors and temperature sensors in the monitored rooms and connected camera modules to the ESP32 microcontroller. The data collected from the sensors is sent wirelessly to the control unit, which is the Raspberry PI Zero. The other created HW modules are an input panel with a touch screen and input panel with an ESP32 Wroom board and a membrane keyboard. It is used to unlock and lock the house to activate the motion sensor and cameras. The control unit is extended using the GSM module IoT-GA5-B. It ensures the sending of messages to the mobile phone of the homeowner, which inform him/her about the security status of the house. Other HW modules are touch screens showing the current status and temperature in the rooms and control LEDs, recording the status of the entire system. The main aspects of the whole system are the following:

  • Motion detection using PIR sensors

  • The capturing of a camera image

  • The monitoring of the physical quantities of the household such as temperature, humidity, the possibility of extension to other monitored physical quantities

  • The storage and monitoring of measured data

  • Access to data via a web server

  • Responsive applications for mobile devices

  • Wireless communication, MQTT communication, System security

  • GSM communication with the system (at the request of the owner)

In the individual chapters of this article, we will gradually describe the selection of hardware components, the software implementation of the entire system, the design of system security, the installation and testing of the monitoring system and the financial aspects of implementation with the possibility of expansion.

2. Background and related works

Shortly after its introduction, the ESP32 microcontroller became fully integrated into industrial automation, mainly into the deployment of embedded systems and various IoT tasks. Its great advantage is undoubtedly its price, circuit structure, the possibility of connecting peripherals and IoT modules and other sensors, as well as having excellent support for creating applications. The ESP32 chip is well implemented as a web server, using wireless Wi-Fi communication, Bluetooth and mostly the MQTT communication standard at the level of exchanging messages with the surroundings. It often works with another suitable microcomputer such as the Raspberry Pi. In [1] we have described in detail the creation of an architecture for an embedded system based on the ESP32 chip and the processing of a monitoring task using Dual-core for its operation, while one core takes care of obtaining and processing data from the sensors, the other core solves communication issues with the surrounding devices. The suitability of using multiple cores is also discussed [2] in the field of deployment of ESP32 in the field of machine learning and neural networks. Currently, ESP32 is implemented in a wide range of IoT industries and applications in the areas are listed in this chapter with a specific example of use.

The ESP32 chip is suitable for implementation in applications of various monitoring and security tasks. The common element of the implemented applications is its high-quality, low-cost solution in multiple areas, such as the Solar Water Pumping System in agriculture [3] or various types of monitoring systems in farming [4, 5]. Other suitable deployments can also be found in the field of monitoring air quality systems [6], monitoring LPG leakage [7] or waste management systems [8]. Article [9] describes the use of ESP32 as a web server for a real-time photovoltaic monitoring system. With the help of other suitable peripherals such as a camera, linear actuators and drivers, we can use ESP32 to implement a position control system [10] or a Smart surveillance system [11]. The ESP32 microcontroller is also used to perform Device-Free Passive (DfP) tasks such as detection, localization and the tracking of human entities [12], or utilized using GPS as an indoor positioning system [13] or security system [14]. SCADA systems have also begun to focus on IoT in recent years [15]. SCADA architectures have evolved over the years from monolithic (stand-alone) through distributed and networked architectures to the latest Internet of Things (IoT) architecture. Article [16] presents the design and implementation of the Open Source SCADA system by using a local server IoT platform as Master Terminal Units for handling data processing and human-machine interactions and an ESP32 micro-controller as the Remote Terminal Unit for receiving, processing and sending the remote data from the field instrumentation devices. Article [17] describes the design of a Smart home IoT system and notes the trade-off between scalability, security and data collection efficiency for the Internet-of-Things sensor networks. The article [18] discusses security risks in detail and states that IoT systems carry risks in terms of security and privacy. Without eliminating these risks, the IoT requirements are not adequately fulfilled. The article describes the vulnerability of the IoT system at individual layers of the network system and proposes a solution in the form of a security model. Article [19] presents an environment monitoring system based on ESP32 together with a wireless sensor network. The result is not only its low cost but also its low power system, which is today a sought-after benefit when deploying a monitoring system. An integral part of IoT today is the area of iHealth and health monitoring using smart embedded systems. This area is evidenced by the use of ESP32 for monitoring heart rate [20], an image recognition system for blind people in article [21], or a smart saline monitoring system in intravenous therapy [22]. Article [23] describes the possibilities of implementing a control system with the help of human gestures on wearable devices. ESP32 chips are implemented not only in iHealth monitoring systems, but now smart systems are also being developed for the comfort and convenience of mental health and well-being. The article [24] documents a case study of the creation of an intelligent lighting system according to the detection of human emotions. It uses, among other things, necessary hardware components, the predecessor of the ESP32 chip, namely ESP8266, and the already mentioned MQTT communication standard, which is the most common communication standard. It is possible to use the encrypted MQTTs protocol with SSL/TLS certificates to secure MQTT communication, as described [25]. Other security features of communication such as the Algorithm of Advanced Encryption Standard (AES), implemented on ESP32 with a LoRa module to secure wireless communication are described in [26]. Lora communication techniques and the used Zigbee communication standard in the field of home automation are dealt with in [27, 28]. IoT architecture, in general, is described with its requirements and paradigms in [29] and the integration of IoT and cloud computing in terms of the configuration of embedded systems is described in a research article [30]. In the field of embedded systems and monitoring, ESP32 development variants with touch screens can be used, either integrated into the ESP32 Wrover board or connected externally [31]. A comparative analysis of ESP32 and other modules with the ESP32 recommendation for the IoT area is discussed [32]. We agree with his conclusions, as the authors express the idea that the microcontroller operating system FreeRTOS is open source software providing great support for real-time applications. Thus, it is expected that ESP32 will play a major role in the design of future IoT systems and embedded projects. The performance evaluation mentioned in the article [33] - Enabling ESP32-based IoT Applications in Building Automation Systems confirms the suitability of using ESP32 in low-cost applications with an industrial-grade performance. The results of this article are essential for developing cheap but nevertheless reliable industrial solutions based on SoC.

3. Hardware modules

The system will therefore include the Raspberry Pi as a control unit. The set will also include three camera modules equipped with a PIR and a temperature sensor. The ESP32 equipped with a display and a membrane keypad for entering the boiler room and a touch screen also controlled by the ESP32 at the main entrance will be used to lock the house. The set also includes one ESP32 microprocessor equipped with two temperature sensors, the same as the camera module, so we will not describe this device in the next chapter. Some basic components are shown in Figure 1.

Figure 1.

Some hardware components.

3.1 Input panel with membrane keyboard

The system contains the following elements:

  • ESP-WROOM-32

ESP-WROOM-32 belongs among Microcontroller units (MCU), which are fundamentally computer board platforms with CPU, memory, busses and built-in peripherals indispensable to read connected sensors or drive actuators [34].

  • Monochrome character 16x2 (16 characters per line and 2 lines)

The LCD display is connected via a I2C bus. It is a serial bus that divides the connected device into a master or slave category. One wire is used to transmit the clock signal (SCL - synchronous clock) and is the data channel (SDA - synchronous data).

  • Matrix membrane 4x4 keyboard for single-board computers

The keyboard contains characters (1 ÷ 9, A ÷ D and special characters # and *), and these are connected to 8 pins. The buttons in the individual rows and columns are always connected to a common wire. After pressing the button, the row and the column are always connected at a given point. The manufacturer guarantees a service life of 100 million presses.

  • Alarm

The last component in this set is an alarm whose operating voltage is in the range of 3-24 V and intensity 95 dB. Its function is to trigger a loud tone in the event of an intruder entering the house, which should alert you that there is an intrusion in your home.

3.2 Input panel with touch screen

The main input will be the same ESP32 model as the previous set. As for the display unit, a 2.8” USART touch screen from NEXTION will be used. The most significant advantage of these displays is the graphic editor, in which you can quickly and without problems define the graphical and touch environment and perform simulations. This editor saves a lot of time when developing applications. The resolution of this display is 320x240 together with 65 thousand colors, and adjustable brightness will make the perfect choice for all kinds of applications. The biggest advantage is the communication via USART, through which the created graphical environment can be uploaded directly to the display, in which a 4 MB flash memory is integrated. The second variant is using a micro SD card, for which this display has a slot. The USART interface is also used to communicate with the microprocessor, through which it receives variables and sends a click response to the element. Any other display can be used to implement the system. Our goal was not to reduce the price of components to the lowest level but to develop a monitoring system in a comfortable, user-friendly environment, so we chose this display [35]. Custom-made input panels and boards with the help of a 3D printer are shown in Figure 2.

Figure 2.

Input board in boiler room.

3.3 Camera modules

The composition contains the following elements:

  • Ai-Thinker ESP32-CAM. Again, this is a Wi-Fi + BT MCU module, expanded by 520 KB SRAM, including external 4MPSRAM. It also supports OV2640 and OV7670 cameras and SD cards. ESP32-CAM can be widely used in various IoT applications. It is suitable for home intelligent devices, industrial wireless control, wireless monitoring and other IoT applications.

  • RGB LED module. It is a type of RGB LED with a common anode, i.e. the individual ledges are switched by connecting to the ground. Its function will be to give information about the current status of the camera module (whether it is connected to a Wi-Fi network, or whether there was an error loading the camera or other error messages) indications in different colors.

  • Temperature sensor DALLAS DS18B20, This sensor allows you to measure the temperature in a range of −55 to +125 degrees Celsius, while in the range of −10 to +85 degrees Celsius it has a guaranteed accuracy of ±0.5° C. It is available in a TO-92 package, which is similar in size to ordinary transistors, it is also available in a waterproof variant, where the sensor is sealed in a stainless steel stick. OneWire bus is used for communication, which uses only one communication pin. This sensor also supports the so-called parasitic mode, where only two wires are needed to connect the sensor to the microcontroller.

  • PIR module: There are many variants of motion sensors designed for applications similar to this one. Again, we chose from two variants. The first of them is called HC - SR501, whose supply voltage is in the range of 4.5 to 20 V and the output logic is 0 / 3.3 V. The size of the sensor is 32x24mm, so it is a larger sensor but allows you to set the sensitivity of the sensor and timing using two potentiometers. Also, its detection distance is more than sufficient; the manufacturer states a distance of up to 7 meters with a sensing angle of 120°.The second variant is a smaller module called AM312. The operating voltage is in the range of 2.7 to 12 V, while the output logic is the same as for the previous module. The dimensions of the plate are only 10x8mm. However, the detection distance is also smaller, approximately in the range of 3–5 m at a scanning angle of 110°. Figure 3 shows the mounted camera modules in the individual rooms.

Figure 3.

ESP32 camera modules in the corridors and living room.

3.4 Control unit

Even though the Raspberry Pi is already running with the fourth generation of the development board, the economical Pi Zero variant is sufficient for our system. Also, Zero W has built-in Wi-Fi and Bluetooth. Zero is built with a single-core ARMv6 processor clocked at 1 GHz. It also has 512 MB of RAM, audiovisual output via Mini-HDMI, a classic micro-USB 2.0 connector and power supply via micro-USB. It also has a 40-pin GPIO interface. The control unit is then further expanded by a GSM module called IOT-GA6-B. It is an ideal solution for IoT devices that communicate via a serial line at the TTL level, and it supports voice calls, SMS, GPRS data transfer and standard AT commands. Of course, it would be possible to connect this module to the ESP32 microprocessor. Since it would be necessary to forward all messages from the control unit to the input panel and then to the terminal, this implementation would still be too complicated. For this reason, we decided to omit one intermediary and connect the device directly to the control unit. The architecture of our IoT system is therefore centralized, for our smart system, the central point is the control unit, which is also an MQTT broker that communicates with ESP32 modules and input panels. The conditions under which it would be appropriate to decentralize the IoT system describes [36], among other things, a detailed comparison of the decentralized IoT architecture approach with different approaches.

4. Application software

This chapter describes the individual services that have been used in this system. There are also descriptions of source code fragments that are uploaded to individual devices. Thanks to this outline, it is possible to understand better the way the whole assembly works. Figure 4 shows the resulting software application, which is described in this subchapter.

Figure 4.

Measuring and monitoring application.

The operating system is the latest version of Raspbian called Buster and runs on Debian Linux version 4.16. It is an operating system designed directly by the manufacturer of this board, thanks to which the reliability and stability of this system should be guaranteed.

The Raspberry Pi runs:

  • MQTT Server - Service for communication with microcontrollers

  • Apache 2 - Web server

  • MariaDB - SQL database for measured values.

  • Python Scripts - Covers all logic in communication with microcontrollers, as well as storing the data in a database.

4.1 Communication

All communication takes place wirelessly via Wi-Fi. The protocol by which individual devices communicate is MQTT. MQTT (formerly: Message Queuing Telemetry Transport, today MQ Telemetry Transport) is a simple and undemanding protocol for transmitting messages between clients via a central point - a broker. Thanks to this simplicity, it is easy to implement it even in embedded devices and it is spread relatively quickly. For the MQTT protocol, the transmission is performed using TCP and uses the publisher-subscriber design pattern. So there is one central point (the MQTT broker) that takes care of exchanging messages. In our case, the broker will be Raspberry Pi. Figure 5 shows a block diagram of MQTT Communication. Messages are sorted into so-called topics, and the device either publishes in the given topic (publish), i.e. it sends data to a broker, which stores and distributes them to other devices, or is subscribed to a topic or more topics (subscribe). The broker then sends all messages with the given topic to the device. Of course, one device can be a publisher in some topics and at the same time a subscriber in others.

Figure 5.

MQTT communication.

4.2 Input panel

Its purpose will be to lock a house by pressing a key, as well as to unlock it by entering a 4-digit numeric code. At the same time, it serves as an element to alert the intruder via an alarm. In the source code, we have programmed macros that allow you to define how many times it is possible to enter a pin when the house is locked, the time delay of attempts, the default display of data on the screen, reading keystrokes and communicating using the MQTT protocol. Furthermore, in the source code, which we will not mention here, we perform Wi-Fi configurations and check whether a connection to Wi-Fi has taken place, followed by repeated attempts, LED signaling and the reconfiguration of the device. Another functionality programmed in the input panel is the function for setting the MQTT client, which defines the address of the broker, the communication port and instructions with the settings for receiving messages from the broker. The main loop of the program first calls a function that verifies if the ESP is still connected to the Wi-Fi network, and if not, it tries to connect it several times. If this still does not work, the device will restart. Subsequently, a function is called that verifies the connection to the MQTT broker and, if connected, reads incoming messages from the broker. Incoming messages include the status of whether the house is locked, in which case this fact is shown on the display, and if the locked state detects an intruder from one of the camera modules, then an alarm is triggered in the form of a passive speaker, which emits a constant tone of a specific frequency. Other functions that needed to be solved included verifying key presses at a certain time interval, resolving the display backlight when entering data, verifying an incorrectly entered Pin code and then blocking further attempts for a certain time interval, as well as sending a message when trying to crack a password. The module then further solves the verification logic of the house locking status and the communication with the control unit. The PIN code is stored in a database located on the control unit. The control unit transmits the house status and the current PIN code via secure communication.

4.3 Camera module

Its primary goal is to record movement in a specific area if the module has been activated in advance. Motion is recorded using a PIR sensor, and then photos are captured at one-second intervals while the PIR sensor detects movement. The secondary goal is to monitor the temperature and send this data to the control unit. The source code in Figure 6 contains macros that allow you to configure how long the delay between each captured image is, as well as the delay between recording the temperature. Other macros are used to define the pins to which the PIR module and the temperature sensor are connected, as well as the accuracy with which the value on the sensor is measured. Furthermore, RGB LED cathodes are defined here. In terms of software, this module solves a total of 6 libraries, which ensure the sending of the captured image of the server, the loading of the camera, connection to the Wi-Fi network, communication using the MQTT protocol and connection and work with the temperature sensor.

Figure 6.

Including the libraries and macro definitions.

The software of this module implements functions for verifying the connection to the Wi-Fi network and checking the connection to the MQTT broker. This code fragment is shown in Figure 7. Other functions are checking the measuring interval, processing the measured values and sending it to the broker. Another check finds out if the broker received the message about a locked house. If this happens, then the movement in the area is checked by reading the value from the PIR sensor. If the movement has been detected, a house intrusion report is sent to the broker. At the same time, it is checked whether the time required to take another screenshot has elapsed since the last loop. If so, a function is called to take a picture using the connected camera. This image is then sent and then saved in the directory.

Figure 7.

Fragment of the source code of the ESP32 camera module.

4.4 Control unit

The purposes of this unit are as follows: To mediate communication using the MQTT protocol, to store incoming data in a database and to enable access to them, and also to provide an HMI interface. We use the MariaDB database to store data, which is a relational database that is community developed by the successor branch of MySQL.4 users with different rights to use the database. This is mainly to ensure that we secure access to information as much as possible. The primary user is the Administrator with rights related to the esp_db database, in which all tables are stored, telephone numbers, measured values, captured photographs and the individual states of closing and opening the house. Users are also WRITE, who can write into the individual TABLEs and users READ who can only read data.

The telephone numbers and names of the users to whom these telephone numbers belong are stored in the DB Phones table. The other two columns of this table indicate the rights of individual telephone numbers, one column indicates the right to unlock or lock the house via SMS, while the other column indicates the manipulation of the gateway. The last is LOGIN, which stores a 4-digit PIN to unlock the house.

As already mentioned, Raspberry runs a web server, which is mediated by the Apache 2 service. This service runs several PHP scripts supplemented by an HTML structure. JavaScript then takes care of the dynamics of the pages together with a jQuery. Everything is unified in design and formatted using a CSS style.

The application screen on the webserver is divided into three parts. The first is the option to log in by entering the PIN code. After a successful login, the house can be unlocked or locked remotely. We see this directly in the application on the mobile device in Figure 8.

Figure 8.

Web server – Application on a mobile device.

In the next section, there is a HighCharts graph, which clearly shows the course of temperatures over time measured on individual devices. In the chart, it is possible to select a specific device from which we want to see the course of temperatures. It is also possible to choose which time range we want to display the temperature. There are also additional options in which graphs can be exported either to an image or, for example, to an Excel worksheet or similar files. In the last section called the Cameras picture, we will find all captured photos from all connected camera devices that are connected to the set. These images are sorted according to the date that is displayed for each photo and are assigned a serial number for greater clarity. The site can be switched according to the language preference to the local environment, if necessary. This site has also been customized for mobile devices such as smartphones. We assume that these sites will mainly use these devices.

4.5 Python scripts

These scripts mediate communication for the MQTT protocol, as well as for storing data in a database and communication with the GSM module. There are three python files on Raspberry, one of which acts as an MQTT client. It listens to everything that is sent to the broker and performs a specific action based on the incoming message. The second python script contains functions that allow access to the database. The third communicates via a serial line with the GSM module and mediates communication with the end-user.

The Python script contains functions that are used to retrieve values from the database, such as the current state of the house (locked/unlocked). Another function is used to write values into tables with temperatures that come as a message from the camera modules via the MQTT protocol.

The first one, on_message, is called when the MQTT broker sends a message. An example of this code is shown in Figure 9. In this function, the message is then filtered using a topic, where we are interested in what the name of the message is. In the case of a topic called Refresh, we know that a new device has just joined the communication and is requesting an update of the data. Therefore, a message is sent to this command, which calls a function that reads the current pin code and house status from the database. It sends these messages after an encrypted communication.

Figure 9.

Fragment of python script for MQTT communication.

The second function then takes care of changing the state of the house (unlocking/locking). If it occurs, the message will be retransmitted after 5 seconds to make it 100% certain that all connected devices will receive the message. At the same frequency, messages are also sent about the state of the intruder (i.e. if one of the camera devices detected movement), if the house is in a locked state.

The script that mediates communication with the GSM module first sets up this module. It then goes into an endless loop in which it checks to see if an intruder has entered the house. If so, then an SMS message is sent to all telephone numbers that are registered in the database. If a telephone number is dialed, the number is first verified whether it is written in the database and has the appropriate rights to open the gateway. Then there is contact on the relay module, which is connected to the Raspberry Pi, it closes and thus the gate opens. We added this function at the request of the owner of the house on which the system is installed. By sending an SMS “lock” or “unlock” it is possible to manipulate the security system of the house. An example of this code is shown in Figure 10. Of course, when sending an SMS, we first check whether the number from which the SMS was sent is registered in the database together with the appropriate permissions. Subsequently, an SMS message is sent to this telephone number. This message contains the current time, the status of the house (unlocked/locked), the last measured temperatures from all sensors and, last but not least, the remaining credit on the SIM card (so that the user knows when it is necessary to recharge the mobile credit). At the request of the owner, a function has been added that controls the boiler temperatures, which are sent from one of the modules. The owner is informed by an SMS message when a limit of 80° C is exceeded.

Figure 10.

Fragment of python script with GSM module communication.

5. System security measures

The proposed system must, of course, comply with safety principles. As these are a number of interconnected technologies, there are several recommendations for security measures, from completely common to complex solutions. The system uses a number of hardware modules, communication elements, a web server, a database, configurable access to the control unit, an input pin to unlock the system and all this must be secured. The basic safety recommendation is to separate the wireless network for the IoT modules of our system from the wireless network of the house in which we use PCs, laptops and other common devices. This can be done either by the total separation and operation of two separate networks or by different variants of VLAN and micro segmentation of the network, depending on the available hardware of the specific solution. In our case, it is a completely separate network.

Another important element is the principle of preventive protection of the Raspberry Pi control unit, securing SSH remote access, compliance with security principles and best practices for MariaDB database such as Avoiding running mysqldas root, Limit ssh access, Limit sudo access on the MariaDB and the use of security plugins [37]. The limitation of the number of attempts to enter the input Pin on the instrument panel is solved by the possibility of configuring the selected time delay after the unsuccessful entry of 3 consecutive attempts, including sending a notification to a mobile phone to pre-selected phone numbers.

Last but not least, securing the communication of the MQTT protocol is also important, as this protocol was not originally designed for security, but for its availability and undemanding implementation. We can apply the security of this communication in implementations of later Mosquitto brokers. This is done using authentication and authorization mechanisms that allow you to add plugins. This is done using authentication and authorization mechanisms that allow you to add plugins. This is a client authentication using a client IDs, Access Control List or x509 Clients certificates. To protect the contents of your MQTT messages you can use TLS or SSL Security and Payload Encryption.

6. Installation and testing of security system

To be able to implement the device into operation and place it in the house, these devices must have mechanical protection and at the same time, allow the most convenient possible installation. For this reason, we decided to produce cases for camera modules and input panels with a keyboard and touch screen on a 3D printer.

It is necessary to insert ESP32, an LCD, a keyboard, a speaker and DC-DC voltage converter in the input panel, which will reduce the distribution voltage of 24 V DC to the required 5 V DC. The housing is designed for wall mounting around the front door, with a height suitable for the user. The camera module contains the following elements: ESP32-CAM, temperature sensor, a PIR sensor, a RGB LED, IR LED, a NPN transistor, a constant current source, a DC-DC converter and an antenna for Wi-Fi. We designed the housing so that the camera can be mounted in the corner of the room so that it blends in with the surrounding walls as much as possible and does not disturb the integrity of the room in any way. The camera is placed in a rotating sphere to be set in which area of the room we want to record. After the implementation of hardware modules, the 3D printing of assembly boxes and the mounting and software implementation of the entire system, the testing and installation phase took place, first in the laboratory and after verification of the functionality of all modules assembly into a residential house. Figure 11 shows the testing of the input panel, the touch screen, one camera module and the display of monitoring temperatures and captured photos on the webserver in individual modes simulating a closed and unlocked house. This test also related to testing the alarm and sending messages by the GSM module to pre-selected telephone numbers.

Figure 11.

Testing of hardware modules and software functionality.

We installed three camera modules and two input panels in the house, one with a touch screen and the other with a membrane keyboard for more comfortable handling in a dusty room, with one module for collecting temperatures in the boiler room and directly from the boiler and one Raspberry Pi Zero W control unit.

All components of the device are powered from a 12 V source with direct voltage so that even on long routes, the voltage of individual devices is at least 5 V. Figure 12 shows one of the three camera modules that has just been activated and signals its initialization with the color green. You can see the input panels in figures in the Hardware Modules chapter. On the left, we can see a panel with a membrane keyboard, which is located in the boiler room, and the other is located at the main entrance. Raspberry Pi Zero W is located in the distribution board, together with a GSM modem and a relay module. The individual devices were tested of course, after connecting all the modules, some parts of the code were fine-tuned to ensure the greatest possible comfort of use and reliability.

Figure 12.

Installation of the ESP32 cam module in the living room.

7. Price of the created monitoring system

The price of the created monitoring system is around 250 euros, when, of course, we add up only all the purchased hardware modules. The price of the 3D printing of the designed boxes is negligible. We did not include the price of our own development work and software implementations in the price of the system. The advantage of the whole system is that when it is extended by other measuring IoT modules in the current configuration, the final price increases only by a few Euros, when increasing the number of existing measuring units, the final price increases in the price of a particular module, whether it is another ESP32 module equipped with a camera and sensors or input or display units, the price of which is given in the table. The price of the resulting device could be reduced, but our goal was not to choose the cheapest components. In the production of more pieces of the monitoring system and with the quantity discount of selected components, we would get even lower prices. Prices in the Table 1 are given according to the European local market, it is possible to get lower prices elsewhere.

DeviceItemPrice in Euro
Control unitRpi Zero12
SD card10
GSM Modem8
Relay module2
DC – DC converter4
RTC real time module2
1 pieceTotal38
Camera moduleESP32 – CAM14
Temperature sensor1,9
PIR sensor2,3
DC – DC converter1,5
RGB LED0,6
Resistances 1k𝛀, 4k7𝛀0,4
3 piecesTotal (rounded)62
Input panel with Touch displayESP328
Touch display25
DC – DC converter2
1 pieceTotal35
Input panelESP328
Keyboard1,5
LCD Char Display4,5
Alarm3
DC – DC converter2
1 pieceTotal19
Measurement deviceESP328
Temperature sensor2
Outdoor temperature sensor4
DC – DC converter2
1 pieceTotal16
Power supplyPower supply30
Electrical wiringHouse wiring, cables, LED indicators30
Total price230 Euro

Table 1.

Price of components.

8. Conclusion

We designed a camera system with an ESP32 chip, which was installed on a house; the system is connected to its Wi-Fi network. The set was extended using input panels at the main entrance and the entrance to the boiler room. It was necessary to create a parent device that would serve as a data store and control for the entire report. This was done using a Raspberry Pi, whose function is to pass communication to all other elements in the assembly. At the same time, it serves as a repository of photographs captured from camera modules and a web server is running on it, which allows access to data on this unit.

In an idle state, the camera modules are inactive (they do not take camera pictures). However, if the house is locked, which can be done by using two input panels or using a web server or by sending an SMS command, then after a certain time delay, the camera modules will be activated after leaving the house. These check whether motion has been detected on the PIR sensors. If this situation occurs, then this information is sent to the control unit and sent to all camera modules. Immediately afterwards, images are taken from all camera modules with a second interval. An alarm located in one input panel is also activated, and an SMS message is sent from the control unit via a GSM modem to predefined telephone numbers stating that an intrusion into the house has occurred. Images taken from the camera modules are sent via HTTP post to the control unit, where they are stored.

ESP32 modules are also equipped with temperature sensors for monitoring the temperature in the rooms. These temperatures are processed and sent to the control unit, where they are stored in the database. The whole set is further expanded by one device that reads the temperatures in the boiler room and the temperature directly from the boiler. This makes it possible to monitor the dependence between the temperatures of the boiler and in the individual rooms. Thanks to this, a house could be heated more efficiently.

The web server, which also runs on this unit, and ensures easy and clear access to all data that is continuously stored here. The current status of the house and the possibility of locking with it after entering the PIN code is displayed on the webserver. The application displays a graph that clearly plots the temperatures measured on individual devices as a function of time. There is the possibility of filtering a certain device from which the data were measured, as well as the possibility of displaying a certain time interval. The last section of the website is a gallery of photos that were taken on camera modules and are sorted from the most recent, with each photo showing the exact time when it was captured.

A GSM modem is connected to the control unit, which enables the remote manipulation of the house via an SMS message, but only for selected telephone numbers. By sending an “unlock” or “lock” command, this action is performed. Back then, the user is informed about the execution via an SMS message, which contains the current state of the house (unlocked/locked). The last measured temperatures from all connected sensors and the credit balance on the SIM card are also sent. If any other SMS message is sent, again only from selected numbers, the user is sent an SMS with the same content as when sending the order. When the telephone number rings, the relay is connected, which is connected to the gate for entering the property of the house. At present, we are also dealing with taking camera pictures in poor visibility conditions or complete darkness. This problem could be solved by removing the IR filter located on the camera lens and illuminating the room by adding, for example, IR LEDs, the light of which would not attract attention because it is not visible to the human eye.

Acknowledgments

This work was supported by the European Regional Development Fund in the Research Centre of Advanced Mechatronic Systems project, CZ.02.1.01/0.0/0.0/16_019 /0000867 within the Operational Programme Research, Development and Education and the project SP2020/571 Research and Development of Advanced Methods in the Area of Machines and Process Control by the Ministry of Education, Youth and Sports.

Download for free

chapter PDF

© 2020 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Marek Babiuch and Jiri Postulka (November 11th 2020). Smart Home Monitoring System Using ESP32 Microcontrollers [Online First], IntechOpen, DOI: 10.5772/intechopen.94589. Available from:

chapter statistics

33total chapter downloads

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us