Problemas Conhecidos e suas "Soluções"
Sintoma
Erro ao compilar ou subir código para ESP32.
Problema
Traceback (most recent call last):
File "/home/meslin/.arduino15/packages/esp32/tools/esptool_py/4.6/esptool.py", line 34, in <module>
import esptool
File "/home/meslin/.arduino15/packages/esp32/tools/esptool_py/4.6/esptool/__init__.py", line 41, in <module>
from esptool.cmds import (
File "/home/meslin/.arduino15/packages/esp32/tools/esptool_py/4.6/esptool/cmds.py", line 14, in <module>
from .bin_image import ELFFile, ImageSegment, LoadFirmwareImage
File "/home/meslin/.arduino15/packages/esp32/tools/esptool_py/4.6/esptool/bin_image.py", line 14, in <module>
from .loader import ESPLoader
File "/home/meslin/.arduino15/packages/esp32/tools/esptool_py/4.6/esptool/loader.py", line 30, in <module>
import serial
ModuleNotFoundError: No module named 'serial'
exit status 1
Compilation error: exit status 1
Solução
Instalar pyserial:
$ pip install pyserial
Defaulting to user installation because normal site-packages is not writeable
Collecting pyserial
Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.6/90.6 KB 1.8 MB/s eta 0:00:00
Installing collected packages: pyserial
Successfully installed pyserial-3.5
Sintoma
Erro ao compilar código para ESP32.
Problema
O ESP32 não usa as convenções de nome A0, A1, etc., para pinos analógicos.
arquivo.ino:4:27: error: 'A1' was not declared in this scope; did you mean 'y1'?
4 | const byte PIN_ANALOG_Y = A1;
| ^~
| y1
exit status 1
Compilation error: 'A1' was not declared in this scope; did you mean 'y1'?
Solução
No ESP32, devemos usar os números de GPIO diretamente:
ADC0: GPI36
ADC3: GPI39
ADC4: GPIO32
ADC5: GPIO33
ADC6: GPI34
ADC7: GPI35
ADC10: GPIO4
ADC11: GPIO0
ADC12: GPIO2
ADC13: GPIO15
ADC14: GPIO13
ADC15: GPIO12
ADC16: GPIO14
ADC17: GPIO27
ADC18: GPIO25
ADC19: GPIO26
Veja pinagem completa nessa página.