Unpacking the Wemos ESP32 Lolin32 Lite, testing the firmware MicroPython with a Raspberry Pi 3

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp
Table of Contents

A few weeks ago, Wemos launched its Lolin32 Lite based Espressif ESP32 module. The ESP32 used is the REV1 which corrects some bugs. It is a very compact development board (50*25.5*6.5 mm) compatible with the 2.54mm pitch of the breadboards. It is as narrow as the Wemos d1 mini (based on ESP8266) which allows to have a row of pins on each side of the board for wiring. The LoLi32 Lite is equipped with a standard LiPo battery connector standard PH-2 2.0mm. By default, the firmware MicroPython is pre-installed. This is an opportunity to discover this firmware. To learn more about the MicroPython firmware project, visit the official page here. The Wemos LoLin32 Lite is only sold by Wemos at its official AliExpress store. It costs $4.90 € (+ shipping costs).

Unpacking the Wemos LoLin32 Lite ESP32

I took advantage of the 11.11 sales to order a LoLin32 on AliExpress. Wemos practices very good prices on these development boards. There was no discount (not for Black Friday for that matter). The LoLin32 Lite is shipped in a simple bubble envelope. She arrived in 12 days, which is very correct as the end of year holidays approach. Wemos has a very well organized shipping service. The board arrives packed in an anti-static bag with a label in the name of the buyer. Unlike the Wemos d1 mini, the LoLin32 Lite comes with only one type of male connector (13 pins). As the board is narrow, we have a row of pins on each side on a breadboard. It is quite easy to find connectors with a male and female side on AliExpress or Banggood if needed.

wemos lolin32 lite test mircopython

LiPo battery with PH-2 2.0mm 2-pin connector, classic for drones and RC

This is a recurring problem with LiPo battery connectors used by development board manufacturers. For LoLin32, Wemos uses a JST 2.0 PH 2-Pin connector. I took the time to look for the full designation because it is still a problem. Luckily, you can easily find cables that can be used to modify a battery pack or a LiPo battery. Be careful not to reverse the polarity!

The JST 2.0 PH 2-Pin connector is widely used in RC toys and mini drones. It is often found on Hubsan or Eachine drones, for example. This is good news because it will also be very easy to find compatible batteries without having to hack. Only regret, it will be difficult to find batteries beyond 1200 mAh. A big advantage of the ESP32 being its very low consumption, it should not be too much problem. It remains to optimize the code to put the module to sleep and limit the sending of data to save the battery.

batterie lipo jst ph 2p

What is MicroPython?

logo micropythonMicroPython is a rewrite (implementation) of the Python language adapted to micro-controllers. It is an open source project launched by Damien George. The source code is available on GitHub here. This project initiated in 2013 was accompanied by a crowdfunding campaign on Kickstarter to launch the PyBoard development board. The project met with immediate success. Today, the PyBoard is a complete development board family that you can buy from the online store. You buy the PyBoard boards, you participate in the support of the project.

Only available for PyBoard, MicroPyton was later worn for other micro-controllers and therefore other board manufacturers. MicroPython is now available for ESP8266, ESP32, WiPy boards, STM32 (STM32F4) boards, Nucleo boards and Espruino Pico boards. To download the firmware that corresponds to your board, go to this page.

As its name suggests, we will code in Python instead of the usual C ++ or Lua code. Of course, not all Python instructions are available. Only commands that are useful for micro-controllers have been brought. All the commands are available on the online documentation.

MicroPython works with a file system or command interpreter called Read-Eval-Print Loop (REPL) available from a serial connection or from an internet browser (this will be WebREPL). It is convenient to test, discover the language and do maintenance operations (file management, connection to a WiFi network …).

For programming, we will use a simple text editor to write the scripts. Then simply copy the files on the board. Of course, it’s a very succinct presentation of MicroPython. We will discover it much better in the next tutorials.

For this first discovery, we will use a Raspberry Pi 3. We will see how to do Windows 10 in the next article). Here is a short video that introduces the concept quickly

MicroPython Test with Wemos LoLin32 Lite

Wemos delivers the LoLin32 Lite with MicroPython. This is the first time that Wemos has abandoned the NodeMCU firmware. It may be necessary to see a lack of interest in Lua language by the Makers. It is true that the impressive number of libraries and examples Arduino leaves little chance to other languages.

For this first tutorial, I suggest you start with the Raspberry Pi. Open a Terminal or connect to SSH from another computer. Connect the LoLin32 Lite to the USB port and run the following command to identify the USB port on which the ESP32 has just been plugged

dmesg | grep ttyUSB
[5253941.605452] usb 1-1.2: ch341-uart converter now attached to ttyUSB0

We therefore know the USB port on which is connected the board (ttyUSB0) and USB converter / serial used by the board (CH341). It’s no secret that the controller is visible next to the micro-USB connector.

Install Python3, pip3 and rshell to communicate with MicroPython firmware

There are several ways to access the Python command interpreter (REPL). After having tested several, I find that the most reliable is rshell (GitHub page). rshell was developed in Python3, so we will install it and pip3 which will be used to install rshell

sudo apt-get -y install python3
sudo apt-get -y install python3-pip
sudo pip3 install rshell

That’s it, all you have to do is connect to the LoLin32 Lite using the following command

rshell --buffer-size = 30 -p /dev/ttyUSB0

The serial connection is established immediately. If it is not, press the RESET button on the board and start again.

Connecting to / dev / ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.

Run the boards command to identify the connected adapter and the files present. As you can see, only the boot.py file is responsible for managing the boot of the board. We can also see the file system that is able to manage a tree.

/home/pi> boards
pyboard @ /dev/ttyUSB0 connected Dirs: /boot.py

First MicroPython script

Nothing better than an example to understand how the system works. Open a new Terminal (or SSH connection). Go to the /home/pi folder (cd /home/pi ) and open a new file with the command nano blynk.py and paste the following code. This little script will just flash an LED connected to pin 19 of the ESP32.

import utime
import machine
pin19 = machine.Pin(19, machine.Pin.OUT)
while True:

Record with the key combination CTRL + X then Y (En) or O (Fr)

rshell does not support all Linux commands, such as nano.

Transfer and test the MicroPython script

From the rshell Terminal, we will copy the python script on the LoLin32 with the Linux cp command. The command ls followed by the board /pyboard allows to list the files present on the board

cp blynk.py /pyboard
ls /pyboard
blynk.py boot.py

Perfect, just have to test!

Test the REPL interpreter

From the rshell Terminal, execute the REPL command to launch the MicroPython command interpreter. It is symbolized by the >>> prompt

/home/pi> repl
Entering REPL. Use Control-X to exit.
MicroPython v1.9.2-443-g236297f4 on 2017-11-24; ESP32 module with ESP32
Type "help()" for more information.

To launch our script, we use the command import followed by the name of the script without the extension (py)

>>> import blynk

If there are no errors (code and wiring), the LED flashes immediately. Awesome ! To stop the script, use the CTRL + C combination. If the LED has remained lit, this is an opportunity to test the command interpreter to turn it off. Run the following lines one after the other.

How to start a script automatically when connecting the board?

The microPython firmware automatically launches the main.py script at power up. It’s easy, just rename the blynk.py script to main.py. This is an opportunity to play with the file system using REPL. We will import the OS module that contains all the file management commands (the documentation is here). Let’s start by listing the files

>>> import os
>>> os.listdir()
['blynk.py', 'boot.py']

The rename command allows you to rename a file. We must put in quotation marks (‘) to avoid any error

>>> os.rename('blynk.py','main.py')
>>> os.listdir()
['boot.py', 'main.py']

Now press the RESET button on the board. A start-up report is displayed on the Terminal and the LED flashes immediately now!

>>> ets Jun  8 2016 00:22:57

configsip: 0, SPIWP:0xee
mode:DIO, clock div:2
entry 0x4007a6c4
W (65) rtc_clk: Potentially bogus XTAL frequency: 35 MHz, guessing 40 MHz
I (360) cpu_start: Pro cpu up.
I (360) cpu_start: Single core mode
I (361) heap_init: Initializing. RAM available for dynamic allocation:
I (364) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (370) heap_init: At 3FFDCD60 len 000032A0 (12 KiB): DRAM
I (376) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (382) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (389) heap_init: At 4008FC7C len 00010384 (64 KiB): IRAM
I (395) cpu_start: Pro cpu start user code
I (189) cpu_start: Starting scheduler on PRO CPU.

As we are still connected to REPL, we can stop the execution of the main.py script with the CTRL + C combination. By cons, I have not yet found the command that can disconnect from REPL. You have to close the terminal for that.

wemos lolin32 test mircotyphon blynk led

Here, MicroPython is really a very simple language to take in hand, especially if you already have some notions in Python. If you have simple connected objects to realize (DHT22, accelerometer, servo motors, I2C sensors, PWM), MicroPython is a very interesting alternative to C++ and the Arduino IDE. You will see that on Windows, it’s even easier.

WEMOS LOLIN32 Lite V1.0.0-wifi & bluetooth conseil basé ESP-32 esp32 Rev1 MicroPython...
CHF 4.62
Buy this item
aliexpress.com Aliexpress
Eachine VR006 3.7V 500mAh LiPo Battery JST-PH 2.0mm 2P Connector
CHF 7.99
-12% Python: For Beginners: A Crash Course Guide To Learn Python in 1...
$15.70 $17.97 4 used from $10.92
Buy this item
amazon.com Amazon.com
Eachine EV800D 7.4V 1200mAh LiPo Battery with JST-PH 2.0mm 2P Connector
CHF 18.99
Click to rate this post!
[Total: 0 Average: 0]

Thanks for your reading

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
  1. Very nice articles. Any reason you use HTTP with Domoticz and not MQTT?

    • Hi Richard. Both solutions are good. The goal of the tutorial was to mount how to do with HTTP requests. You’re absolutely right, we can do the same thing with MQTT. On the other hand it requires to install an MQTT server. As I tried to make home automation as accessible as possible, I preferred to use HTTP. See you soon. Have a good holiday season: D

    Leave a Reply

    Read more
    Recent posts on the Forum
    DIY Projects
    DIY Projects
    %d bloggers like this: