It's worth watching gadgets elektroda.pl because once in a while there will be a LoLin module based on ESP8266. The module can be programmed with the use of Arduino, LUA, MicroPython, the module provides WiFi 802.11b / g / n connectivity, is equipped with a USB UART CH340 converter that allows you to put the code in flash memory (4MB). It is worth reading the previous materials about ESP8266:
- installing drivers for the CH340 converter
- Start with ESP8266, WIFI start, IoT with Blynk and Thingspeak, TMP36 temperature sensor, ESP.deepSleep deep sleep function ()
- ESP8266 and DS18B20
- ESP8266 and SPIFFS - flash file system
LoLin ESP8266 and MicroPython
ESP8266 integrates well with Arduino, but it is also worth trying other possibilities such as MicroPython.
First, install the Python environment on the computer: https://www.python.org/downloads/
Then, using the pip tool, we install esptool .
I used Python 2.7.x but esptool is also compatible with Python 3.4 and above.
If during the installation of Python we have configured the paths (you can check it by issuing the command echo% PATH%), just type in cmd the command:
pip install esptool
More information about the tool here: https://github.com/espressif/esptool
After connecting ESP8266 and determining the port number on which the USB UART converter works, you can test the operation of esptool.
For example for the COM15 port:
esptool.py -p COM15 read_mac
will allow you to read the MAC of the connected ESP8266
esptool.py -p COM15 flash_id
will show information about the module and the size of the flash memory.
Of course, you replace COM15 with the actual port number on which the converter available on the board appeared,
The baud rate can be set using the -b switch, e.g. 115200.
We download and install the firmware as described:
http://docs.micropython.org/en/latest/esp8266...66/tutorial/intro.html#deploying-the-firmware
We choose the last stable firmware:
http://micropython.org/download#esp8266
Erasing the firmware:
esptool.py -p COM15 erase_flash
We put the new firmware:
esptool.py -p COM15 write_flash --flash_size = detect 0 path and download_file_name.bin
We should get a result similar to:
After these actions, by connecting to the speed 115200 using, for example, PuTTY to the COM port on which the converter connected to ESP8266 works, we get REPL (read-eval-print loop) which is the Python interpreter command line.
We can test the operation by entering a code snippet:
print ("Test")
which will display the inscription:
Test
and then we introduce:
import esp
esp.check_fw ()
which will check the integrity of the firmware.
After installing new firmware ESP8266 works in WiFi AP mode, ESSID: MicroPython-xxxxxx where xxxxxx is replaced with MAC part of the device. The WiFi password is: micropythoN, module address: 192.168.4.1.
More on using WiFi in MicroPython can be found here:
https://docs.micropython.org/en/latest/esp8266/library/network.html
We can easily scan available wireless networks nearby:
The way in which we can disable said built-in AP:
During the tests, I noticed a very high sensitivity of ESP in this module, it detected networks that were not seen by e.g. smartphones, it would probably not be possible to connect to these APs, but they were visible on the list.
Buses and sensors in MicroPython
In the online documentation you will find examples of I2C, SPI, DS18B20 temperature sensors:
http://docs.micropython.org/en/latest/esp8266/esp8266/quickref.html
Let's try a code that reads data from a sensor DTH22 , it can be compared with the code used to read the temperature and humidity on the Arduino platform:
Arduino UNO and DTH22 .
Remember to pull up the power supply through the ~ 5.1kom resistor of the AM2302 data sensor (unless it is in the form of a module and there is a resistor on the board connecting the data pin with vcc). We will use the D4 pin to communicate with DTH22, the sensor is connected to ground and the 3.3V power supply on the LoLin board. Pin D4 will correspond to GPIO2, e.g. here you can find pin assignments in typical ESP8266 modules: http://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/
Startup scripts
Issuing commands to the serial console is a good way to test, but the target of the MicroPython code file will be in a file stored in flash memory. The startup files will allow the execution of specific code after the module is powered.
It's worth getting a helpful tool called Adafruit ampy :
https://github.com/adafruit/ampy
Just like when installing esptool in cmd on PC, we issue the command:
pip install adafruit-ampy
We test:
ampy -p COM15 ls
We have various commands at our disposal: ls list files, get display a file, put put, and rm delete a file.
There is a file in the flash memory boot.py performed after startup, let's see what its content is:
ampy -p COM15 get boot.py
We will get something like:
Let's create a file on the PC main.py which, when copied to flash on ESP8266, will run after each module is powered right after boot.py is done,
for example, it will be a code in the loop reading temperature and humidity from the DTH22 sensor and displaying the data in the serial console.
We precede everything under "while True" with a tab.
We save the file in a specific location on the PC.
We put the file in flash memory:
ampy -p COM15 put path \ main.py
After restarting the module in the serial console, we will see the effect of main.py

You can find many interesting examples of ESP8266 and MicroPython connection, e.g .:
Weather station collecting data from the DTH22 sensor and the BMP180 pressure sensor.
A weather station that downloads data from the internet.
What ideas do you have for using MicroPython and LoLin board based on ESP8266?
What kind of working environment with ESP8266 do you prefer MicroPython, Arduino or maybe LUA?
- installing drivers for the CH340 converter
- Start with ESP8266, WIFI start, IoT with Blynk and Thingspeak, TMP36 temperature sensor, ESP.deepSleep deep sleep function ()
- ESP8266 and DS18B20
- ESP8266 and SPIFFS - flash file system
LoLin ESP8266 and MicroPython
ESP8266 integrates well with Arduino, but it is also worth trying other possibilities such as MicroPython.
First, install the Python environment on the computer: https://www.python.org/downloads/
Then, using the pip tool, we install esptool .
I used Python 2.7.x but esptool is also compatible with Python 3.4 and above.
If during the installation of Python we have configured the paths (you can check it by issuing the command echo% PATH%), just type in cmd the command:
pip install esptool
More information about the tool here: https://github.com/espressif/esptool
After connecting ESP8266 and determining the port number on which the USB UART converter works, you can test the operation of esptool.
For example for the COM15 port:
esptool.py -p COM15 read_mac
will allow you to read the MAC of the connected ESP8266
esptool.py -p COM15 flash_id
will show information about the module and the size of the flash memory.
Of course, you replace COM15 with the actual port number on which the converter available on the board appeared,
The baud rate can be set using the -b switch, e.g. 115200.
We download and install the firmware as described:
http://docs.micropython.org/en/latest/esp8266...66/tutorial/intro.html#deploying-the-firmware
We choose the last stable firmware:
http://micropython.org/download#esp8266
Erasing the firmware:
esptool.py -p COM15 erase_flash
We put the new firmware:
esptool.py -p COM15 write_flash --flash_size = detect 0 path and download_file_name.bin
We should get a result similar to:
Code: Text
After these actions, by connecting to the speed 115200 using, for example, PuTTY to the COM port on which the converter connected to ESP8266 works, we get REPL (read-eval-print loop) which is the Python interpreter command line.
We can test the operation by entering a code snippet:
print ("Test")
which will display the inscription:
Test
and then we introduce:
import esp
esp.check_fw ()
which will check the integrity of the firmware.
After installing new firmware ESP8266 works in WiFi AP mode, ESSID: MicroPython-xxxxxx where xxxxxx is replaced with MAC part of the device. The WiFi password is: micropythoN, module address: 192.168.4.1.
More on using WiFi in MicroPython can be found here:
https://docs.micropython.org/en/latest/esp8266/library/network.html
We can easily scan available wireless networks nearby:
Code: Python
The way in which we can disable said built-in AP:
Code: Python
During the tests, I noticed a very high sensitivity of ESP in this module, it detected networks that were not seen by e.g. smartphones, it would probably not be possible to connect to these APs, but they were visible on the list.
Buses and sensors in MicroPython
In the online documentation you will find examples of I2C, SPI, DS18B20 temperature sensors:
http://docs.micropython.org/en/latest/esp8266/esp8266/quickref.html
Let's try a code that reads data from a sensor DTH22 , it can be compared with the code used to read the temperature and humidity on the Arduino platform:
Arduino UNO and DTH22 .
Remember to pull up the power supply through the ~ 5.1kom resistor of the AM2302 data sensor (unless it is in the form of a module and there is a resistor on the board connecting the data pin with vcc). We will use the D4 pin to communicate with DTH22, the sensor is connected to ground and the 3.3V power supply on the LoLin board. Pin D4 will correspond to GPIO2, e.g. here you can find pin assignments in typical ESP8266 modules: http://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/
Code: Python
Startup scripts
Issuing commands to the serial console is a good way to test, but the target of the MicroPython code file will be in a file stored in flash memory. The startup files will allow the execution of specific code after the module is powered.
It's worth getting a helpful tool called Adafruit ampy :
https://github.com/adafruit/ampy
Just like when installing esptool in cmd on PC, we issue the command:
pip install adafruit-ampy
We test:
ampy -p COM15 ls
We have various commands at our disposal: ls list files, get display a file, put put, and rm delete a file.
There is a file in the flash memory boot.py performed after startup, let's see what its content is:
ampy -p COM15 get boot.py
We will get something like:
Code: Text
Let's create a file on the PC main.py which, when copied to flash on ESP8266, will run after each module is powered right after boot.py is done,
for example, it will be a code in the loop reading temperature and humidity from the DTH22 sensor and displaying the data in the serial console.
Code: Python
We precede everything under "while True" with a tab.
We save the file in a specific location on the PC.
We put the file in flash memory:
ampy -p COM15 put path \ main.py
After restarting the module in the serial console, we will see the effect of main.py

You can find many interesting examples of ESP8266 and MicroPython connection, e.g .:
Weather station collecting data from the DTH22 sensor and the BMP180 pressure sensor.
A weather station that downloads data from the internet.
What ideas do you have for using MicroPython and LoLin board based on ESP8266?
What kind of working environment with ESP8266 do you prefer MicroPython, Arduino or maybe LUA?
