I²C on RPi Pico


#1

Has anyone used either of the I²C interfaces on the RPi Pico with µLisp??
I get the following:

15314> (with-i2c (str 0 #x42) (print str) nothing)
nil 

15314> 

I²C works just fine with MicroPython.


#2

I’ve just checked it on a Raspberry Pi Pico with a HTU31D Humidity Sensor I had lying around, and I get the correct response:

> (with-i2c (str 0 #x40) (print str) nothing)

<i2c-stream 64> 

Are you sure there’s an I2C device at the address #x42? Has it got I2C pullups?


#3

Yes. This isn’t my first I²C Rodeo. :) Resistors and #x42 address.
All I did was reflash the Pico with µLisp from MicroPython – the circuit stayed the same.
Which set of physical pins did you use for I2C0 ?


#4

Pins 9 (SDA) and 10 (SCL); see Raspberry Pi Pico - Pinout.


#5

Your pin #'s are for I2C1, not I2C0 as you specified above. There are two I²C ports and each can be accessed
via 6 pairs of pins on the Pico. See https://datasheets.raspberrypi.org/pico/Pico-R3-A4-Pinout.pdf

OK, the dev # is actually 42₁₀ but changing that made no difference.

I reinstalled MicroPython, put my wires back onto I2C0 ((GP8,GP9 or physical pins 11,12) and
my Python program worked just fine. Mind you, I set the I2C speed down at 100Kbps because
of the older chips but it seems they handle 400Kbps just fine.


#6

uLisp is designed to work with the Arduino core for the Raspberry Pi Pico, and that only defines one I2C port on Arduino pins GP6 and GP7:

// Wire
#define PIN_WIRE_SDA        (6u)
#define PIN_WIRE_SCL        (7u)

These correspond to physical pins 9 and 10 as shown on the diagram you’ve linked to. This is the only I2C port that the Arduino core gives access to, so I’ve called that port 0 in uLisp.

MicroPython accesses the Raspberry Pi Pico via a different interface so it may work on a different I2C port.

You should be able to get I2C to work on physical pins 9 and 10 with uLisp.


#7

Nope. No go with µLisp on pins 9/10.
I drop MicroPython on the Pico and tell my code to use those same
pins and everything works just peachy. Oh well… I have a working
solution with it.

Sorry for the trouble.
-Rusty-


#8

What’s the uLisp function you’re running? Also, what Arduino core are you using?


#9
(with-i2c (str 42) (print str) nothing)

Arduino Mbed OS RP2040 Boards
by Arduino version 2.3.1
on Arduino 1.8.15


#10

I’ve just upgraded the Arduino core to 2.3.1 too, in case that made a difference, but it still all works fine for me:

I’m using uLisp ARM version 4.0b. With the I2C port scanner:

(defun scn () 
  (dotimes (p 127)
    (with-i2c (str p)
      (when str (print p)))))

I get:

15458> (scn)

0 
64 
nil

and running the temperature routine from here: HTU31D Humidity Sensor I get what you’d expect:

15388> (htu31d-temp)
22.5406

I’m keen to try and work out what’s causing your problems.

Thanks! David