Looking for MicroPython ssd1306 OLED module (HILetgo Heltec ESP32 LoRa) #10697
Replies: 18 comments 9 replies
-
Have you seen this one? Stlehmann's fork seems to be of an earlier version of the file, before def rotate() was added. |
Beta Was this translation helpful? Give feedback.
-
Thanks Mike: Yes, I have been banging on this (slightly earlier version).
It runs, as does the one that you linked to in your email.
Unfortunately ...
Nothing appears on the Heltec's display (using HiLetgo ESP32 LoRa SX1276
0.96 inch OLED Display Development Board WiFi Bluetooth Dual Core 240MHz
CP2102 and 868/915MHz Antenna for Arduino Smart WiFi LoRa 32)
Per the spec sheet the pins are sda 4 and scl 15
So I configured : i2c = machine.I2C(sda=machine.Pin(4), scl=machine.Pin(15))
printing the scan output: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119]
ssd1306 class SSD1306_I2C __init__ uses a default address of 0x3c which,
according to ChatGPT is the address to use.
The strange thing is the I2C behavior. According to docs
I2C.scan()¶
<https://docs.micropython.org/en/latest/library/machine.I2C.html#machine.I2C.scan>
Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of
those that respond. A device responds if it pulls the SDA line low after
its address (including a write bit) is sent on the bus.
The Heltec Device is just sitting there at the end of a USB cable that
provides it with power. It cannot possibly have 112 peripherals attached to
it.
Forgive me, I know this drifted from the initial topic but if you have
advice I will gladly take it!
…On Wed, Feb 8, 2023 at 6:58 PM Mike Causer ***@***.***> wrote:
Have you seen this one?
https://github.com/micropython/micropython-lib/tree/master/micropython/drivers/display/ssd1306
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EILZTBXFOUU65JDJ23WWQXK7ANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Hi Peter: I am becoming a fan of your work, thank you.
Before I dive into FrameBuffer, one question:I am using the Heltec
ESP32+LoRa unit with a built in OLED screen. There is nearly NOTHING on the
internet at the intersection of Micropython, ssd1306 and Heltec that I can
find. Am Ijust using the wrong piece of equipment?
…On Thu, Feb 9, 2023 at 5:20 AM Peter Hinch ***@***.***> wrote:
nano-gui <https://github.com/peterhinch/micropython-nano-gui> and
micro-gui <https://github.com/peterhinch/micropython-micro-gui> support
SSD1306.
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EOFM3PN2754UH4CMB3WWTAGVANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
ChatGPT: I just started using it and agree ... many times the answers are
wrong and the links are stale. Google is safe for now (even though the
share prices are dropping like a rock!)
https://github.com/HelTecAutomation/Heltec_ESP32/blob/master/examples/ESP32/I2C_Scanner/I2C_Scanner.ino
Says this, so I think the lines are
static const uint8_t SCL_OLED = 15;
static const uint8_t SDA_OLED = 4;
…On Thu, Feb 9, 2023 at 1:29 PM Stewart Russell ***@***.***> wrote:
according to ChatGPT
I think it would be very helpful if you *stopped* using ChatGPT as a
reference source. It has no intelligence. It is designed to always return a
believable answer, even if completely wrong. In the context of looking for
very specific technical results, it will be a considerable hindrance to
your success.
An i2c scan shouldn't return that many devices. Other sources (ESP32
Built-in OLED - Heltec WiFi Kit 32 – Robot Zero One
<https://robotzero.one/heltec-wifi-kit-32/>, datasheet
<https://resource.heltec.cn/download/HTIT-WB32LA_V3(Rev1.1).pdf>) suggest
you're using the correct pins for SDA and SCL
—
Reply to this email directly, view it on GitHub
<#10697 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EITU23AOO4KEPPCVNDWWUZRXANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Thank you: This is a builtin OLED on the Heltec ESP32+LoRa board. So I
cannot put in resistors, etc.
Question (new toI2C):
i2c = machine.SoftI2C(sda=machine.Pin(4), scl=machine.Pin(15) << this
would say where to look
scan_result = i2c.scan() << this would ask for the address (which should
be 0x3c)
The board is a built in ... where can I look next?
…On Thu, Feb 9, 2023 at 2:15 PM bixb922 ***@***.***> wrote:
When all addresses on a I2C bus seem to respond, then sda is probably
always low. That could mean either a connection problem, or absence of
pullup resistors on sda and/or scl. Many boards provide pullup resistors,
check the schematics.
—
Reply to this email directly, view it on GitHub
<#10697 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EMDSSEN423N5ARMCSLWWU64JANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
As far as I can tell form the Pin-Out diagrams, Pin 4 and Pin 15 are accessible at the board's Pin connector. So you can attach pull-up resistors. I just tried that with a different Heltec board, the Wireless stick, which as well requires external pull-up resistors. |
Beta Was this translation helpful? Give feedback.
-
I don't know, Robert, I have several of these boards on my desk. The ones
that come out of the box fireup to the heltec logo immediately. I then
erase the flash and start working with micropython and ... NADA.
The ones I program in Arduino (C++) also work with no problems:
https://www.instructables.com/Arduino-and-the-SSD1306-OLED-I2C-128x64-Display/
I doubt it has to do with resistors.
…On Thu, Feb 9, 2023 at 3:38 PM Robert Hammelrath ***@***.***> wrote:
As far as I can tell form the Pin-Out diagrams, Pin 4 and Pin 15 are
accessible at the board's Pin connector. So you can attach pull-up
resistors. I just tried that with a different Heltec board, the Wireless
stick, which as well requires external pull-up resistors.
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EIQOBIBTRIAEEAPEADWWVIVLANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
I am using this library:
https://github.com/micropython/micropython-lib/blob/master/micropython/drivers/display/ssd1306/ssd1306.py
With this code:
import machine
i2c = machine.SoftI2C(sda=machine.Pin(4), scl=machine.Pin(15)) # 112
devices found
scan_result = i2c.scan()
print(f"scan result len={len(scan_result)} devices found:{scan_result}")
Which returns this result:
scan result len=112 devices found:[8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119]
…On Thu, Feb 9, 2023 at 4:21 PM Robert Hammelrath ***@***.***> wrote:
Strange. So your test is:
import machine
rst=machine.Pin(16, machine.Pin.OUT, value=1) # set the OLED reset pin high.
i2c = machine.I2C(0, sda=machine.Pin(4), scl=machine.Pin(15))
print(i2c.scan())
Could as well be I2C 1. You could as well use SoftI2C, then the device
parameter is not required.
—
Reply to this email directly, view it on GitHub
<#10697 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EJX2DBTKCR6R2Q3UQLWWVNXHANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
I took the /micropython-nano-gui-master/drivers/ssd1306/ssd1306.py, changed
the pins to correspond to those (supposedly) of the Heltec and placed it on
the Heltec board /pyboard/ directory
I took the micropython-nano-gui-master/setup_examples/ssd1306_i2c_esp32.py
file, modified the import path for ssd1306 and placed it in directory
(/pyboard/) with the name main.py
from machine import Pin, SoftI2C
import gc
from ssd1306 import SSD1306_I2C as SSD
# ESP32 Pin assignment
i2c = SoftI2C(scl=Pin(4), sda=Pin(15))
oled_width = 128
oled_height = 64
gc.collect() # Precaution before instantiating framebuf
ssd = SSD(oled_width, oled_height, i2c)
The result:
Traceback (most recent call last):
File "main.py", line 12, in <module>
File "ssd1306.py", line 114, in __init__
File "ssd1306.py", line 40, in __init__
File "ssd1306.py", line 75, in init_display
File "ssd1306.py", line 119, in write_cmd
OSError: [Errno 116] ETIMEDOUT
Does this mean I have the wrong pins?
…On Thu, Feb 9, 2023 at 5:20 AM Peter Hinch ***@***.***> wrote:
nano-gui <https://github.com/peterhinch/micropython-nano-gui> and
micro-gui <https://github.com/peterhinch/micropython-micro-gui> support
SSD1306.
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EOFM3PN2754UH4CMB3WWTAGVANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Try using ‘Pin.PULL_UP’ on the I2C Pins. For example: https://github.com/russhughes/TurtlePlotBot/blob/3c99a8cc760000a69aabef3c1ba7c76c47b7f61e/lib/oledui.py#L44 |
Beta Was this translation helpful? Give feedback.
-
As a general point, until you get a sensible result from |
Beta Was this translation helpful? Give feedback.
-
The previous iteration (without your suggestion):
i2c = machine.SoftI2C(sda=machine.Pin(4), scl=machine.Pin(15)) # 112
devices found
scan_result = i2c.scan()
print(f"scan result len={len(scan_result)} devices found:{scan_result}")
result:
scan result len=112 devices found:[8, 9, 10, 11, ... ... ... , 118, 119]
This iteration (with your suggestion):
i2c = machine.SoftI2C(scl=Pin(15, Pin.OUT, Pin.PULL_UP), sda=Pin(4,
Pin.OUT, Pin.PULL_UP), freq=450000)
scan_result = i2c.scan()
print(f"scan result len={len(scan_result)} devices found:{scan_result}")
Result:scan result len=0 devices found:[]
Traceback (most recent call last):
...
OSError: [Errno 19] ENODEV
…On Fri, Feb 10, 2023 at 1:32 AM Russ Hughes ***@***.***> wrote:
Try using ‘Pin.PULL_UP’ on the I2C Pins. For example:
https://github.com/russhughes/TurtlePlotBot/blob/3c99a8cc760000a69aabef3c1ba7c76c47b7f61e/lib/oledui.py#L44
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EK75X4N5KTRVWUSW5DWWXOJNANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Understood, Peter.
…On Fri, Feb 10, 2023 at 5:06 AM Peter Hinch ***@***.***> wrote:
As a general point, until you get a sensible result from .scan there is
no chance of any driver working.
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EIWZU53ETKUJTMTSSTWWYHIPANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Robert: I believe you provided the solution to the I2C scan:
Here is the code as I implemented it with your suggested code:
p4=Pin(4, Pin.OPEN_DRAIN)
p15=Pin(15, Pin.OPEN_DRAIN)
# set the OLED reset pin to a high level, otherwise the display will not
respond
p16=Pin(16, Pin.OUT, value=1)
i2c=machine.SoftI2C(sda=p4, scl=p15)
# now reconfigure the pin with internal Pull-up
p4.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
p15.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
# now test:
scan_result = i2c.scan()
print(f"scan result len={len(scan_result)} devices found:{scan_result}")
and the result:
scan result len=1 devices found:[60] (which is the much expected 0x3c)
Thank you much
…On Fri, Feb 10, 2023 at 2:40 AM Robert Hammelrath ***@***.***> wrote:
I do not expect that setting the Pin to open drain works, at least not in
the constructor. Because SoftI2C init calls mp_hal_pin_open_drain(p), and
that is defined as:
#define mp_hal_pin_open_drain(p) mp_hal_pin_config((p),
MP_HAL_PIN_MODE_OPEN_DRAIN, MP_HAL_PIN_PULL_NONE, 0)
One could try to reconfigure the Pin after creating the I2C object e.g. as:
from machine import SoftI2C, Pin
p4=Pin(4, Pin.OPEN_DRAIN)
p15=Pin(15, Pin.OPEN_DRAIN)
# set the OLED reset pin to a high level, otherwise the display will not respond
p16=Pin(16, Pin.OUT, value=1)
i2c=SoftI2C(sda=p4, scl=p15)
# now reconfigure the pin with internal Pull-up
p4.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
p15.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
# now test:
print(i2c.scan())
—
Reply to this email directly, view it on GitHub
<#10697 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EJYMR4OXZQ2C6X65FTWWXWIVANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
Peter: And with that I2C snippet from Robert the display works!
Everyone: Thank you all for your suggestions and assistance.
…On Fri, Feb 10, 2023 at 5:06 AM Peter Hinch ***@***.***> wrote:
As a general point, until you get a sensible result from .scan there is
no chance of any driver working.
—
Reply to this email directly, view it on GitHub
<#10697 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EIWZU53ETKUJTMTSSTWWYHIPANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
I think I did, but please check my code (has been converted to a class)
def initialize_display(self):
p4=Pin(self.pin_sda, Pin.OPEN_DRAIN)
p15=Pin(self.pin_scl, Pin.OPEN_DRAIN)
p16=Pin(self.pin_rst, Pin.OUT, value=1) # set the OLED reset pin
to a high level, otherwise the display will not respond
i2c=machine.SoftI2C(sda=p4, scl=p15)
…On Fri, Feb 10, 2023 at 8:44 AM Robert Hammelrath ***@***.***> wrote:
You did not set GPIO16 to high!. And you have to configure GPIO4 and
GPIO15 with PULL_UP after the line with i2c=.... as in the script below:
from machine import SoftI2C, Pin
p4=Pin(4, Pin.OPEN_DRAIN)
p15=Pin(15, Pin.OPEN_DRAIN)
# set the OLED reset pin to a high level, otherwise the display will not respond
p16=Pin(16, Pin.OUT, value=1)
# Instantiate the i2c object, which internally configures the Pins to OPEN_DRAIN, PULLNONE.
i2c=SoftI2C(sda=p4, scl=p15)
# now reconfigure the pin with internal Pull-up
p4.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
p15.init(Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
# now test:
print(i2c.scan())
I tested that script with a different Heltec device, which has a SSD1306
OLED as well at the same pins. And that returs [60], where 60 == 0x3c.
—
Reply to this email directly, view it on GitHub
<#10697 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVW4EIGVZKU5NUH5GLC5V3WWZA3PANCNFSM6AAAAAAUV3KJIU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Gary Kuipers, President, Casinfo
cell +1 805 443 9446 other +1 702 608 6558
|
Beta Was this translation helpful? Give feedback.
-
I'm assuming this isn't solved since there is a bunch of conversation after this including one post that points out this is an older driver.
|
Beta Was this translation helpful? Give feedback.
-
ChatGPT helpfully pointed me to several broken links when I asked about code pertaining to the OLED ssd1306. Can someone point me in the correct direction?
Apparently searching Github comes up with lots of suggestions. ChatGPT is going to take over the world? I don't think so!
None of the github projects appear to mention ESP32 or Heltec.
Interesting: found this "This MicroPython code, executed on an ESP32 OLED SSD1306 board, displays departure tables by utilizing the VVS Rest A…" while paging through the results, but a specific search for "Micropython ESP32 ssd1306" came up with nothing.
SOLVED: THis makes it upip installable! https://github.com/stlehmann/micropython-ssd1306
Beta Was this translation helpful? Give feedback.
All reactions