Rasberry Pi 4 Red Using Piiicodev expansion and motion sensor

I am a newbie so please excuse my ingorance.

I have a Rasberry Pi 400 (red one with keyboard all in one) and connected the PiicoDev expansion board and motion sensor.

Following this guide: Guide and have everything stored in Documents/PiicoDev

IC2 is enabled but when I run the code I get the following error:

Device 0x68 not found, trying again
Device 0x68 not found, trying again
Device 0x68 not found, trying again
Traceback (most recent call last):
  File "/home/pi/Documents/PiicoDev/motion.py", line 11, in <module>
    accel = motion.read_accel_data() # read the accelerometer [ms^-2]
  File "/home/pi/Documents/PiicoDev/PiicoDev_MPU6050.py", line 128, in read_accel_data
    x = self.read_i2c_word(self.ACCEL_XOUT0)
  File "/home/pi/Documents/PiicoDev/PiicoDev_MPU6050.py", line 85, in read_i2c_word
    rawData = self.i2c.readfrom_mem(self.addr, register_high, 2)
  File "/home/pi/Documents/PiicoDev/PiicoDev_Unified.py", line 69, in readfrom_mem
    self.smbus_i2c_read(addr, memaddr, data, nbytes, addrsize=addrsize)
  File "/home/pi/Documents/PiicoDev/PiicoDev_Unified.py", line 52, in smbus_i2c_read
    self.i2c.i2c_rdwr(msg_w, msg_r)
  File "/home/pi/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
    ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 121] Remote I/O error
>>> 

Unsure what I am doing wrong and any help would be appreciated.

1 Like

Hi Tim, Welcome to the Forum!

The first step is to make sure your Piicodev module is being seen at all on your Pi. The easiest way to do this would be to run sudo i2cdetect -y 1 (you may have to run sudo apt install i2c-tools first if that returns an error about not being installed)

Once you’ve done that, we can take a closer look at your code. Keen to see your project on its feet!
-James

Hi Tim,

No worries, we’re here to help!

It does seem a little odd, as the default address on that chip is 0x68 (this is hex so in dec it’s actually 104 = 0x68) if for some reason ADR is high on your board it would actually appear to be at 0x69. Running the commands that James linked will let us know whether there’s an issue with the address of the PiicoDev sensor not being correct/unrecognised.

Thanks for that. Here is a screenshot showing the terminal output.

Hi Tim,

Just to confirm, have you enabled i2c? Easiest way to check is to run sudo raspi-config nonint get_i2c

If it’s not (returns 1), sudo raspi-config has an option for enabling it.

-James

yes i did that and rebooted after ensuring it was enabled

sudo raspi-config nonint get_i2c returns 0

i noted in the tutorials the light is enabled on the sensor but i do not get the light on the sensor. could that be a hint?

Hi Tim,

Hmm, quite possibly. Maybe @Michael has an idea what is happening here? We test all Piicodev modules before they leave our warehouse, but something may be amiss here. I see you’ve got a couple cables to plug the sensor in, have you got the same symptoms on all? Have you tried different connectors on the Piicodev modules to try and find a fault there?

Whatever the problem turns out to be, we’ll try our best to get you sorted out.
-James

P.S. On the schematic, the LED is just a power LED, so it’ll be lit regardless of communication with the Pi, just power:
image

I also have the distance sensor so i will try that and update shortly.

1 Like

same issue so I am starting to think its the expansion board

here is another image of how i have it all connected

1 Like

Hi Tim,

I’ve connected up the same setup here and the piicodev sensors light up.

I will add this isn’t my preferred setup, I think it would be more robust long term to use a ribbon cable to extend the headers, or at the very least stackable header pins to space the expansion board so it doesn’t press on the keyboard frame. The GPIO connector is a surface mount connector after all and not really a load bearing component.
Something like this:

or failing that just this https://core-electronics.com.au/stackable-0-100-female-header-2x20-pin-straight.html

Is there a chance the expansion board was missaligned on the GPIO pins like below?


This would cause the LEDs not to light up.

Well that is embarrassing. :frowning: Yep it was misaligned to the left. Repositioned it and the green light came up immediately. Thanks guys for all your help and patience today. Really appreciate it.

3 Likes

Hi Tim,

Awesome to hear it works! We’re in the process of updating our product page to make sure no-one falls into the same trap :slightly_smiling_face:

Good luck with your projects, and let us know if you need a hand with anything else!
-James

2 Likes