I am trying to output the temperature values from a DHT20 temperature sensor via a raspberry pi pico w. I have connected the sda and scl pins of the sensor to pins 11 and 12 of the pi pico respectively.
Here is the following code I am trying to run:
import machine
from machine import Pin, I2C
from utime import sleep
from dht20 import DHT20
i2c0_sda = Pin(2) #11 or 8 or 4
i2c0_scl = Pin(2) #12 or 9 or 5
i2c0 = machine.I2C(id=1, sda=i2c0_sda, scl=i2c0_scl) #this is line 10
dht20 = DHT20(0x38, i2c0)
while True:
measurements = dht20.measurements
print(f"Temperature: {measurements['t']} °C, humidity: {measurements['rh']} %RH")
sleep(1)
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
ValueError: bad SCL pin
Does anyone know why this is occuring? I have verified the correct wiring and tried a new breadboard as well.