I have been messing around with a Wemos Lolin32 ESP32 module that I recently bought on ebay for a few bucks. I'm not totally sure what I am going to do with it yet, but it looks awesome for easy IoT home automation. I have had some early successes after some difficulty so I wanted to share my methods and results on Mac OS x.
Unfortunately, the Lolin32 module I bought was not pre-loaded with the AT command interpreter that seems to be standard. I ended up with 2 different ESP32 boards from separate ebay sellers which seem to be pre-loaded with only a simple test program. The manufacturer of both of them seems to be "TTGO". Anyway, it is definitely something to be aware of if you don't want to be doing a lot of programming and flashing just to get the AT command interpreter for an internet modem. Fortunately, Espressif Systems, the company that manufactures the ESP32, has done an excellent job of providing development tools and open sourced software for the chip. It is nice to see great macOS support from this company. Most Chinese manufacturers seem to focus on Windows only and maybe Linux.
Things you need to install for building and testing the AT command terminal:
- ESP32 Development Framework
- SIL2104 MacOS drivers(for flashing and debug console)
- Another USB to TTL adapter, or a USB to RS232 with an RS232 to TTL adapter, with appropriate drivers (for the AT command terminal interface).
If you have the CJMCU FT232H (or FTDI UM232H(-B), or Adafruit FT232H breakout), like I am using on my Apple II Disk emulator, connect it to the ESP32 module like this (we don't really need CTS/RTS yet, though):
ESP32 signal | ESP32 GPIO# (Lolin32 labels) | FT232H (CJMCU labels) |
---|---|---|
RX | 16 | AD0 |
TX | 17 | AD1 |
RTS | 14 | AD2 |
CTS | 15 | AD3 |
Follow the instructions for flashing the AT command firmware. Basically: git clone --recursive https://github.com/espressif/esp32-at.git $ cd esp32-at $ make menuconfig In the menu that appears, set:
- erial flasher config
- to: efault serial port
- /dev/cu.SLAB_USBtoUART
$ make
$ make erase_flash
$ make flash
Along the way, you may get errors about some python modules that are missing. To resolve these, just install the listed package...
$ sudo pip install pyyaml xlrd
... and re-run the command with the error.
The first time I ran everything, I was getting brown-out errors in the debug console. I changed USB cables and did not have any further power problems.
The biggest issue I had was actually communicating with the AT command terminal using the "screen" command in macOS. No matter what I typed, the ESP32 would echo, but not respond. The basic problem had to do with line endings. Using miniterm.py rather than screen solved the problem, but a adding bindkey "\015" stuff "\015\012"
to the ~/.screenrc file also worked. I couldn't get the stty screen commands like onlret or onlcr to work correctly.
Or, you can configure the ESP32 to use <CR> line ending, like it should have:
$ make menuconfig- omponent config
- T
- enable: T command terminator support.
- set : to: T command terminator.
- 0x0D
Once everything is connected and built, you can connect to the device with:
$ screen /dev/cu.usbserial 115200,cs8,-parenb,-cstopb
or:
$ miniterm.py /dev/cu.usbserial 115200
Of course, you may need to add a numeric extension after "cu.usbserial", depending in what is in your /dev/ folder.
Quick ESP32 AT Trouble-Shooting Guide | ||
---|---|---|
Issue | Likely Cause | Solution |
Garbage characters received from ESP32 | Incorrect Baud rate | set terminal baud rate to 115200, or the same rate specified in make menuconfig. |
Typed characters do not appear in terminal | Incorrect RX/TX connections | verify that wires to ESP32 UART1 are not crossed and have continuity |
Typed characters appear in terminal, but no response from ESP32 | Incorrect line endings from terminal | Use miniterm.py, or modify ESP32 settings with make menuconfig, or modify screen bindkey settings in ~/.screenrc |
Typed characters appear in terminal, but still no response from ESP32 | ESP32 is hung from previous incorrect line endings | Reset ESP32 |
So, after all of that I am to the standard default set-up that most people get already installed.