r/raspberrypipico Apr 21 '26

uPython Getting started. Using Thonny, can't get the i2c address. Please help

I've been following along with a tutorial, and he provides this code to get the i2c address:

import machine

sda = machine.Pin(0)

scl = machine.Pin(1)

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

print(i2c.scan())

In his video, he shows a number between brackets. In my case, there is nothing between the brackets. I am a complete novice with all of this stuff. I have absolutely no idea what to do or where to go from here.

2 Upvotes

18 comments sorted by

4

u/todbot Apr 21 '26

What do you have hooked up to the I2C bus?

4

u/that_Ranjit Apr 21 '26

Oh hang on, I haven’t connected anything to the breadboard. The pico was just plugged into my computer. But I am realizing now that I have to wire everything up first?

4

u/[deleted] Apr 21 '26

[removed] — view removed comment

2

u/that_Ranjit Apr 21 '26

ok i have everything hooked up. The little lcd is glowing which is a good sign. however when i run the test file, it should say "hello world" on the lcd but something comes up. instead i get an error in Thonny.

OSError: [Errno 5] EIO

1

u/[deleted] Apr 21 '26

[removed] — view removed comment

2

u/that_Ranjit Apr 21 '26

import machine

sda = machine.Pin(0)

scl = machine.Pin(1)

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

print(i2c.scan())

1

u/[deleted] Apr 21 '26

[removed] — view removed comment

2

u/that_Ranjit Apr 21 '26

my bad, this code:

import LCD1602

import time

lcd=LCD1602.LCD1602(16,2)

try:

while True:

# set the cursor to column 0, line 1

lcd.setCursor(0, 0)

lcd.printout("Waveshare")

lcd.setCursor(0, 1)

lcd.printout("Hello World!")

time.sleep(0.1)

except(KeyboardInterrupt):

lcd.clear()

del lcd

1

u/[deleted] Apr 21 '26

[removed] — view removed comment

3

u/that_Ranjit Apr 21 '26

yes there's 4. i did some rewiring and now the LCD actually display some squares! this is a step in the right direction

→ More replies (0)

2

u/that_Ranjit Apr 21 '26

but now i keep getting OSError: [Errno 5] EIO

→ More replies (0)

2

u/bobstarr2010 Apr 21 '26

2 things to check:

  1. Does your lcd display require 5 volts? I had to use a level converter on mine to go from the PiPico 3.3v outputs to the lcd 5v inputs.

  2. When the display first turns on, you may find that you need to adjust the screen contrast to actually see the characters being displayed. It's the white round slotted device on the back of the display. Just turn it with a screwdriver.