Raspberry Pi Pico -...
 
Notifications
Clear all

Raspberry Pi Pico - Control the (I/O) World  

Page 4 / 4

DeadlyDave
(@deadlydave)
Active Member
Joined: 1 month ago
Posts: 8
 

@byron

Oh now I do feel silly. Yep you were right if I typed it properly it would have been fine. 

I'll go and hang my head in shame.

 

Thanks a million for your help,

Dave.

 


Sean451 liked
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 1042
 

@deadlydave

There is probably not one of us on this forum that hasn't made the same mistake before.  And also some of us that have made it multiple time.  Yours truly sure has! 

SteveG


ReplyQuote
Sean451
(@sean451)
Trusted Member
Joined: 5 months ago
Posts: 69
 
Posted by: @deadlydave

@byron

Oh now I do feel silly.

Never feel silly. We've all been there and we've all done it. It's how we learn.

--->Sean

(◕(' 人 ') ◕)


ReplyQuote
DeadlyDave
(@deadlydave)
Active Member
Joined: 1 month ago
Posts: 8
 

@codecage

I appreciate the kind words. 😀 I still feel super silly though, anyway! 😳 

Sure look, the issue is solved now and when I finish work later, I get to get back to it and finish it off.

Then think of an actual use for my pico.

 

Dave.

 


Sean451 liked
ReplyQuote
Smurf
(@smurf)
Active Member
Joined: 4 weeks ago
Posts: 5
 

@deadlydave

@byron

I had the same problem, and used byrons suggestion of downloading the ssd1306.py from github.

But I'm running old Win7, so that didn't work until I used Zadig to install the correct driver (apparently automatic in Win10).

So now I can select the MicroPython (Raspberry Pi pico) in the configure interpreter menu, and the correct fields are showing in Thonny.

But my problems haven't ended there. I still can't get Bills prog. which addresses the oled to work.

It's this one: 

# Raspberry Pi Pico OLED Display Test
# Uses ssd1306 module
# display-ssd1306-test.py

# DroneBot Workshop 2021
# https://dronebotworkshop.com

import machine
import utime

sda=machine.Pin(20)
scl=machine.Pin(21)

i2c=machine.I2C(0, sda=sda, scl=scl, freq=400000)

from ssd1306 import SSD1306_I2C
oled = SSD1306_I2C(128, 32, i2c)


print(i2c.scan())

oled.text('Welcome to the', 0, 0)
oled.text('Pi Pico', 0, 10)
oled.text('Display Demo', 0, 20)
oled.show()
utime.sleep(4)

oled.fill(1)
oled.show()
utime.sleep(2)
oled.fill(0)
oled.show()

while True:
oled.text("Hello World",0,0)
for i in range (0, 164):
oled.scroll(1,0)
oled.show()
utime.sleep(0.01)

When I run this, I get an error : Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "ssd1306.py", line 114, in __init__
File "ssd1306.py", line 36, in __init__
File "ssd1306.py", line 71, in init_display
File "ssd1306.py", line 119, in write_cmd
OSError: [Errno 5] EIO

pointing to line: File "<stdin>", line 17, in <module>

No manner of massaging the code seems to fix this.

Any suggestions ?

ReplyQuote
byron
(@byron)
Honorable Member
Joined: 2 years ago
Posts: 519
 

@smurf

doing a google on 'OSError: [Errno 5] EIO' showed a few results and possibly this one could be of interest, though not relating to your ssd1306.
https://forum.micropython.org/viewtopic.php?t=560

And note the comment 

" Probably the most common reason is that the i2c device isn't responding.

So soldering could be a problem. Does anything show up if you do an i2c.scan() ? "

So double check your wiring for good connections

You could then scan for your i2c device with the following

import machine

sda=machine.Pin(20)
scl=machine.Pin(21)

i2c=machine.I2C(0, sda=sda, scl=scl, freq=400000)


print('Scan i2c bus...')
devices = i2c.scan()
 
if len(devices) == 0:
  print("No i2c device !")
else:
  print('i2c devices found:',len(devices))
 
  for device in devices:  
    print("Decimal address: ",device," | Hexa address: ",hex(device))


 

 


ReplyQuote
Smurf
(@smurf)
Active Member
Joined: 4 weeks ago
Posts: 5
 

@byron

Thanks. For some reason I have to disconnect the pico and restart Thonny sometimes, as the whole thing 'hangs up'. It loses the USB connection, and the pico file menu disappears from Thonny. Another issue to resolve, possibly Win7 and/or driver related !!!

Anyhowz, after getting back to normal operation, I then ran the I2C scan prog as you suggested, and it came up with:

 Scan i2c bus...
i2c devices found: 1
Decimal address: 60 | Hexa address: 0x3c

so at least it is connected properly.

How do I know what address the "Raspberry Pi Pico OLED Display Test" is using, as Bill says it's fixed but does not mention fixed at what setting (0x3c, 0x3d, or whatever) ?

How can I force it to be what I want (0x3c) ?

Cheers for your help with this stuff, you must think I'm a bit of a dummy !!

 

 


ReplyQuote
DeadlyDave
(@deadlydave)
Active Member
Joined: 1 month ago
Posts: 8
 

@smurf @byron

"you must think I'm a bit of a dummy !"

Well I obviously don't, judging by my rookie questions the other day 😉

 

Firstly glad you are now picking up the I2C address. 

The address 0x3C is the default address hard codded into the library.

You can verify that yours is still set to this by clicking into the library (You can just click on the include)

Line 108 (in mine anyway) has the following

class SSD1306_I2C(SSD1306):
def __init__(self, width, height, i2c, addr=0x3C, external_vcc=False):

If you need to change it for whatever reason, you should just be able to change the value here.

 

Edit:

Alternately (which is probably the better option as you shouldn't change the library if you don't need to)

You can create the object and pass it the value in your main program

Wherever you are creating the oled object

Change:

oled = SSD1306_I2C(128, 32, i2c)

To:

oled = SSD1306_I2C(128, 32, i2c, addr=0x3C)

 

Dave.

This post was modified 4 weeks ago by DeadlyDave

ReplyQuote
Smurf
(@smurf)
Active Member
Joined: 4 weeks ago
Posts: 5
 

@deadlydave

@byron

Thanks deadlydave for your suggestions, much appreciated.

My 128X64 oled display has a link set to 0x3c, and I can get Bills ssd1306_test.py  to run ONLY if I

a) set the line "oled = SSD1306_I2C(128, 64, i2c)"   to  "oled = SSD1306_I2C(128, 32 ,i2c)", and

b) comment out the lines shown here:

 

# Raspberry Pi Pico OLED Display Test
# Uses ssd1306 module
# display-ssd1306-test.py

# DroneBot Workshop 2021
# https://dronebotworkshop.com

import machine
import utime

sda=machine.Pin(20)
scl=machine.Pin(21)

i2c=machine.I2C(0, sda=sda, scl=scl, freq=400000)

from ssd1306 import SSD1306_I2C
oled = SSD1306_I2C(128, 64, i2c)


print(i2c.scan())

#oled.text('Welcome to the', 0, 0)
#oled.text('Pi Pico', 0, 10)
#oled.text('Display Demo', 0, 20)
#oled.show()
#utime.sleep(4)

#oled.fill(1)
#oled.show()
#utime.sleep(2)
#oled.fill(0)
#oled.show()

while True:
oled.text("Hello World",0,0)
for i in range (0, 164):
oled.scroll(1,0)
oled.show()
utime.sleep(0.01)

 

If I set the oled parameters at (128, 64, i2c)

I get error:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "ssd1306.py", line 114, in __init__
File "ssd1306.py", line 36, in __init__
File "ssd1306.py", line 71, in init_display
File "ssd1306.py", line 119, in write_cmd
OSError: [Errno 5] EIO

 

If I leave it at (128, 32, i2c)

I get error:

Traceback (most recent call last):
File "<stdin>", line 28, in <module>
File "ssd1306.py", line 104, in show
File "ssd1306.py", line 119, in write_cmd
OSError: [Errno 5] EIO

unless I comment out all of the oled. lines shown above.

Also, what is the significance of the (0, 164) in the line:

for i in range (0, 164) ?

Why (arbitrarily?) choose 164 ?

 

I'm still really confused about what's going on.

 


ReplyQuote
byron
(@byron)
Honorable Member
Joined: 2 years ago
Posts: 519
 

@smurf

I suggest you do a google of 

i2c ssd1306 OSError: [Errno 5] EIO

A quick look at some of the info puts up some possibilities like over long cable runs and other stuff.  

a copy of the sort of info you will see is show below

  1. It is pretty likely that Pico Thonny Python's error message "OSError: 5" is similar to Rpi Os's "OSError: [Errno 121] Remote I/O error"

  2. Errno 121 usually occurs when running an I2C python program with the following situation:

    2.1 The hardware wiring connection is bad, eg,

    2.1.1 Forget to plug/connect the cable,

    2.1.2 Too long cabling, eg, over 30cm,

    2.1.2 I2C frequency too high, over 400kHz,

    2.1.3 I2C device, eg. I2C I2C MCP23017, which is sensitive to noise,

    2.1.4 I2C bus overloaded, with more than 4 devices, causing bus capacitance over 400pF.

or perhaps on another site the following test program is suggested but you would need to set the pins you are using on your pico

import machine
from ssd1306 import SSD1306_I2C
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text("Hello World!", 0, 0)
oled.show()
print('Done')

But you will also find other info which may point you in the right direction.  Apart from this I dont think I can assist further.  Good luck in sorting it out, and if you do, be sure to let us know of the solution.


ReplyQuote
Smurf
(@smurf)
Active Member
Joined: 4 weeks ago
Posts: 5
 

@byron

@deadlydave

Thanks byron, I just missed your reply as I posted mine.

I tried your prog, and modified it to :

import machine
from ssd1306 import SSD1306_I2C
sda=machine.Pin(20)
scl=machine.Pin(21)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=100000)
oled = SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text("Hello World!", 0, 0)
oled.show()
print('Done')

Seems it did not like running at 400000Hz, but sprang into life at 100000.

Except that it only flashes up "Hello World" for a brief (0.5sec) time.

I tried importing 'utime' and adding a delay with utime.sleep(5), but then it reverted back to the ol' :

Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "ssd1306.py", line 114, in __init__
File "ssd1306.py", line 36, in __init__
File "ssd1306.py", line 71, in init_display
File "ssd1306.py", line 119, in write_cmd
OSError: [Errno 5] EIO

 

Think I'll just give up until I can try it out on a Win10 machine !!!

Cheers - Kev.

 


ReplyQuote
DeadlyDave
(@deadlydave)
Active Member
Joined: 1 month ago
Posts: 8
 

@smurf

Or, just as a point to note, if you wanted to stay on W7, you must have good reasons. You can install Linux and dual boot or you could even 'install' linux on USB key and run it off that without affecting your W7 installation at all.

Just another option 🙂

Anyway you are welcome and as @byron said "Good luck in sorting it out, and if you do, be sure to let us know of the solution."

That's the most important part, when you do find a solution letting everyone else know. 👍 

 

Thanks,

Dave.


ReplyQuote
Page 4 / 4