These are the steps to get MicroPython with OLED setup with just WebREPL and WebREPL tools:
https://github.com/Hermann-SW/webrepl
- flash any ESP32 MicroPython to module with esptool.py
https://micropython.org/download#esp32
- open screen session
- do "import webrepl_setup", enable WebREPL and power cycle ESP32
- open screen session again
- activate access point
Code: Select all
import network
ap = network.WLAN(network.AP_IF)
ap.active(True)
- detach screen session by pressing CTRL-A, then CTRL-D
- download ssd1306.py from https://github.com/adafruit/micropython ... it-ssd1306
- copy over to ESP32:
Code: Select all
$ webrepl/webrepl_cli.py ssd1306.py 192.168.4.1:
Password:
op:put, host:192.168.4.1, port:8266, passwd:abcd.
ssd1306.py -> /ssd1306.py
Remote WebREPL version: (1, 9, 4)
Sent 5477 of 5477 bytes
$
- store below boot.py (with or without modifications)
- copy over to ESP32:
Code: Select all
$ webrepl/webrepl_cli.py boot.py 192.168.4.1:
Password:
op:put, host:192.168.4.1, port:8266, passwd:abcd.
boot.py -> /boot.py
Remote WebREPL version: (1, 9, 4)
Sent 637 of 637 bytes
$
- power cycle ESP32, that will result in Oled display as shown in photo below
Connect to the module as displayed on Oled, either with webrepl_client.py or with webrepl.html from github repo, or online:
https://micropython.org/webrepl/
Small WebREPL shell sample session:
Code: Select all
$ webrepl_client.py 192.168.4.1
Password:
WebREPL connected
>>> oled.invert(1)
>>> os.listdir()
['boot.py', 'webrepl_cfg.py', 'ssd1306.py']
>>>
And this is the boot script used, it displays whatever access point IP is configured:
Code: Select all
$ cat boot.py
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import network
ap = network.WLAN(network.AP_IF)
ap.active(True)
import webrepl
webrepl.start()
import machine, ssd1306
i2c = machine.I2C(scl=machine.Pin(4), sda=machine.Pin(5))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text(' MicroPython on ', 0, 0)
oled.text('ESP32 board with', 0, 9)
oled.text('- SSD1306 OLED ', 0, 19)
oled.text('- WebREPL active', 0, 28)
oled.text('AP = ' + ap.ifconfig()[0], 0, 38)
oled.text('connect: webrepl', 0, 47)
oled.text('_client.py|.html', 0, 56)
oled.show()
import os, time
$