ESP8266 MicroPython Demo
MicroPython demo on NodeMCU with ESP8266 (WiFi). Fake temperature data will be posted to API every 10 seconds.
用 Python 玩硬體:MicroPython 簡介與實作
Setup NodeMCU & Tools
- Install tools
- Deploy firmware
- Plug in the device
- Get port name of device:
$ ls /dev/tty.*
- Download firmware from MicroPython downloads page
- Deploy:
$ esptool.py --port <port-name> write_flash --flash_size=detect 0 <firmware-file>
Usage
- Create an API for posting data, e.g. Firebase
- Copy
config.py.template
toconfig.py
, replace the placeholders with real values- WiFi SSID and password
- API (can replace the whole string with your own url if not using Firebase)
- Upload code
- Get port name of device:
$ ls /dev/tty.*
- Upload code to board:
$ ampy --port <port-name> put boot.py main.py config.py
- Get port name of device:
- Reset NodeMCU, i.e. press the reset button, the LED will flash after release;
main.py
will run, data sent at 10 sec interval - Check API console for the data posted; the LED will also flash after each data upload