Raspberry Pi Pico -...
 
Notifications
Clear all

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

72 Posts
21 Users
40 Likes
11.8 K Views
DeadlyDave
(@deadlydave)
Member
Joined: 3 years ago
Posts: 6
 

@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 reacted
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@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)
Member
Joined: 3 years ago
Posts: 62
 
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

(◕(' 人 ') ◕)


   
DeadlyDave and huckOhio reacted
ReplyQuote
DeadlyDave
(@deadlydave)
Member
Joined: 3 years ago
Posts: 6
 

@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 reacted
ReplyQuote
(@smurf)
Member
Joined: 3 years ago
Posts: 6
 

@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)
No Title
Joined: 5 years ago
Posts: 1122
 

@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))


 

 


   
DeadlyDave reacted
ReplyQuote
(@smurf)
Member
Joined: 3 years ago
Posts: 6
 

@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)
Member
Joined: 3 years ago
Posts: 6
 

@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 3 years ago by DeadlyDave

   
ReplyQuote
(@smurf)
Member
Joined: 3 years ago
Posts: 6
 

@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)
No Title
Joined: 5 years ago
Posts: 1122
 

@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)
Member
Joined: 3 years ago
Posts: 6
 

@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)
Member
Joined: 3 years ago
Posts: 6
 

@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
(@jasline123)
Member
Joined: 2 years ago
Posts: 20
 

I am trying to connect raspberry pi pico with waveshare ov2640 and an SD card adapter.Even after giving the connection i am getting the error pin is in use.Any help?


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6965
 

@jasline123 First try just the SD card and follow Bill's video. If it does not work, show some pictures so we can see the mechanical connections well. Then take a screen capture of the error and post the code that caused it using the code posting procedures documented in the help to the right of this page.

Once we have that sorted out we can discuss how you connected a camnera to a PICO since I don't remember seeing a camera adapter on the board.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@jasline123)
Member
Joined: 2 years ago
Posts: 20
 
import os
import board
import busio as io
import digitalio
import storage
import adafruit_sdcard
import sdcardio
import adafruit_ov2640
import microcontroller
from time import sleep
import time
from displayio import (
Bitmap,
Group,
TileGrid,
FourWire,
release_displays,
ColorConverter,
Colorspace,
)
SD_CS = board.GP13

spi = io.SPI(board.GP10, board.GP11, board.GP12)
cs = digitalio.DigitalInOut(SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

with digitalio.DigitalInOut(board.GP10) as reset:
reset.switch_to_output(False)
time.sleep(0.001)
bus = busio.I2C(board.GP9, board.GP8)

cam = adafruit_ov2640.OV2640(
bus,
data_pins=[
board.GP12,
board.GP13,
board.GP14,
board.GP15,
board.GP16,
board.GP17,
board.GP18,
board.GP19,
],
clock=board.GP11,
vsync=board.GP7,
href=board.GP21,
mclk=board.GP20,
shutdown=None,
reset=board.GP10,
)

cam.colorspace = adafruit_ov2640.OV2640_COLOR_JPEG
cam.size = adafruit_ov2640.OV2640_SIZE_QQVGA
buf = bytearray(cam.capture_buffer_size)

jpeg = cam.capture(buf)
print(f"Captured {len(jpeg)} bytes of jpeg data")
try:
with open("/sd/jpeg.jpg", "wb") as f:
f.write(jpeg)
except OSError as e:
print(e)
print(
"A 'read-only filesystem' error occurs if you did not correctly install"
"\nov2640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the board"
)
print("Wrote to CIRCUITPY/jpeg.jpg")



   
ReplyQuote
Page 4 / 5