Etape 1 : Installer la librairie ssd1306.py pour gérer l'écran oled
#
#Installer la librairie ssd1306.py
#pour utiliser les afficheur oled
from machine import Pin
import urequests
from time import sleep
fichier = "ssd1306.py"
get_lib = "http://217.182.207.90/ota1/"+fichier
reponse = urequests.get(get_lib)
f = open(fichier,"w")
f.write(reponse.text)
f.flush()
f.close
led = Pin(2, Pin.OUT)
print("Librairie ",fichier," installée sur l'ESP")
while True:
led.value(not led.value())
sleep(0.1)
Etape 2 : Tester l'écran
#
from machine import Pin, I2C,SoftI2C
import ssd1306
# using default address 0x3C
# ESP32 Pin assignment
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.text('Hello, World 1!', 0, 0)
oled.text('Hello, World 2!', 0, 10)
oled.text('Hello, World 3!', 0, 20)
oled.show()
Source : https://docs.micropython.org/en/latest/esp8266/tutorial/ssd1306.html