Development of an Affordable Real-Time IoT-Based Surveillance System Using ESP32 and TWILIO API

Development of an Affordable Real-Time IoT-Based Surveillance System Using ESP32 and TWILIO API

Kennedy Okokpujie* Imhade P. Okokpujie Fortune T. Young Roselyn E. Subair

Department of Electrical and Information Engineering, Covenant University, Ota 112101, Ogun State, Nigeria

Africa Centre of Excellence for Innovative & Transformative STEM Education, Lagos State University, Ota 102101, Lagos State, Nigeria

Department of Mechanical and Mechatronics Engineering, Afe Babalola University, Ado Ekiti 360001, Nigeria

Department of Mechanical and Industrial Engineering Technology, University of Johannesburg, Johannesburg 2028, South Africa

University Librarian, Afe Babalola University, Ado-Ekiti 360001, Nigeria

Corresponding Author Email: 
kennedy.okokpujie@covenantuniversity.edu.ng
Page: 
1069-1075
|
DOI: 
https://doi.org/10.18280/ijsse.130609
Received: 
10 July 2023
|
Revised: 
24 August 2023
|
Accepted: 
22 September 2023
|
Available online: 
25 December 2023
| Citation

© 2023 IIETA. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

In a global context increasingly concerned with security challenges, the significance of robust surveillance systems cannot be overstated, especially in regions afflicted by vandalism and crime. Despite the growing adoption of video surveillance technologies, their high cost remains a barrier, particularly in lower-income areas, notably in African cities where surveillance implementation is reportedly minimal. This study introduces a cost-effective, real-time surveillance system, integrating the ESP32 microcontroller with an OV2640 (OV) camera and a Pyroelectric Infrared (PIR) sensor, leveraging Internet of Things (IoT) technology. The system is designed to detect motion, alert users via SMS in the event of an intrusion, and transmit real-time video using the TWILIO Application Programming Interface (API), which facilitates global communication through SMS, voice, and wireless services. Upon deployment and testing, it was observed that the system effectively corresponds the visual images on the Ismart platform with the actual real-time video captured within the coverage area. The motion sensor unit demonstrated reliable functionality. A notable outcome of this implementation is the operational cost, which is assessed to be less than 50% of existing surveillance systems, thereby offering a more affordable alternative without compromising efficiency. The proposed system's efficacy and cost-effectiveness position it as a viable solution for a wide range of applications, including domestic settings, banking institutions, office premises, and airports.

Keywords: 

surveillance system, ESP32-Cam, IoT, video, TWILIO API, real-time, motion detection, Pyroelectric Infrared (PIR) sensor, low cost, Africa

1. Introduction

Security poses a significant challenge globally, with the paramount importance of safety in an era marked by vandalism and criminal activities being universally acknowledged. The deployment of video surveillance systems has witnessed a dramatic upsurge in recent years, playing a pivotal role in enhancing security in both public and private sectors, including applications in traffic monitoring, sign language recognition, and the banking and finance industry, among others [1]. Notwithstanding their widespread use, these systems are not without their drawbacks, which include issues such as unclear imagery, intricate setups, limited stability, high energy consumption, substantial data storage requirements, and notably, their relatively high costs. Traditional surveillance systems predominantly comprised analogue cameras connected via coaxial cables. However, with evolving technology, Closed-Circuit Television (CCTV) systems continue to be a staple in maintaining public order and security [2-5]. In response to cost and performance considerations, a shift towards digital systems has been observed, with current data transmission relying on Internet Protocol (IP) [6, 7].

This research endeavors to develop a cost-effective, real-time security monitoring system, employing the ESP32 microcontroller in conjunction with an OV2640 (OV) Camera. The system is designed to detect motion using a Pyroelectric Infrared (PIR) sensor and to alert users via SMS through a GSM feedback mechanism, facilitated by the Internet of Things (IoT) through the TWILIO API [8-10]. IoT, a network of physical objects interconnected through the World Wide Web, enables devices to communicate, exchange data, and operate autonomously without human intervention. IoT's capabilities extend to real-time analytics, machine learning, and sensory technologies, making it instrumental in various applications, including home monitoring systems and smart home devices [11-14]. In this work, IoT plays a crucial role in enabling real-time, wireless transmission, and streaming of video and SMS data.

The system developed in this study incorporates intelligent features in video surveillance, utilizing digital and wireless technologies. Users can remotely monitor their premises through surveillance cameras, while sensor networks provide enhanced security. The integration of Wi-Fi in these systems facilitates faster data transmission and remote administration from any global location. This innovative, cost-effective real-time IoT surveillance system represents a significant advancement in surveillance technology, offering enhanced capabilities for a variety of settings.

2. Related Works

In the realm of affordable security monitoring, several notable studies have been conducted, as highlighted in the literature. Patel et al. [15] introduces a smart surveillance device, controllable remotely via an Android application named the Pushetta App. Leveraging IoT connectivity, this system dispatches push notifications to mobile phones upon detecting intruders, thus combining low-cost, web-camera-based technology for remote security monitoring.

Similarly, Ahmed et al. [16] presents an economical home security system rooted in IoT technology, facilitating remote management and live video feedback. This system integrates a motion sensor with a camera module to detect intruders, promptly alerting users via the Internet. Additionally, it incorporates a GSM module to send SMS alerts, offering the advantage of global accessibility and affordability through the integration of domestic hardware components.

Jyothi and Vardhan [6] proposes a real-time security monitoring device, employing a Python-based Motion Detection method within the framework of IoT. By integrating this algorithm with the Raspberry Pi 2 and a Pi camera, the device efficiently transmits live images to a remote server, thereby reducing storage requirements and lowering investment costs.

Bhatkule et al. [17] developed a cost-effective and scalable home security system using Raspberry Pi and GSM technology. This system is designed to detect burglary through photographic evidence sent to mobile phones or emails, accompanied by an alarm and the release of deterrents like smoke or gas in response to suspicious activities. Its compact PCB board design enhances its suitability for industrial production and distribution.

Finally, Jayakumar and Muthulakshmi [18] introduces a surveillance system that comprises a Raspberry Pi and a camera, continuously monitoring a designated area. When motion is detected, the system records video, stores it locally and in the cloud, and alerts the user via email with the captured image. It also includes facial recognition technology, maintaining a directory of local suspect faces for real-time identification and tracking.

These studies collectively underscore the advancements in affordable and efficient security monitoring systems, emphasizing the integration of IoT and digital technologies in enhancing surveillance capabilities. Each system offers unique features, from global accessibility and real-time alerts to innovative use of facial recognition, reflecting the diverse approaches in contemporary security technology research.

3. Methodology

This section describes the hardware and software designs of the System. The software connects the various passive components essential to the microcontroller and provides a platform for observing and monitoring the area of interest and action. The software synchronises with the hardware because it analyses the design of the circuit to implement the parameters derived from the theory.

In the related works reviewed the systems despite showing some strength and advancement. However, have various flaws, such as hazy images, complex structures, poor stability, high power consumption, and ample storage space required to retain surveillance data, and prices remain relatively high. Theses are who this cost-effective real-time IoT surveillance system using ESP32 and TWILIO API seek to address. This is an effort to improve upon the limitations of these current system designed presently in the literature.

3.1 System description

Protection is a worldwide challenge, and the System presented provides a low-cost solution and a certain degree of security. As seen in Figure 1, the monitoring system was placed in an environment and powered by a supply unit. The unit is a DC - AC converter in the form of a mobile loader that provides the transmission of 5v DC to the ESP32-Cam and other devices. As seen in Figure 1, the monitoring system was placed in an environment and powered by a supply unit.

Figure 1. Conceptual framework of the system

The unit is a DC - AC converter in the form of a mobile loader that provides the transmission of 5v DC to the ESP32-Cam and other devices. When the motion sensor unit detects motion, it transmits a signal to the ESP32-Cam. The microcontroller interacts with the cloud and informs the user through text messages and records a picture of the person responsible for the motion saves it into the SD card. The user may now watch an intruder on a laptop or smart mobile device from anywhere globally in real-time and take necessary measures. The ESP32-Cam includes a built-in Wi-Fi module for constructing Local Area Network (LAN); however, this is restricted to the building premises and the range of the ESP32-Cam. The microcontroller may also be linked through the software program, which creates the device’s broad area network (WAN), which allows it to cover more significant geographical regions and the whole world. Figure 2 shows the pictorial representation of the deployed System. While Table 1 shows the components specifications using in the design of the system.

Table 1. Specification for the components

S/N

Unit

Component

Specification

1

Power Supply

USB 2.0 Power Supply

Signal = 5 V DC

Max. Current = 0.5 A

2

Control

ESP32-CAM

Input voltage: 5v-DC

3

Communication

Inbuilt Wi-Fi module

Operating voltage = 3.3v-DC

Frequency Range = 2.412 - 2.484 GHz

Baud rate = 9600bps

4

Sensing

PIR (Passive Infrared) Sensor

In: 5 V DC, Out: Digital

5

Software

Arduino IDE, Messages App Cayenne API, Windows OS

C++ ISO/IEC 14882:2011, MQTT

Figure 2. Pictorial representation of the developed system

3.2 Hardware components

Only three components were inducted in this system, as follows:

  1. Micro USB Power Supply
  2. PIR Sensor
  3. ESP32-CAM

a) Micro USB Power Supply

The power supply device converts alternating current to direct current in the form of a mobile charger, and then it was passed to the micro USB power supply allowing 5v DC to been supplied to the ESP32-Cam and other components. The power supply unit is critical since it provides electricity to the whole System.

b) PIR Sensor

PIR (Passive Infrared) Sensors are pyroelectric devices that detect motion by detecting changes in the infrared levels produced by adjacent objects. This motion may be detected with a powerful signal on a single I/O pin. The PIR Sensor has a range of about 20 feet. This may vary according to the context. When sudden changes occur, such as when motion occurs, the sensor is designed to adapt to gradually changing circumstances that occur naturally throughout the day as the external conditions change, but it responds by increasing its output. Figure 3 shows the diagram of a well-labelled PIR sensor while Figure 4, shows that there are three pins in this sensor: The Source, Drain, and Ground (GND). In addition, Figure 5 depicts the working principle of PIR sensor.

The ESP32-Cam and Micro USB Power Supply units are both linked to the GND pin on the sensor’s ground wire, which is connected to the GND pin on the ESP32-Cam. Drain pin (also known as Vcc) is linked to the positive power supply, which is typically a 5-volt direct current source. It is also connected to the 5volts pin on the ESP32-cam. The Source pin, also known as the output pin (OUT), is also the device’s output pin since it is responsible for transmitting the detected infrared signal to the ESP32-Cam GPIO 12. Figure 6 shown the flowchart of the motion algorithm as depicted in Algorithm 1.

Figure 3. Pictorial view of the PIR sensor

Figure 4. Circuit diagram of the PIR sensor

Figure 5. Working principle of PIR sensor

Algorithm 1. The motion working steps sensor detection unit:

  1. compute the average value of a single hue in frame 1
  2. pause for X seconds
  3. find the average of a colour in frame 2
  4. If abs (avgF rame1 avgF rame2) is greater than the threshold,
  5. motion has been observed

Figure 6. Flowchart of the motion algorithm unit

c) ESP32-CAM

Figure 7. ESP32-CAM microcontroller

As shown in Figure 7, the ESP32-CAM is a microcontroller equipped with an ESP32-S processor, a micro SD card slot, an OV2640 camera and several general-purpose input/output (GPIO) pins. The ESP32-Cam has a total of sixteen pins. The pins used in this project include GND, GPIO 12, GPIO 0 and VCC+(5v), while for hard coding, the microcontroller, serial pins such as GPIO 1(TX) and GPIO 3(RX) are used. The ESP32-CAM outputs 3.3V. GPIO 0 determines whether the ESP32 is flashing or not. This GPIO is internally connected to a 10k Ohm pull-up resistor. When the GPIO 0 is connected to GND the ESP32-CAM goes into flashing mode and codes can be uploaded to the board. While Figure 8(a) shows the schematic diagram of the proposed system.

  • SD Card Connections

The following pins are used to interact with the SD card, as seen in Table 2. These are the pins used as general purpose input/output (GPIO): 12, 2, 13, 4, 15, and 14. They are all compatible with RTC (real-time clock) and ADC (analogue-to-digital converter).

  • FTDI Programmer

Using an FTDI programmer is the best approach to upload code to the ESP32-CAM.

GPIO 0 and GND are connected to put the ESP32-Cam into flashing mode; this allows codes to be passed to the ESP32-Cam. As seen in Figure 8(b), the 3.3v power pin is used to code the ESP32-Cam. After uploading the code, the GPIO 1 and GPIO 3 are used to attach other peripherals such as outputs or sensors.

It is connected as:

TX – to RX (GPIO 3) of the ESP32 module

RX - to TX (GPIO 1) of ESP32

GND - to GND

VCC (3.3v) – to 3.3v of ESP32

Table 2. A summary of the pins used to interact with the SD

MicroSD Card

ESP32 Pins

CLK

GPIO 14

CMD

GPIO 15

DATA0

GPIO 2

DATA1/ flashlight

GPIO 4

DATA2

GPIO 12

DATA3

GPIO 13

(a)

(b)

Figure 8. (a) Schematic diagram of the proposed system; (b) Connection diagram of the ESP32- CAM & the FTDI programmer

3.3 Software description

The software component consists of:

•   Sublime Text

•   Arduino IDE

•   Software application

  1. Sublime text

This is a text editor with programming code support. C++ was utilised to connect with the text editor in this project. Its main benefit was the ability to notice code syntax issues and automatically implement the code. It is compatible with Windows-based operating systems. MAC and Linux are both supported

  1. Arduino IDE

Arduino IDE is a cross-platform program built in C and C++ functions. It is used to create and upload programs to Arduino compatible boards and other vendor development boards through third-party cores. The code is installed into the ESP32-cam in this platform.

  1. Software application

In this case, the software program is named “Ismart.” A home automation software program enables remote monitoring of the property [19, 20]. When the user leaves his or her premises, the application may be armed. This enables the PIR sensor to detect motion and sends a signal to the ESP32-Cam, which notifies the user through SMS text and allows the user to take necessary measures and watch the intruder remotely. Figure 9 to Figure 10 show visual representations of the Ismart application deployment. Both indoor and outdoor was considered for testing this developed system and both environment worked very well.

Figure 9. Visual user interface of the Ismart application

Figure 10. Testing of the transmitted video detected

Motion Sensor Test: Activation of the motion sensor unit occurs when the application is armed. Once motion is detected, an SMS text message is delivered to the user, allowing him or her to monitor the surroundings from anywhere in the globe at any time as depicted by Figure 11 setting interface of the application. Figure 12 shows a sample of SMS text received by user during testing and setting of the developed system.

Figure 11. Setting interface of the application

Figure 12. Sample of SMS text received by user during testing and setting of the developed system

4. Results and Discussions

As long as the visual representation of data on the Ismart platform coincides with the actual video captured in real-time in an environment and with the proper functionality of the motion sensor unit, the surveillance system is considered to be in proper working order. The amount of time it takes for data to be sent as determined by the amount of traffic on the network and the speed of the internet connection.

The operational performance of the PIR sensor was tested to ensure that it performed in accordance with the intended requirements, allowing the system to be more sensitive to motion changes. The component of the technology that allows for remote monitoring was also tested. The values of the parameters may be retrieved at any time and from any location on the planet. Table 3 shows the summary comparative analysis. The developed system is more effective comparative of related works in terms of performance, cost, power consumption, and ease of use. Also, the developed system uses few components in achieving its intended purpose.

Table 3. Comparative analysis summary

References

Number of Components

Microcontroller

Module

Developed System

3

ESP32-CAM

Inbuilt Wi-Fi module

[15]

3

Raspberry Pi(single board computer )

No GSM Module

[16]

7

ESP-32 CAM

GSM Module

[6]

9

A Raspberry Pi(single board computer )

GSM Module

[17]

6

Raspberry Pi(single board computer )

GSM Module

[18]

4

Raspberry Pi(single board computer )

No GSM Module

5. Conclusions

Video surveillance systems have grown more sophisticated since the introduction of digital and wireless technology. Users may watch their residences remotely using surveillance cameras, while sensor networks give extra security possibilities based on the sensors. In addition, incorporating Wi-Fi into security systems offer for quicker data transfer and allows users to watch and operate the System from anywhere on the world. In the area of security, which is still a complex subject in the world today, this is of great benefit.

A lower-cost surveillance system was developed compared the cost of previous related in literature. Which offers an Internet of Things-based surveillance system that, when activated, monitors an environment and alerts the user through SMS text messages when an intruder is detected. In order to verify and examine the Ismart application and observe these events in real-time, the user must first log into the program. Some the merits of this developed system include reduction of complex structures, poor stability, high power consumption, and ample storage data, and cost.

The system was tested base on it functionability. Other parametrics such as how does the system handle false positives or negatives from the motion sensor? Providing information on error handling strategies that could help understand how the system maintains its reliability should be considered in future studies.

Acknowledgment

This paper is partly sponsored by Covenant University Center of Research, Innovation, and Discovery (CUCRID) Covenant University, Ota, Ogun State, Nigeria.

  References

[1] Okokpujie, K., Kennedy, C.G., Ayankoya, D., Noma-Osaghae, E., Okokpujie, I.P., Bhandari, K.S., Kalibbala, J.M. (2022). Development of a real-time home security and safety management system. In: Pattnaik, P.K., Sain, M., Al-Absi, A.A. (eds) Proceedings of 2nd International Conference on Smart Computing and Cyber Security. SMARTCYBER 2021. Lecture Notes in Networks and Systems, vol 395. Springer, Singapore. https://doi.org/10.1007/978-981-16-9480-6_11

[2] Nguyen, H.Q., Loan, T.T.K., Mao, B.D., Huh, E.N. (2015). Low cost real-time system monitoring using Raspberry Pi. In 2015 Seventh International Conference on Ubiquitous and Future Networks, Sapporo, Japan, pp. 857-859. https://doi.org/10.1109/ICUFN.2015.7182665

[3] Suh, K.S., Min, B.I., Yang, B.M., Kim, S., Park, K., Kim, J. (2022). Machine learning method using camera image patterns for predictions of particulate matter concentrations. Atmospheric Pollution Research, 13(3): 101325. https://doi.org/10.1016/j.apr.2022.101325

[4] Bhatti, M.T., Khan, M.G., Aslam, M., Fiaz, M.J. (2021). Weapon detection in real-time CCTV videos using deep learning. IEEE Access, 9: 34366-34382. https://doi.org/10.1109/ACCESS.2021.3059170

[5] Okokpujie, K., Kennedy, G.C., Nzanzu, V.P., Molo, M.J., Adetiba, E., Badejo, J. (2021). Anomaly-based intrusion detection for a vehicle can bus: A case for Hyundai Avante CN7. Journal of Southwest Jiaotong University, 56(5). https://doi.org/10.35741/issn.0258-2724.56.5.14

[6] Jyothi, S.N., Vardhan, K.V. (2016). Design and implementation of real time security surveillance system using IoT. In 2016 International Conference on Communication and Electronics Systems (ICCES), Coimbatore, India, pp. 1-5. https://doi.org/10.1109/CESYS.2016.7890003

[7] Li, D., Zhao, X., Liu, S., Liu, M., Ding, R., Liang, Y., Zhu, Z. (2022). Radio frequency analog-to-digital converters: Systems and circuits review. Microelectronics Journal, 119: 105331. https://doi.org/10.1016/j.mejo.2021.105331

[8] Omoregbe, N.A., Ndaman, I.O., Misra, S., Abayomi-Alli, O.O., Damaševičius, R., Dogra, A. (2020). Text messaging-based medical diagnosis using natural language processing and fuzzy logic. Journal of Healthcare Engineering, 2020: 1-14. https://doi.org/10.1155/2020/8839524

[9] Hassan, S.B., Hassan, S.B., Zakia, U. (2020). Recognizing suicidal intent in depressed population using NLP: A pilot study. In 2020 11th IEEE Annual Information Technology, Electronics and Mobile Communication Conference (IEMCON), Vancouver, BC, Canada, pp. 0121-0128. https://doi.org/10.1109/IEMCON51383.2020.9284832

[10] Balakrishna, K., Mohammed, F., Ullas, C.R., Hema, C.M., Sonakshi, S.K. (2021). Application of IOT and machine learning in crop protection against animal intrusion. Global Transitions Proceedings, 2(2): 169-174. https://doi.org/10.1016/j.gltp.2021.08.061

[11] Singh, R.P., Javaid, M., Haleem, A., Suman, R. (2020). Internet of things (IoT) applications to fight against COVID-19 pandemic. Diabetes & Metabolic Syndrome: Clinical Research & Reviews, 14(4): 521-524. https://doi.org/10.1016/j.dsx.2020.04.041

[12] Chou, J.S., Truong, N.S. (2019). Cloud forecasting system for monitoring and alerting of energy use by home appliances. Applied Energy, 249: 166-177. https://doi.org/10.1016/j.apenergy.2019.04.063

[13] Hammi, B., Zeadally, S., Khatoun, R., Nebhen, J. (2022). Survey on smart homes: Vulnerabilities, risks, and countermeasures. Computers & Security, 117: 102677. https://doi.org/10.1016/j.cose.2022.102677

[14] Okokpujie, K.O., Odusami, M., Okokpujie, I.P., Abayomi-Alli, O. (2017). A model for automatic control of home appliances using DTMF technique. International Journal of Scientific & Engineering Research, 8(1): 266-272. 

[15] Patel, P.B., Choksi, V.M., Jadhav, S., Potdar, M.B. (2016). Smart motion detection system using raspberry pi. International Journal of Applied Information Systems (IJAIS), 10(5): 37-40.

[16] Ahmed, T., Nuruddin, A.T.B., Latif, A.B., Arnob, S.S., Rahman, R. (2020). A real-time controlled closed loop IoT based home surveillance system for Android using Firebase. In 2020 6th International Conference on Control, Automation and Robotics (ICCAR), Singapore, pp. 601-606. https://doi.org/10.1109/ICCAR49639.2020.9108016

[17] Bhatkule, A.V., Shinde, U.B., Zanwar, S.R. (2016). Home based security control system using raspberry pi and GSM. International Journal of Innovative Research in Computer and Communication Engineering, 4(9): 16259-16264. https://doi.org/10.15680/IJIRCCE.2016. 0409083

[18] Jayakumar, A.J.K., Muthulakshmi, S. (2018). Raspberry Pi-based surveillance system with IoT. In: Thalmann, D., Subhashini, N., Mohanaprasad, K., Murugan, M. (eds) Intelligent Embedded Systems. Lecture Notes in Electrical Engineering, vol 492. Springer, Singapore. https://doi.org/10.1007/978-981-10-8575-8_19

[19] Okokpujie, K., Okokpujie, I.P., Subair, R.E., Simonyan, E.O., Akingunsoye, A.V. (2023). Designing an adaptive Age-Invariant Face recognition system for enhanced security in smart urban environments. Ingénierie des Systèmes d’Information, 28(4): 815-822. https://doi.org/10.18280/isi.280402

[20] Isife, O.F., Okokpujie, K., Okokpujie, I.P., Subair, R.E., Vincent, A.A., Awomoyi, M.E. (2023). Development of a malicious network traffic intrusion detection system using deep learning. International Journal of Safety & Security Engineering, 13(4): 587-595. https://doi.org/10.18280/ijsse.130401