Wemos D1 Mini - Configuring boot.py

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
blckpstv
Posts: 23
Joined: Thu Dec 15, 2016 9:11 pm
Location: Belgium

Wemos D1 Mini - Configuring boot.py

Postby blckpstv » Tue Jan 10, 2017 11:24 am

Hi,

I've finally managed to install the micropython platform on the wemos D1 Mini. Now I'm following the micropython docs. When I do os.listdir() I only get the boot.py file. Not the main.py as shown in the docs. Is this second file necessary?

Follwing on that small note/question. How do I change the boot.py in minicom on mac to add following start up script.

Code: Select all

def do_connect():
    import network
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect('<essid>', '<password>')
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())


I get this in return when trying to open('boot.py') >>> <io.TextIOWrapper 3fff14c0>

User avatar
deshipu
Posts: 795
Joined: Thu May 28, 2015 5:54 pm

Re: Wemos D1 Mini - Configuring boot.py

Postby deshipu » Tue Jan 10, 2017 1:42 pm

The "main.py" is not created by default, but if you do create it, it will get executed at startup. It's for starting your application.

I like to use Adafruit's "ampy" tool for uploading (and downloading) files from the board. You can get the boot.py file to your computer, edit it with a text editor, and put it back on your board. You can also use mpfshell or the webrepl for uploading the files.

blckpstv
Posts: 23
Joined: Thu Dec 15, 2016 9:11 pm
Location: Belgium

Re: Wemos D1 Mini - Configuring boot.py

Postby blckpstv » Tue Jan 10, 2017 7:23 pm

Hi, I used the ampy and installed it succesfully. But when trying to connect to my board I get.

Code: Select all

ampy --port /dev/cu.wchusbserial1420 ls
Traceback (most recent call last):
  File "/usr/local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1063, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/ampy/cli.py", line 70, in cli
    _board = pyboard.Pyboard(port, baudrate=baud)
  File "/usr/local/lib/python2.7/site-packages/ampy/pyboard.py", line 143, in __init__
    raise PyboardError('failed to access ' + device)
ampy.pyboard.PyboardError: failed to access /dev/cu.wchusbserial1420

User avatar
deshipu
Posts: 795
Joined: Thu May 28, 2015 5:54 pm

Re: Wemos D1 Mini - Configuring boot.py

Postby deshipu » Tue Jan 10, 2017 9:35 pm

You have to close the other program using the serial. Only one program can use it at a time.


Return to “ESP8266 boards”

Who is online

Users browsing this forum: No registered users and 3 guests