A guided tutorial on how to install EspressIf ESP32 for Arduino and use it to blink the built-in led
Table of Content
Requirements
Install Arduino IDE. Visit their site for instructions.
Add permission to use the serial connection and operate with it.
Make sure your board is recognized properly.
Add permission for serial operations
In case your current user is not added to dialout group, you have to add it.
1
2
sudo adduser $USER dialout
sudo usermod -a -G dialout $USER
Check if ESP32 board is connected to your computer
The fastest way to check whether the board is connected to the computer or not is using lsusb command
1
Bus 002 Device 003: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
You should see a line similar to previous one. If you dont, check your cable and board.
Finish Arduino IDE installation
After you download Arduino IDE files, you are required to execute install.sh script to complete installation, add shortcut, menu items, etc.
1
./install.sh
If you run install.sh without root permissions, you will see following error message
1
2
3
4
5
6
Adding desktop shortcut, menu item and file associations for Arduino IDE...
ln: failed to create symbolic link '/usr/local/bin/arduino': Permission denied
Adding symlink failed. Hope that's OK. If not then rerun as root with sudo.
done!
So, you need to execute install.sh script with sudo
1
2
sudo ./install.sh
[sudo] password for sergio:
After that, the success results will be
1
2
3
4
Adding desktop shortcut, menu item and file associations for Arduino IDE...
done!
After this, is time to restart the arduino IDE and check for right installation and support for ESP32 boards.
Pyserial not installed error
1
2
3
4
5
6
7
Pyserial is not installed for /usr/bin/python. Check the README for installation instructions.Traceback (most recent call last):
File "/home/sergio/Downloads/arduino-1.8.15/hardware/espressif/esp32/tools/esptool/esptool.py", line 38, in <module>
import serial
ImportError: No module named serial
exit status 1Error compiling for board ESP32 Dev Module.
The solution to previous error is to install PySerial. We can install easily with pip utility.
After this, you can compile Arduino sketchs with no problem. The Arduino IDE will report to you sketch final size, for example
1
2
Sketch uses 205592 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 11976 bytes (3%) of dynamic memory, leaving 315704 bytes forlocal variables. Maximum is 327680 bytes.
Flashing a Arduino code to ESP32
To verify the installation and support for ESP32, we will flash an example file. This sketch will make the builtin led to blink.
Flash Arduino Led Blink sketch to ESP32
This ESP32 board has a built in LED on pin D9, which we will control using a very simple Arduino program
In order to successfully complete the code flashing process, you need to press BOOT button of the board while you flash the sketch. The button must be kept hold until you see Writing at ... line.
Sketch uses 214148 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 12304 bytes (3%) of dynamic memory, leaving 315376 bytes forlocal variables. Maximum is 327680 bytes.
python /home/sergio/Downloads/arduino-1.8.15/hardware/espressif/esp32/tools/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 /home/sergio/Downloads/arduino-1.8.15/hardware/espressif/esp32/tools/partitions/boot_app0.bin 0x1000 /tmp/arduino_build_418056/empty.ino.bootloader.bin 0x10000 /tmp/arduino_build_418056/empty.ino.bin 0x8000 /tmp/arduino_build_418056/empty.ino.partitions.bin
esptool.py v3.1-dev
Serial port /dev/ttyUSB0
Connecting........_____....._
Chip is ESP32-D0WDQ6 (revision 1)Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: OFUSCATED_MAC_HERE
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 703.8 kbit/s)...
Hash of data verified.
Compressed 18576 bytes to 12483...
Writing at 0x00001000... (100 %)Wrote 18576 bytes (12483 compressed) at 0x00001000 in 1.3 seconds (effective 111.4 kbit/s)...
Hash of data verified.
Compressed 214288 bytes to 120110...
Writing at 0x00010000... (12 %)Writing at 0x0001c9c3... (25 %)Writing at 0x00021f78... (37 %)Writing at 0x000273f9... (50 %)Writing at 0x0002c783... (62 %)Writing at 0x00035ed3... (75 %)Writing at 0x0003cef3... (87 %)Writing at 0x00042749... (100 %)Wrote 214288 bytes (120110 compressed) at 0x00010000 in 10.7 seconds (effective 160.0 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 438.1 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
By default, my ESP32 board each time is reset shows
Thanks for checking this out and I hope you found the info useful! If you have any questions, don't hesitate to write me a comment below. And remember that if you like to see more content on, just let me know it and share this post with your colleges, co-workers, FFF, etc.