Page 1 of 1

Isses getting Oled to work properly

Posted: Sat Feb 22, 2020 9:38 am
by MicroNinja
I have trouble getting my Oled display to work properly.
In my code you can see i2c.scan(). That is just printing an empty list.
And the program is crashing out with OSError: [Errno 110] ETIMEDOUT.
I am a bit stuck to where I can debug and find out what's wrong? Any ideas?

Code: Select all

from machine import Pin, I2C
import ssd1306
import time

# Sanity check blink on board led Default 2
LED_PIN = 2 # On board led
led = Pin(LED_PIN, Pin.OUT) 
def blink(times=2):
  for i in range(times):
      led.off()
      time.sleep(0.25)
      led.on()
      time.sleep(0.25)
blink()

i2c = I2C(scl=Pin(5), sda=Pin(4))
i2c.scan() # Print empty list
display = ssd1306.SSD1306_I2C(64, 48, i2c)
display.fill(0)
temp = "Boot2"
display.text(temp,10,10)
display.show()

time.sleep(2)

i = 0
while True:
    i+=1
    display.fill(0)
    display.text("{}".format(i),10,10)
    display.show()
    print(i)
    time.sleep(1)

Re: Isses getting Oled to work properly

Posted: Sat Feb 22, 2020 9:41 am
by Roberthh
If you get an empty list, then the wiring is wrong. Either sda and scl have to be swapped, or the pull-up resistors are missing, or you forgot to connect then GND cable.

Re: Isses getting Oled to work properly

Posted: Sat Feb 22, 2020 9:52 am
by MicroNinja
Thank you!
I will double check the wiring. I might have moved it around then. I did get it to work before. But whenever I pulled the usb cable out of the wemos something seemed to be chached? or someting. I did not work when I ran script from file using ampy (ampy run <path to script>). To solve that I had to reinstatement the oled in the repl like with just this bit of code:..
After that the oled worked from script again. Any idea why that would be?

Code: Select all

i2c = I2C(scl=Pin(5), sda=Pin(4))
display = ssd1306.SSD1306_I2C(64, 48, i2c)
display.fill(0)
temp = "Boot2"
display.text(temp,10,10)
display.show() 

Re: Isses getting Oled to work properly

Posted: Sat Feb 22, 2020 3:17 pm
by MicroNinja
Turns out nothing was wrong with wiring or code. I seem to have a faulty unit that just sometimes work. I had another one and that work fine everytime. Annoying when you spend so much time on it :( Oh well