I am using AHT10 sensor, so far with Python script, based on this project: GitHub - gejanssen/aht10-python
Unfortunately, in latest LE 10 Nightly builds (perhaps after move to 64 bit kernel) it stopped working, it's a timing issue with i2c communication which returns IO Error 121 or nonsense results. Despite I tried to struggle with time.sleep wait constants, couldn't get it working again. It looks the python script should be improved to communicate with AHT i2c device properly but I am not able to tune it up.
The current script looks like:
#!/usr/bin/python3
# https://github.com/Thinary/AHT10/blob/master/src/Thinary_AHT10.cpp
# https://myhydropi.com/raspberry-pi-i2c-temperature-sensor
# cleaned up and documented smbus 1 and some errors
# GJ 03-2020
# i2cdetect -y 0
import time
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
sys.path.append('/storage/.kodi/addons/virtual.adafruit-libraries/lib')
sys.path.append('/storage/.kodi/addons/virtual.system-tools/lib')
import smbus
# Get I2C bus
#bus = smbus.SMBus(0) # Rev 1 Pi uses 0
bus = smbus.SMBus(1) # Rev 2 Pi uses 1
# when you have a 121 IO Error, uncomment the next pause
time.sleep(1) #wait here to avoid 121 IO Error
config = [0x08, 0x00]
bus.write_i2c_block_data(0x38, 0xE1, config)
time.sleep(0.05)
byt = bus.read_byte(0x38)
#print(byt&0x68)
MeasureCmd = [0x33, 0x00]
bus.write_i2c_block_data(0x38, 0xAC, MeasureCmd)
time.sleep(0.05)
data = bus.read_i2c_block_data(0x38,0x00)
#print(data)
temp = ((data[3] & 0x0F) << 16) | (data[4] << 8) | data[5]
ctemp = ((temp*200) / 1048576) - 50
print(u'Temperature: {0:.1f}°C'.format(ctemp))
tmp = ((data[1] << 16) | (data[2] << 8) | data[3]) >> 4
#print(tmp)
ctmp = int(tmp * 100 / 1048576)
print(u'Humidity: {0}%'.format(ctmp))
Display More
I suppose the better results could be achieved with using directly AHT libraries but in Adafruit Libraries Add-on 10.0.0.107 only these are present:
ls /storage/.kodi/addons/virtual.adafruit-libraries/lib/
Adafruit_ADS1x15 Adafruit_LED_Backpack Adafruit_SSD1306
Adafruit_ADXL345 Adafruit_LSM303 Adafruit_TCS34725
Adafruit_BMP Adafruit_MCP3008 Adafruit_VCNL40xx
Adafruit_CharLCD Adafruit_MCP4725 Adafruit_WS2801
Adafruit_DHT Adafruit_PCA9685 SI1145
Adafruit_GPIO Adafruit_PureIO
So the quiestion is - could be possible to extend the Adafruit Libraries Add-on a bit please, at least with AHT?