Saturday, July 11, 2020

BasicOTA: Program ESP32 (or ESP8266) via ArduinoOTA, on Windows 10/Arduino IDE

One of the very useful feature of ESP32/ESP8266 is OTA (Over-The-Air) programming; such that you can update the firmware without physically connect to the device.

With ESP32/ESP8266 core for Arduino installed to your Arduino IDE, you can find ArduinoOTA examples of BasicaOTA and OTAWebUpdater under Examples for ESP32 Dev Module.


This post show trying BasicOTA examples on ESP32-DevKitC using Arduino IDE running on Windows 10, and fix the problem I faced:  Network Ports no shown and No response from device.


Basically, the default DevKitC firmware have no OTA function. So you have to flash the first firmware with OTA function using serial port (USB). After then, you can update your firmware via OTA without physical connected serial port. Both the computer used to update the firmware and the ESP devices to be updated have to be in the same network.

The ESP device I used in this example is ESP32-DevKitC with ESP32-WROOM-32 module. It should be a relatively old and original version.


Somebody (include me) reported there are no Network Ports shown up. 


Somebody suggested to install Python, somebody suggested to reboot router, or install Bonjour... All of them not work for me. In order to eliminate the problem outside my computer, I decide to use Windows 10's Mobile hotspot.


Open BasicOTA example and change ssid and password according to my network setting. Upload the ESP32 device via serial port (USB, or COM5 in this example).

Turn on Windows 10's Mobile hotspot with matched ssid/password.

Now the Network ports shown, with attached device (the programmed ESP32 with OTA function) and its assigned ip.


Once Network port selected, the Arduino IDE's Serial Monitor not work on network. So I run Putty to monitor the output from ESP device via serial port.

Now, upload your second program via OTA. But still fail due to No response from device.


Now, open Windows Security and Allow espota.exe to communicate through Windows Defender Firewall.

Upload again, and Done uploading.
(In the various steps, the assigned ip of the ESP device may be changed. Double check the ip in Putty and select the Network port accordingly.)


Saturday, June 27, 2020

ESP32-DevKitC + 2.8inch 240x320 SPI TFT (ILI9341) using TFT_eSPI library

This post show how to use ESP32-DevKitC to drive a 2.8inch 240x320 SPI TFT (wih ILI9314 using serial interface), using TFT_eSPI library.




Connection:


I connect ESP32-DevKitC and Display board follow the default setting of TFT_eSPI library.
TFT_MISO 19
TFT_MOSI 23
TFT_SCLK 18
TFT_CS   15
TFT_DC    2
TFT_RST   4

I found the Fritzing parts here:
ESP32S-HiLetgo Dev Boad with Pinout Template
https://forum.fritzing.org/t/esp32s-hiletgo-dev-boad-with-pinout-template/5357

2.2 320x240 TFT ILI9341.fzpz (it should be logically same as the 2.8" display I use)
https://forum.fritzing.org/t/2-2-ili9342-tft/1813

Setup Library in Arduino IDE:
Menu > Sketch > Include Library > Manager Libraries...
Search and install TFT_eSPI


Then have to edit User_Setup.h to fix your circuit.


- Confirm ILI9341_DRIVER is defined

- comment the original define of:
TFT_CS, TFT_DC and TFT_RST.

- un-comment the pin define under "For ESP32 Dev board (only tested with ILI9341 display)"
TFT_MISO, TFT_MOSI 23, TFT_SCLK, TFT_CS, TFT_DC and TFT_RST.

Then, you can try any example under TFT_eSPI.



Thursday, June 25, 2020

Install ESP32/ESP8266 to Arduino IDE on Ubuntu 20.04, with setup Pythton & serial

After install JDK (OpenJDK) and Arduino IDE on Ubuntu 20.04, you can add support of ESP32 (or ESP8266).

May be you will be with Python 2 related error of:
exec: "python": executable file not found in $PATH
ModuleNotFoundError: No module named 'serial'

In 20.04 LTS, the python included in the base system is Python 3.8. Python 2.7 has been moved to universe and is not included by default in any new installs. (referene: Ubuntu 20.04 LTS (Focal Fossa) release notes)

Here show how to fix it:


First, install board to Boards Manager:

Menu > File> Preferences
Enter the url in the "Additional Board Manager URLs":
https://dl.espressif.com/dl/package_esp32_index.json (for ESP8266)
http://arduino.esp8266.com/stable/package_esp8266com_index.json (for ESP8266)

To enter more than one URL, separate it with a comma.

Menu > Tools > Board > Boards Manager…
Search and install ESP32 (or ESP8266)

When you build your code for ESP32/ESP8266, if you report with error of :
exec: "python": executable file not found in $PATH

It's because Python 2 is not installed on Ubuntu 20.04. You can create a symlinks /usr/bin/python to python3 by installing python-is-python3.

$ sudo apt install python-is-python3

Optionally, you can prevent Python 2 from being installed as a dependency of something in the future:

$ sudo apt-mark hold python2 python2-minimal python2.7 python2.7-minimal libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib

Then you may be report with error:
ModuleNotFoundError: No module named 'serial'

Because pyserial is not installed in Python 3 by default. Install with pip:

$ sudo apt install python3-pip
$ pip3 install pyserial

Additionally, if you cannot download your code to board caused by:
avrdude: ser_open(): can't open device "/dev/xxx": Permission denied

Add permission to your user:

$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw /dev/xxx


Next:
ESP32-DevKitC + 2.8inch 240x320 SPI TFT (ILI9341) using TFT_eSPI library