Using The ESP32 Microcontroller For Data Processing
Using The ESP32 Microcontroller For Data Processing
Processing
Marek Babiuch Petr Foltýnek Pavel Smutný
Department of Control Systems and Department of Control Systems and Department of Control Systems and
Instrumentation Instrumentation Instrumentation
VSB - Technical University of Ostrava VSB - Technical University of Ostrava VSB - Technical University of Ostrava
Ostrava, Czech Repubic Ostrava, Czech Repubic Ostrava, Czech Repubic
marek.babiuch@vsb.cz petr.foltynek@vsb.cz pavel.smutny@vsb.cz
Abstract — This article deals with experiences with the These articles summarize the main advantages of the
development of applications of the ESP32 microcontrollers and ESP32 chip, which includes: wide deployment capabilities,
provides a comprehensive review of the possibilities of support for Wi-Fi standards and protocols, low-cost solution.
applications development on this platform in the area of data However, these articles describe deploying a microcontroller
measurement and processing. Microcontrollers usually connect as a system that provides data as a web server and
with IoT modules and other smart sensors and provide data to communicates with the environment and the superior system.
the superior system. This paper also describes implementation In this article we will also attempt to describe the possibility
of application with the version of connected OLED display and of displaying measured data also on different types of displays
with ESP32 Wrover development board with integrated display.
directly on the microcontroller and displaying the status of the
Keywords—ESP32, IoT, microcontroller, measurement,
current data or system configuration for an immediate check
display, development boards, environment of the system status.
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.
ESP32 boards are produced in prototype designs that can program is, as with the Arduino platform, assigned to the setup
be used in smart home applications, automation, wearables, function, which initializes the startup values of the
audio applications, cloud-based IoT applications, and more. It microcontroller and the loop function that is responsible for
is possible to choose a specific development kit or to design a running the program. When developing ESP32
custom embedded system built on the ESP32 microcontroller. microcontrollers, the loop function is always run on the first
processor core. However, we need to realize that the ESP32
core numbering starts from the zero index.
The benefits of using this environment are its simple
configuration and good community support. Using this
environment, you can very quickly start prototyping the
ESP32 microcontroller. This environment is designed for the
development of simpler projects, with complex projects being
a loss of clarity and sustainability of the project. At the same
time, this platform is ideal for achieving experience with the
development of the ESP32 microcontroller.
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.
command. To monitor the application, you can use a built-in Uploading the program and library functions to the
monitor that runs with the make monitor command. microcontroller can be done using the python utility ampy,
which provides communication with the microcontroller over
the serial line. Despite this utility, any manipulation of the files
on the microcontroller is performed. The command to upload
the main.py file to the microcontroller looks like:
ampy -p <USB-to-Serial Port> put main.py
A terminal connection can be used to debug Python on a
microcontroller, for example, using the PuTTY program. You
can use any available text editor to write Python programs. We
use Visual Studio Code for these purposes.
This development approach is advantageous for
prototyping and developing new algorithmic solutions for
embedded systems based on MicroPython firmware. The
development difficulty is somewhat higher than on the
Fig. 2. The configuration of ESP project in IDF
Arduino platform because there is no simple interface, but it
is secured by a set of command line utilities.
The great advantage of using this framework is that you
can create applications at the lowest level. Therefore, this
framework is suited to the development of large and complex D. Other Development Possibillities
projects. The disadvantage of using a framework is the There are still other ways to develop an application for
relatively high initial experience of the developer that the ESP32 microcontrollers, for example by using the Lua
embedded system will develop. The community around this programming language with the appropriate firmware, or by
framework is also not as wide as the Arduino platform. using the JavaScript programming language. Another option
is to use some of the commercial projects such as Zerynth [13]
C. MicroPython that support ESP32 microcontrollers too. However, we have
not tested these platforms yet. Our goal in this section was to
Some manufacturers that produce ESP32 chip-based
describe the most commonly used open-source approaches for
development boards now use MicroPython environments as
embedded system development on the ESP32 microcontroller
default firmware. The most common are ESP32-Wrover
on Windows platforms and to compare the experience with
chips, which are usually available with PSRAM. MicroPython
their use.
is a lightweight implementation of the Python 3 programming
language that includes a subset of Python's standard libraries
and is optimized for running on microcontrollers. The IV. ESP32 APPLICATION
advantage of Python as a programming language is that it can The experience gained from the use of individual
be learned quite quickly. In case the ESP32 microcontroller development environments on the Windows platform has
does not contain MicroPython firmware, it is possible to been used in the practical implementation of various
upload this firmware to the given microcontroller. This is done applications in the field of acquisition and processing of
using the esptools utility, which is written in Python and measured data from IoT sensors on the ESP32
distributed via a pip package system that is native in Python microcontroller. The block diagram of the embedded system
environment. Subsequently, you need to download the is shown in Figure 3.
MicroPython Firmware, which is available on [12].
Uploading MicroPython Firmware is done using the
following command: esptool.py --chip esp32 -p <USB-to-
Serial Port> write_flash -z 0x1000 <path to .bin>
where a COM port through which the ESP32
microcontroller communicates with the development
computer is added to the <USB-to-Serial Port>, and a file
name and a MicroPython firmware path location are added to
the <path to .bin>. Now, after preparing the MicroPython
environment on the ESP32 microcontroller, we will learn
some basic programming rules. Each solution should contain
at least two files, boot.py and main.py. It corresponds to the
concept used in the Arduino platform. The boot.py file defines Fig. 3. Block scheme of the embedded system
the initialization of the variables to be set at the start of the
microcontroller, and main.py contains the microcontroller In this article, we focused on the visualization of measured
program that is executed without delay after initializing the data on a display that is part of our embedded system. The
variables in the boot.py file. If we need to use other library communication buses are different depending on the type and
functions that are not implemented in the fundamental size of the display and the size of the display depends on what
MicroPython firmware, these library functions must also be kind of information we will display. For lower resolution
flashed to the device. Typically, these are libraries that provide displays, we decided to show only the status information and
communication and behavior of a particular hardware we sent the measured data for the evaluation to the superior
element, such as displays, sensors and IoT modules, etc. system. The information we show on the given display is, for
example, whether the microcontroller has a network
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.
connection, which current job is processing, what the actual B. Application with OLED Display 0,96”
measurement cycle is, etc. On displays that have a higher size This display has a resolution of 128x64 pixels. It is
and resolution, we also show the graphical flow of the produced in the I2C or SPI version. We have used the I2C
measured values in addition to the status information. In case communication interface in our application, because we
we simultaneously measured multiple variables at the same wanted to reduce the HW complexity of our solution. The
time, only the chart for one quantity was displayed, with the display is programmed the same as the 0.91-inch OLED
possibility of switching between graphs of the measured display variant, the only difference being in the display
quantities. We have used multiple types of displays for our number of pixels and rows. Although this display is 2 times
embedded system. larger than the previous one, it is inappropriate to draw the
measurement chart. Therefore we display more detailed status
information on this display with this resolution than on the
previous one. The figure 4 shows using of 0.96-inch display.
ESP32 microcontrollers are produced in different versions and
one of the variants is an integrated 0.96 inch display directly
on the board. If this is sufficient for our application, we can
use this development board. Figure 6 shows the integrated
display on the ESP32 board with status information. We
displays wireless connection again, this time with IP address,
number of measured samples and output file.
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.
The big advantage is that a 320x240 color LCD display is IDF platform, in which development is provided through C
already natively installed on this kit, which communicates via language with a native firmware downloader.
the 4-wire Serial Peripheral Interface (SPI). Espessif's GitHub We can encounter quite often MicroPython on new boards
[17] contains a free library for working with the LCD display with ESP32 Wrover chip, which features advantages of
on the Wrover development kit. From the point of view of Python language properties and allows application
programming, access is similar to previous displays. Because development both procedurally and with the use of object-
it is a larger resolution of the display, it is possible to display oriented design.
the graphical waveform of the measured values on this
display. Due to the fact that the library provides only the We often encounter the problems of visualization of
Application Programming Interface (API), it is necessary to measured data and system diagnostics during developing an
embedded system. Some development boards with ESP32
program the plotted charts. This part is relatively difficult for
microcontrollers are already produced with an integrated
debugging and testing compared to displaying only the status
display of various sizes. In our article, we describe an
information on the display. Therefore, it is very important to experience with an application design that uses different types
consider whether we want to use the feature on our embedded of displays. We can recommend from our experiences with
system. If we decide that charts are necessary, it's a good idea application development that the status information is better
to create a graph component that makes it easier for us to work to display on small displays, and larger displays can also
with charts. Figure 7 shows measured data directly on the display real-time data. The more graphic information we want
integrated display. Because we measured more quantities at to show on the display, the more difficult the application is
the same time, we have programmed a change in the display and the more demanding for the developer. So, if we decide to
of quantities over a certain time interval. Figure 8 shows other display graphics in real-time, it's a good idea to create a graph
measured variables. The display of accelerometer sensor component that has the responsibility for chart plotting and is
values and temperature measurement values changes independent of the hardware implementation of the display
cyclically. work.
ACKNOWLEDGMENT
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 SP2019/51
Applied Research in the Area of Machine and Process Control
supported by the Ministry of Education, Youth and Sports.
REFERENCES
[1] A. Maier, A. Sharp, Y. Vagapov, “Comparative analysis and practical
implementation of the ESP32 microcontroller module for the internet
of things” 2017 Internet Technologies and Applications, ITA 2017 -
Proceedings of the 7th International Conference IEEE, pp 143-148,
November 2017, DOI: 10.1109/ITECHA.2017.8101926.
[2] I. Allafi, T. Iqbal, “Design and implementation of a low cost web server
using ESP32 for real-time photovoltaic system monitoring” 2017
IEEE Electrical Power and Energy Conference, EPEC 2017, pp 1-5,
February 2018, DOI: 10.1109/EPEC.2017.8286184.
[3] B.S. Sarjerao, A. Prakasarao, “A Low Cost Smart Pollution
Measurement System Using REST API and ESP32” 3rd International
Conference for Convergence in Technology, I2CT 2018, November
2018, DOI: 10.1109/I2CT.2018.8529500.
[4] A.H. Abdullah, S. Sudin, M.I.M. Ajit, F.S.A. Saad, K. Kamaruddin, F.
Fig. 8. Boxed embedded ESP32 system with the integrated display Ghazali, Z.A. Ahmad, M.A.A. Bakar, “Development of ESP32-based
Wi-Fi Electronic Nose System for Monitoring LPG Leakage at Gas
Cylinder Refurbish Plant” 2018 International Conference on
Computational Approach in Smart Systems Design and Applications,
V. CONCLUSION August 2018, DOI: 10.1109/ICASSDA.2018.8477594
We summarized in this article the most commonly used [5] D. Ghosh, A. Agrawal, N. Prakash, P. Goyal “Smart Saline Level
application development platforms for the ESP32 Monitoring System Using ESP32 And MQTT-S” 20th International
microcontroller. For each platform, we have described the Conference on e-Health Networking, Applications and Services,
Healthcom 2018, DOI: 10.1109/HealthCom.2018.8531172.
benefits, recommendations for which type of application the
[6] A. Iqbal, T. Iqbal, “Low-cost and Secure Communication System for
platform is suitable for, and at the same time we have Remote Micro-grids using AES Cryptography on ESP32 with LoRa
compared the level of prerequisites for that platform in terms Module” 2018 IEEE Electrical Power and Energy Conference (EPEC),
of software skills and experience of the developer. We October 2018, DOI: 10.1109/EPEC.2018.8598380.
recommend to use the Arduino ESP 32 Core extension [7] S. Bipasha Biswas, M. Tariq Iqbal “Solar Water Pumping System
platform for beginning developers on the ESP32 platform and Control Using a Low Cost ESP32 Microcontroller” Canadian
also for quickly verification of application design, but for the Conference on Electrical and Computer Engineering, CCECE 2018,
May 2018, DOI: 10.1109/CCECE.2018.8447749.
product development and better use of hardware properties
[8] P. Urban, L. Landryova, “Collaborative Operations Using Process
(programming of two RTOS cores), we recommend the ESP Alarm Monitoring” IFIP WG 5.7 International Conference on
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.
Advances in Production Management Systems, APMS 2017, [13] Zerynth “The Middleware for IoT” [online], 2019, available at:
September 2017, DOI: 10.1007/978-3-319-66923-6_52. https://www.zerynth.com/
[9] G. Takacs, J. Vachálek, B. Rohal’-Ilkiv, “Online Structural Health [14] GitHub “OLED SSD1306” [online], 2019, available at:
Monitoring and Parameter Estimation for Vibrating Active Cantilever https://github.com/ThingPulse/esp8266-oled-ssd1306
Beams Using Low-Priced Microcontrollers”, Shock and Vibration, [15] GitHub “Sample code for driving 128x64 OLED display with
Volume 2015, DOI: 10.1155/2015/506430. SSD1306 driver via ESP-IDF's I2C master driver” [online], 2019,
[10] GitHub “Arduino core for ESP32 WiFi chip” [online], 2019, available available at: https://github.com/yanbe/ssd1306-esp-idf-i2c
at: https://github.com/espressif/arduino-esp32 [16] GitHub “Adafruit CircuitPython driver for SSD1306 or SSD1305
[11] GitHub “Espressif IoT Development Framework” [online], 2019, OLED displays” [online], 2019, available at: https://github.com/
available at: https://github.com/espressif/esp-idf/ adafruit/Adafruit_CircuitPython_SSD1306
[12] MicroPython “Firmware for ESP32 boards” [online], 2019, available [17] GitHub “Library for the Adafruit ILI9341 display products” [online],
at: https://micropython.org/download/#esp32 2019, available at: https://github.com/espressif/WROVER_KIT_LCD/
Authorized licensed use limited to: Universidade Tecnologica Federal do Parana. Downloaded on August 31,2022 at 20:27:21 UTC from IEEE Xplore. Restrictions apply.