Pages

Thursday, 16 August 2018

MicroPython on ESP32 WROVER


I just received the new Wemos/Lolin D32 Pro board in the post. The board is based on the Espressif ESP32-WROVER which is a step upgrade of the ESP32-WROOM with the addition of 4MB SPI PSRAM. Since I purchased this board Espressif have released a newer module with the addition of 8MB SPI PSRAM so shortly expect to see boards based on the newer module.


ESP32 based boards are a significant upgrade compared to the ESP8266. They contain a dual core processor, Wi-Fi and Bluetooth wireless connectivity, 36 GPIO pins with support for a large range of peripheral interfaces, cryptographic acceleration, and low power operation. In addition to the processor module the Wemos board features on-board I2C and TFT ports, Lithium battery interface with charging circuit, micro SD card slot, and a micro USB connection for power and communication, all in a board for under $10.

The default firmware on the board is a current version of MicroPython. Since I am running Windows 10 I first needed to install the CH340G driver which will allow USB to serial communication to the board with the use a micro USB cable. Once the USB cable is connected, power is supplied to the board and a serial COM port should appear on in your Windows device manager.


Using your terminal program of choice (Putty, Arduino Serial Monitor, etc) with baud rate set to 115200 you will be able to connect to the ESP32 board and should be presented with the standard >>> Python REPL prompt. Pressing the Wemos board reset button located beside the micro USB connector will reset the board and output some board information along with the MircoPython version installed. Typing help() at the REPL provides some basic information on the MicroPython 'machine' module used to access the hardward, Wi-Fi configuration, and control commands. 

You will soon want a way to transfer files between your computer and the MicroPython board. Two popular options are Adafruit ampy and rshell. Both require Python 3 installed on your computer. Adafruit ampy was the easiest to get up and running. I was unable to get rshell running on Windows 10 and also ran into some problems using it on Windows subsystem for Linux. I need to spend a little time troubleshooting this as it does appear to be a very useful tool.

Once install, typing ampy --help from the command prompt provides command syntax. To return the contents of a directory on the MicroPython board use ampy -p COM4 ls which should return boot.py. To transfer a simple Python blink script to the board use ampy -p COM4 put blink.py and run it with ampy -p COM4 run blink.py

The MicroPython board filesystem root contains two important files:
  • /boot.py is run when the board is powered on or reset. Generally it is not edited and should only be used to setup board configuration.
  • /main.py is an optional file and is run after boot.py. This file can be used to start your application script after power on. Simply calling ampy with addition board target filename can have your blink script run automatically at power on ampy -p COM4 put blink.py /main.py.
Next I need to refresh my knowledge of Python and familiarise myself with the MicroPython hardware 'machine' module.


1 comment:

  1. Thank you for having the only photo on the internet that shows how the SD card sticks out!

    ReplyDelete