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 card 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 card 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 map 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.
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.
What is MicroPython?
MicroPython 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 card. The project met with immediate success. Today, the PyBoard is a complete development card family that you can buy from the online store. You buy the PyBoard cards, you participate in the support of the project.
Only available for PyBoard, MicroPyton was later worn for other micro-controllers and therefore other card manufacturers. MicroPython is now available for ESP8266, ESP32, WiPy cards, STM32 (STM32F4) cards, Nucleo cards and Espruino Pico cards. To download the firmware that corresponds to your card, 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 card. 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 card (ttyUSB0) and USB converter / serial used by the card (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