Skip to content

Instantly share code, notes, and snippets.

@wbchn
Created October 27, 2016 02:34
Show Gist options
  • Save wbchn/4132a45566786badfa79b320b5d7a673 to your computer and use it in GitHub Desktop.
Save wbchn/4132a45566786badfa79b320b5d7a673 to your computer and use it in GitHub Desktop.
micropython in esp8266
# using D1 mini for example:
## Firmware
'''
esptool.py --port /dev/ttyUSB0 erase_flash
make PORT=/dev/ttyUSB0 FLASH_MODE=dio FLASH_SIZE=32m deploy
minicom -D /dev/ttyUSB0 -b 115200
'''
## Wifi
import network
sta_if = network.WLAN(network.STA_IF);
sta_if.active(True)
sta_if.scan() # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected() # Check for successful connection
## AP
ap_if = network.WLAN(network.AP_IF)
ap_if.config(essid="embed", authmode=network.AUTH_WPA_WPA2_PSK, password="88888888")
## RTC
rtc = machine.RTC()
# There's currently no timezone support in MicroPython !!!
# (year, month, day, weekday, hour, minute, second, millisecond)
# put 0 in weekday, it will be calculated correctly.
rtc.datetime((2016, 10, 27, 0, 9, 59, 0, 0))
print(rtc.datetime())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment