ESP32 is a family of systems on a chip microcontrollers, which their functionalities focus on embedded systems and IoT (Internet of Things). Most of their applications are centered around and chosen due those chip's reliability on wireless telecommunications, low-power consumption, abundance of I/O pins and dual-core processor. However, there's much more that can be done with a microcontroller of this kind.
Bojan Jurca has released a functional oscilloscope application for esp32 devices which displays the received data on a webpage. It has support for most esp32 boards, and uses the I2S interface for data sampling.
We will use this project and add it to one of our esp32 PLC.
1. Get the files
We'll first take everything in the Git repository and unpack it in a new folder on our machine.
2. Open IDE
Open "Esp32_oscilloscope.ino" with Arduino IDE. Opening this file will also open the rest of dependencies, keeping them in different tabs of the IDE.
Arduino IDE might ask of us to put the .ino file in a folder with the same name. If you do, don't forget all the files must be in the same directory.
3. Set the board config
Connect the esp32 PLC to our PC with a USB cable.
Since Industrial Shield esp32 boards don't have options to set the filesystem used, we'll have to improvise and use a basic "ESP32 Dev Module". We'll set the filesystem "Partition Scheme > Default 4MB with ffat". We could use other partition schemes as long as they are FAT/FATFS. This one in particular we found it works just fine.
4. Set SSID and PASSWORD
This app hosts a small server we should be able to access to see the sampled data. For that, we need to change the network configuration.
In "Esp32_osccilloscope.ino" , change DEFAULT_STA_SSID and DEFAULT_STA_PASSWORD to our WiFi access point name and its password respectively. We'll have to make sure the machine we run the web browser on after activating the code will be connected to the same WiFi device.
Now that this is done, we can upload the sketch.
When the esp32 connects to the WiFi access point it will give back an IP address we will from now on be using to access the microcontroller.
6. Copy HTML file to the correct path
The filesystem has been mounted, but the files aren't in the right place. For that, we'll have to copy the file "oscilloscope.html" to the appropriate directory. Open a terminal on the root folder of the project and use the following commands:
7. Use
After a quick reboot of the esp32, we can now test it out. In a web browser on a machine connected to the same WiFi as the esp32, we open the website http://ESP32_IP/oscilloscope.html. Change "ESP32_IP" for your esp32's IP. We can now use it accordingly.
In case of one of our PLC boards, we will select any of the GPIOs that are accessible on the board. We have chosen GPIO21, which is the SDA pin of our PLC.
After connecting the signal, we can finally start the oscillator.
Most avid users of ESP32 products will know about the esp32 family's little reliability on analog I/Os. This however, poses no issue for Industrial Shields PLCs that don't use directly the ESP32's GPIOs for data sampling. On top of that, 14IOs PLCs have an analog sampling correction included in the Industrial Shields libraries which increases the ESP32 data reliability.
Oscilloscope using an ESP32 PLC