Files
esp8266_bms/Micropython_install.md
2022-08-05 12:18:05 +02:00

1.9 KiB

Installation of Micropython .bin on a ESP8266

Before we can program and use a ESP8266 with python, we need to flash the firmware to MP - a Mirco Python environment especially designed for these microprocessors

We need to dowload the latest MP binary. At the time of writing:

wget https://micropython.org/resources/firmware/esp8266-1m-20220618-v1.19.1.bin

Then, we need to flash the software to the microcontroller. A script that helps us with this task is called esptool.py which can be downloaded from HERE:

esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect -fm dout 0 esp8266-1m-20220618-v1.19.1.bin 
    esptool.py v2.4.1
    Serial port /dev/ttyUSB0
    Connecting......
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: 80:7d:3a:7f:51:2a
    Uploading stub...
    Running stub...
    Stub running...
    Changing baud rate to 460800
    Changed.
    Configuring flash size...
    Auto-detected Flash size: 1MB
    Flash params set to 0x0320
    Compressed 591476 bytes to 392427...
    Wrote 591476 bytes (392427 compressed) at 0x00000000 in 32.3 seconds (effective 146.3 kbit/s)...
    Hash of data verified.

    Leaving...
    Hard resetting via RTS pin...

We need urequests as well. This is no longer the stnadard in the mikropython default package:

https://raw.githubusercontent.com/micropython/micropython-lib/master/python-ecosys/urequests/urequests.py

Copy the files into the ESP with the help of ampy. Adafruit ampy that is. You can get it on arch linux / Manjaro distributions with

yay -S aur/adafruit-ampy

Now the files to be copied:

ampy -p /dev/ttyUSB0 put urequests.py
ampy -p /dev/ttyUSB0 put boot.py
ampy -p /dev/ttyUSB0 put main.py
ampy -p /dev/ttyUSB0 put inet.conf

Hopefully. Done.