MircoPython

MircoPython

This page is to Setup and Config MircoPython

Hardware and Software

Hardware : ESP32, ESP8266 and Arduino

Software :

MircoPython :http://micropython.org/

Notes

  • Master Page : http://micropython.org/

  • Firmware : http://micropython.org/download

  • Document : http://docs.micropython.org/en/latest/index.html

  • Setup RELP : https://docs.micropython.org/en/latest/esp8266/tutorial/repl.html#using-the-repl

    • import webrepl_setup

ampy : Shell Upload and Download Script and any file format into ESP32

  • pip install ampy

  • ampy --port COM3 put <filename> : upload

  • ampy --port COM3 run <filename> : upload and run

  • ampy --port COM3 get <filename> : download and list on screen

  • ampy --port COM3 get <filename> C:\<filename> : download and save into local dir

  • ampy --port COM3 rm <filename> : delete file

  • ampy --port COM3 ls : List All file on ESP device

ERROR ampy :

  • ERROR ---------------------

    • File "c:\users\sanki\appdata\local\programs\python\python37-32\lib\site-packages\ampy\pyboard.py", line 192, in enter_raw_repl

    • raise PyboardError('could not enter raw repl')

    • ampy.pyboard.PyboardError: could not enter raw repl

  • SOLVE ------------------------ reference : http://marsdiy.blogspot.com/2018/06/nodemcumircopythoncould-not-enter-raw.html

    • open and edit file from : C:\Users\sanki\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ampy\pyboard.py

    • Around Line 191 : add time.sleep(2)

    • while n > 0:

    • self.serial.read(n)

    • n = self.serial.inWaiting()

    • time.sleep(2)

    • self.serial.write(b'\r\x01') # ctrl-A: enter raw REPL

Setup webrepl : Web upload and download by HTML

  • Setup webrepl on esp32

    • >>> import webrepl_setup

      • MicroPython v1.8.6-7-gefd0927 on 2016-11-10; ESP module with ESP8266

      • Type "help()" for more information.

      • >>> import webrepl_setup

      • WebREPL daemon auto-start status: disabled

      • Would you like to (E)nable or (D)isable it running on boot?

      • (Empty line to quit)

      • > E

      • To enable WebREPL, you must set password for it

      • New password: srccodes

      • Confirm password: srccodes

      • Changes will be activated after reboot

    • Would you like to reboot now? (y/n) y

    • Check essid :

      • MicroPython v1.8.6-7-gefd0927 on 2016-11-10; ESP module with ESP8266

      • Type "help()" for more information.

      • >>> import network;

      • >>> ap = network.WLAN(network.AP_IF);

      • >>> print(ap.config('essid'));

      • MicroPython-d0fa00

      • >>>

      • Setup ESSID :

        • MicroPython v1.8.6-7-gefd0927 on 2016-11-10; ESP module with ESP8266

        • Type "help()" for more information.

        • >>> import network;

        • >>> ap = network.WLAN(network.AP_IF);

        • >>> ap.active(True);

        • >>> ap.config(essid='MyESP8266', authmode=network.AUTH_WPA_WPA2_PSK, password='mypassword');

        • >>> print(ap.config('essid'));

        • MyESP8266

        • >>>

      • Start and Open webrepl web

        • Install WebREPL client and run program over WIFI

          1. Download the WebREPL client from https://github.com/micropython/webrepl/archive/master.zip and unzip the same.

          2. Disconnect USB to Serial converter from computer.

          3. Connect computer to the WIFI access point of ESP8266.

          4. open webrepl.html in folder

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Examples

ssd1306 Example

  • copy library on Device (e.g. https://github.com/adafruit/micropython-adafruit-ssd1306)

Examples

EXample