ESP32 programming, Arduino - install requirements
I have not had much to do with Arduino or microcontrollers, apart from updating and operating my 3D printer. Microcontrollers, for example the ESP32, offer a cheap alternative to the Raspberry Pi for certain purposes, such as collecting data or certain control or monitoring tasks: WLAN and Bluetooth included. After entering new territory for me here, I wanted to share my experience from a beginner's point of view. Background of my efforts was a concrete use case.
I had set myself the goal to record the water flow of my water-to-water heat pump. For measuring the flow I use an ultrasonic flowmeter TUF-2000B, this works so far and shows the actual flow and offers RS485 as interface, see: Commissioning Ultrasonic Flowmeter Flowmeter TUF-2000M. To display and record the flow rates of the TUF-2000B in Home-Assistant, I need a way to read out the serial interface RS485 and transmit the data via WLAN to Home-Assistant. For receiving the data in Home-Assistant I need something like MQTT, which I will describe in a separate article.
Equipment
For the use case, i.e. the recording of data from a RS485 interface, I got the following hardware and have it available:
- ESP32 Dev Kit C V4 NodeMCU WLAN WiFi Development Board
(manufacturer details: https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/esp32-das-multitalent)
- RS485 to TTL 5V converter with MAX13487 chip for Raspberry Pi Arduino and other MCU
- as plan B I would also have a Raspberry PI 3 in the drawer
But my first intermediate goal for now is just to be able to address the ESP32 via the existing USB port and to upload an example: Both should be possible via the Arduino IDE.
see: Home Assistant + DIY Microcontroller + ESP Home (Docker).
Arduino IDE from the MS-Store
Not needed for a long time, but from updating the 3D printer I remember that the Arduino IDE is available in the Windows Microsoft Store:
After starting the IDE, the board hardware can be selected under Tools, Boards.
ESP32 is missing from the boards
Unlike the 3D printer, I can't find the ESP32 among the available boards:
After a brief search, additional source URLs, for previously unknown boards, can be added under Preferences:
After a short excursion with other URLs and the board version 2.02 -> see ESP32 2.0.2, it worked with version 1.06 and the URL: "https://dl.espressif.com/dl/package_esp32_index.json" then worked:
After specifying the URL, the hardware can be installed and selected in the Boards Manager:
Connect ESP32 via USB
The ESP32 can simply be connected to the computer with a USB cable, which also triggers the typical USB noise when connecting new devices, but the ESP32 does not appear in the Arduino IDE.
as COM port only port: COM1 is available
At this point we are still missing a driver: docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/establish-serial-connection.html -> www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
Install CP210x Universal Windows Driver
After downloading and unzipping the driver, it can be easily integrated by "right-clicking" and "Install":
After this action an additional COM port, in my case COM3 appears under the ports:
After selecting COM3 we have a connection to our ESP32:
Once all preparations for programming an ESP32 are done, the examples available in the Arduino IDE can be adapted and uploaded to the ESP32:
The upload of the WiFiClient and a simple web server (HelloServer) follows in a separate article ...
ESP32 Version 2.0.2
The first time I tried to program an ESP32 in the Arduino IDE, I would have tried ESP32 board version 2.0.2: ... continue reading
{{percentage}} % positive