ESP UART using Arduino IDE
Many projects have me finding myself in a position where I cannot find all of the information in one place to solve what should be a simple problem.
I’m on Manjaro Linux trying to use the Arduino IDE to create a usb UART interface from an esp32 devkit I have in the drawer. Before getting started, we needed to find a board support package for the ESP32 to shove into the Arduino IDE.
- With Arduino IDE open, press
Ctrl
+,
- Under
Additional Board Manager URLs
addhttps://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
- Open Tools > Board > Board manager
- Search
Esp32
and installArduino ESP32 Boards
- Select an Arduino esp32 option from the boards dropdown before compiling or flashing
Upon compilation it was determined that there was no serial module available for flashig phase.
import serial
ImportError: No module named serial
As it turns out, I did not have pip, either. Open a terminal and input:
sudo pacman -S python-pip
pip install pyserial
Serial port /dev/ttyUSB0
File "/home/YOURUSERHERE/.local/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB0'
Permissions can be checked in your terminal using:
ls -lash /dev/tty*
in this case, I needed to modify my user permissions in the group uucp to access serial devices.
sudo usermod -aG YOURUSERHERE uucp
To remove users from a group if you wish to do so after flashing:
sudo gpasswd -d YOURUSERHERE uucp
Below pins 2 and 4 are being used. Pin 2 for receive and pin 4 for transmit.
A substantial amount of help came from this source
Using any GPIO pins as Rx / Tx:
|
|
Screen command for setting baudrate on your TTY port:
screen /dev/ttyUSB0 115200