ValueError: No i2c device at address 0x40

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
formlessform
 
Posts: 5
Joined: Tue Nov 22, 2022 7:57 pm

ValueError: No i2c device at address 0x40

Post by formlessform »

Have a Adafruit 16 PWM Servo HAT connected to a Raspberry Pi 4B.

I get an error:

ValueError: No i2c device at address 0x40

When I try run:

import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)

kit.servo[0].angle = 180
kit.servo[4].angle = 20
time.sleep(0.5)
kit.servo[4].angle = 0
time.sleep(0.5)
kit.servo[0].angle = 0

Just as an fyi, i2cdetect -y 20 and i2cdetect -y 21 display contents, just not i2cdetect -y 1. Is that normal?

This exact same code runs perfectly when I connect the HAT to a raspberry pi zero.

Thanks
-formlessform

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: ValueError: No i2c device at address 0x40

Post by mikeysklar »

I assume you have verified that i2c is enabled on the Pi 4B.

You could try moving the SD card with installed OS from the Pi Zero to the Pi 4B. That would help indicate if it is a OS setting.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”