ESP32 Workshop 2019

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

  1. Open up the current Arduino IDE.
  2. Go to FilePreferences 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
  3. Open boards manager. Go to Tools > Board > Boards Manager
  4. Search for ESP32 and press install button for the “ESP32 by Espressif Systems
  5. Plug in the board wit a USB cable.
  6. 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)
  7. 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.
  8. 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

( https://www.aliexpress.com/item/TFT-2-4-Touch-Shield-V1-0-0-for-LOLIN-WEMOS-D1-mini-2-4-inch/32919729730.html?spm=2114.12010108.1000013.5.5af963cby6LhkF&gps-id=pcDetailBottomMoreThisSeller&scm=1007.13339.99734.0&scm_id=1007.13339.99734.0&scm-url=1007.13339.99734.0&pvid=ed988c8b-3baf-44b9-bc2e-a6b46454da31 )

  1. Connect the touchscreen to the ESP32 with the supplied cable. It only connects one way
  2. 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.
  3. 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.
  4. 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);
  5. 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

  1. Run File > Examples > (Examples for D32 Lolin Pro) > SPIFFS > SPIFFS_Test
  2. 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.
  3. Note options for static memory in Tools.
  4. 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

  1. 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.
  2. 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

  1. Open up the current Arduino IDE.
  2. Go to FilePreferences 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
  3. Open boards manager. Go to Tools > Board > Boards Manager
  4. Search for ESP32 and press install button for the “esp8266 by ESP8266 Community
  5. Plug in the board wit a USB cable.
  6. 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)
  7. 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.
  8. 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

 

Maker Tech Education