ESP32 MicroPython OLED Display
ฝัง
- เผยแพร่เมื่อ 27 มี.ค. 2020
- OLED display of resolution 128 x 64 , 0.96 in, blue ,I2C protocol is iused in this demo with ESP32 Micropython.
OLED is built on SSD1306 IC , and a ssd1306.py library is available for easy interface.
github.com/micropython/microp...
CODE DOWNLOAD :
www.alselectro.com/files/micro... - แนวปฏิบัติและการใช้ชีวิต
One of the very best for MP and OLED thank you my friend Saravanan!
Awesome explanation with very useful info - saved me a lot of time. Thanks!
Thank you sir, this is just what I was looking for today.
Useful video 👍
Grande tutorial. 😊👌
Thank you
Very nice. 🌅 Thank you.
As I was using a PyBoard instead of an esp32 I was worried these instructions wouldn't work for me, but with minor modifications it worked a dream. This video is awesome!
Can you please tell me how you modified it? Thanks!
@@maheswarkk1034 Hopefully you can extract the code you need from this:
'''
Step 1: Get the current system time
Step 2: Write out the current time to the microcontrollers's rtc object
Step 3: Synchronize the rtc object with the ds3231 module
Step 4: Within a loop write out the ds3231 get_time value to an oled display
Step 5: For now print out the hours, minutes and seconds
Step 6: Within the loop calculate days until retirement
'''
from utime import sleep
from pyb import RTC
from ds3231_pb import DS3231
import ssd1306
import utime
def days_between(d1, d2):
d1 += (1, 0, 0, 0, 0) # ensure a time past midnight
d2 += (1, 0, 0, 0, 0)
return utime.mktime(d1) // (24*3600) - utime.mktime(d2) // (24*3600)
retirement_date = (2021, 9, 10)
rtc = RTC()
i2c = machine.I2C(1) # Connected on 'Y' side Y9 clk Y10 data
ds3231 = DS3231(i2c)
#ds3231.save_time() # Set DS3231 to match Pyboard RTC
oled = ssd1306.SSD1306_I2C(128,64, machine.I2C(1))
while True:
oled.fill(0)
print('[rt]', rtc.datetime())
print('[ds]', ds3231.get_time())
ds_time = ds3231.get_time()
today = (ds_time[0], ds_time[1], ds_time[2])
diff = days_between(retirement_date, today)
print('diff =', diff)
time_text = "%02d:%02d:%02d" % (ds_time[3], ds_time[4], ds_time[5])
print("date text is:" + time_text)
oled.text(time_text, 0, 10)
#oled.text( str(ds_time[3]) + ':' + str(ds_time[4]) + ':' + str(ds_time[5] ), 0, 10)
oled.text( 'days to ret:' + str(diff) , 0, 20)
oled.show()
sleep(5)
@@wrightkevin9000 Wow! Thanks so much! Did not expect you to reply because its been a year. Was looking for this. There is not a lot of tutorials explaining things about the pyboard.
This is great. I can work well with the I2C bus but I am having trouble with getting SPI to work. Do you know where I could get such a video as this but for SPI in micropython on an ESP32 WROOM
Trying to program an epaper, with micro python esp32, do you have a tutorial for that?
Sir is this the method where we can save any library in micropython?
Sir. Can I use this method with a micro:bit?
AttributeError: 'SSD1306_I2C' object has no attribute 'fill_rect'
I have a problem, when i run it, the Thonny Shell said " Warning: I2C(-1, ...) is deprecated, use SoftI2C(...) instead" and when use SoftI2C, in the shell "NameError: name 'SoftI2C' isn't defined". Can you help me to fix it. I will be happy if you can help me
you must use
from machine import SoftI2C