Install usb serial driver
Download the latest esp8266 micropython binary.
After driver installation do: '''bash sudo kextload /Library/Extensions/SiLabsUSBDriver.kext ''' Then in security settings on your mac, click allow for the kext (kernel extension) to be activated. I needed this for OS X High Sierra
Optional: Erase the flash of the Wemos D1 with esptool
esptool.py -p /dev/tty.SLAB_USBtoUART erase_flash
Run to install micropython on the Wemos D1 with esptool(install this with pip install esptool):
esptool.py -p /dev/tty.SLAB_USBtoUART write_flash -fm dio -fs 4MB 0 ~/Downloads/esp8266-20171101-v1.9.3.bin
Notice, use 4MB even though the D1 mini pro has more space. I tried 16MB and it failed.
To connect use screen or picocom (when still connected to usb, restart probably required after driver install)
picocom /dev/tty.SLAB_USBtoUART -b115200
Connect to the device (see above) and run
import webrepl_setup
Follow the steps (enable and set a password) and you're done. You can now connect to it via a webinterface (details or use the online (but local browser running) webrepl)
https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/network_basics.html
import network
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)
sta_if.active()
False
ap_if.active()
True
ap_if.ifconfig()
('192.168.4.1', '255.255.255.0', '192.168.4.1', '8.8.8.8')
sta_if.active(True)
sta_if.connect('<your ESSID>', '<your password>')
sta_if.isconnected()
sta_if.ifconfig()
Or put the following in your boot.py(or main.py) so it connects on boot
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('<your essid>', '<your password>')
while not sta_if.isconnected():
pass
print('network config:', sta_if.ifconfig())
connect()
There are two files that are treated specially by the ESP8266 when it starts up: boot.py and main.py. The boot.py script is executed first (if it exists) and then once it completes the main.py script is executed. You can create these files yourself and populate them with the code that you want to run when the device starts up.
Activate Webrepl on the device, instructions
Download the webrepl client and open webrepl.html
So....micropython doesn't use the epoch as it should, but utime.time() shows the seconds since 1-1-2000.
Also the clock seems to drift, so using it every 7,5 hours or using settime is a must. Details
I used the instructions (and files) from here Make sure you have esptool later than 2.3.1 (I used 2.5.1)