flrrth / pico-htu21d

This is a MicroPython library for the Raspberry Pi Pico and the HTU21D Digital Relative Humidity sensor with Temperature output.
GNU General Public License v3.0
3 stars 2 forks source link

Anyone else got this code to work for them...? #4

Closed ADenislebel closed 8 months ago

ADenislebel commented 1 year ago

I can't get this example to work. I'm using Thonny. The htu21d.py and htu21d_configuration.py load ok but when I call them from an external py that is much the same as the example shown:

from machine import Pin, I2C from utime import sleep from htu21d import HTU21D i2c0_sda = Pin(8) i2c0_scl = Pin(9) i2c0 = I2C(0, sda=i2c0_sda, scl=i2c0_scl) htu21d = HTU21D(0x40, i2c0) while True: measurements = htu21d.measurements print(f"Temperature: {measurements['t']} °C, humidity: {measurements['h']} %RH") sleep(1)

I get an HTU21Dconfigurations not defined error. also I can't import math in the hut21d.py file and my search on the micropython documentation doesn't show any such import available for the pi-pico. For now I just commented out but I know when I get it to work the math stuff is going to be a problem as I see its part to the due point calculation functions Thanks Denis Lebel

ADenislebel commented 8 months ago

I got passed this hurdle. I can't remember the specifics at this time but in Thonny The pys must be downloaded to the pico prior to using any required import. Thanks Denis