In the summer of 2019 I am evaluating development boards to use in my Intro to Rapid Prototyping course. As part of this effort I took a hard look at the ESP32-based Lolin D32 Pro with a touchscreen.
The following are materials I initially used in a presentation/workshop for the Columbus Arduino Raspberry Pi Enthusiasts Meetup on my research.
Description of the Meetup session:
The ESP Series of Systems on a Chip for Prototyping IoT devices
Bill Ball will give an overview and bring examples of the ESP series of SoCs by Espressif mounted on development boards. Implementations of the ESP32 & ESP8266 offer the means to quickly learn and prototype connected hardware at low cost using a variety of programming environments, languages, and attached peripherals. Bill’s current focus is on evaluating the Lolin D32 Pro implementation of the ESP32 as the basis for learning micro-controllers in a rapid prototyping class.
Slides from the presentation portion as a PDF file
Demo instructions from the workshop portion
Basic set up for the Wemos/Lolin D32 Pro (https://wiki.wemos.cc/products:d32:d32_pro) on Arduino
- Open up the current Arduino IDE.
- Go to File> Preferences and add the following:
https://dl.espressif.com/dl/package_esp32_index.json into the “Additional board Manager URLs and click OK (use commas as separators if you already have additional board managers - Open boards manager. Go to Tools > Board > Boards Manager
- Search for ESP32 and press install button for the “ESP32 by Espressif Systems“
- Plug in the board wit a USB cable.
- Specify the board and port. Select Tools > Board > LOLIN D32 PRO. A conservative upload speed is a good place to start. Select Tools > Upload Speed > 115200 (your USB cable may be capable of a much faster speed), Leave the other settings as default. Select the USB port (COMx on Windows, maybe /dev/cu.wchusbserial410 on Mac)
- Run Blink. Select File > Examples > 01.Basics > Blink. Select the run arrow to compile, download, and run. You should get a blue LED blinking once per second.
- If you cannot connect and need USB drivers for the CH340 chip on this board you can find them here: https://wiki.wemos.cc/downloads
Add support for the TFT & touchscreen
- Connect the touchscreen to the ESP32 with the supplied cable. It only connects one way
- This screen uses a ILI9341 driver IC for the display and a
XPT2046 controller for the touchscreen. Adafruit’s libraries are a good place to start for this hardware, although there are faster drivers for the ILI9341 controller available. - Download the Adafruit libraries if you’re a conformist. They are available on Github but you can also install them from the Arduino IDE. Select Tools > Manage Libraries. Search for and install Adafruit IlI9341 and Adafruit GFX Library. If you want speed download and install the TFT_eSPI by Bodner library as well. You will see other libraries available for the ESP32 + ILI9341.
- From the Adafruit libraries, a good first test is the File > Examples > (Examples from Custom Libraries) Adafruit GFX Library > mock_ili9341 sketch. You will have to comment out (//) lines 22, 23, and 26, and change line 28 to the following to work with this board: Adafruit_ILI9341 tft = Adafruit_ILI9341(14, 27, 23, 18, 33, 19);
- For a much faster and simpler to set up example try File > Examples > (Examples from Custom Libraries) TFT_eSPI > 320×240 > TFT_graphicstest_PDQ. Note that no pin assignments need to be changed, just load the sketch and run it.
Try the SPIFFS (SPI Flash File System) for storing files in static memory
- Run File > Examples > (Examples for D32 Lolin Pro) > SPIFFS > SPIFFS_Test
- Open Tools > Serial Monitor to see results. The baud rate in the serial monitor will have to match line 158 in the script: Serial.begin(115200); A lower baud rate can be used in both.
- Note options for static memory in Tools.
- The esp8266fs tool, available here: https://github.com/esp8266/arduino-esp8266fs-plugin can be used to load files into static memory without having to put them directly in your sketch.
Try the touch screen
- A simple example can be found here: https://github.com/wemos/D1_mini_Examples/blob/master/examples/04.Shields/TFT_2.4_Touch_Shield/TFT_TouchTest/TFT_TouchTest.ino. The correct pin definitions will need to be used for the D32 Pro.
- A better illustration of the possibilities can be found in File > Examples > (Examples from Custom Libraries) TFT_eSPI > 320×240 > Keypad_240x320. However before that example will work you will need to replace line 134 //#define TOUCH_CS PIN_D2 with #define TOUCH_CS PIN_D12 in the User_Setup.h file found in the Arduino > libraries > TFT_eSPI folder.
Try an esp8266-based board
- Open up the current Arduino IDE.
- Go to File> Preferences and add the following:
https://arduino.esp8266.com/stable/package_esp8266com_index.json into the “Additional board Manager URLs and click OK (use commas as separators if you already have additional board managers - Open boards manager. Go to Tools > Board > Boards Manager
- Search for ESP32 and press install button for the “esp8266 by ESP8266 Community“
- Plug in the board wit a USB cable.
- Specify the board and port. Select Tools > Board > (the board you’re using). A conservative upload speed is a good place to start. Select Tools > Upload Speed > 115200 (your USB cable may be capable of a much faster speed), Leave the other settings as default. Select the USB port (COMx on Windows, maybe /dev/cu.wchusbserial410 on Mac)
- Run Blink. Select File > Examples > 01.Basics > Blink. Select the run arrow to compile, download, and run. You should get a blue LED blinking once per second.
- If you cannot connect and need USB drivers for the CH340 chip on this board you can find them here: https://wiki.wemos.cc/downloads