Does anyone have SHT40 example code?
I'm trying for 2 days, and no progress. Is it posible with i2cwrite, i2cread command?
Trying to do conversion and read data, all 0's. Trying to read serial no, al 0's.
HW connection looks good.
Printable View
Does anyone have SHT40 example code?
I'm trying for 2 days, and no progress. Is it posible with i2cwrite, i2cread command?
Trying to do conversion and read data, all 0's. Trying to read serial no, al 0's.
HW connection looks good.
what have you tried ?
i fumbled around a bit with a scd41 which has a similar modus operandi and managed to get it to work with i2cread/write commands eventually , trick was to send a dummy 0 write prior to the needed delay before the result was read back
Got it working, stupid datasheet....
Address is $88, not $44, as in datasheet.
Found that using
https://www.picbasic.co.uk/forum/sho...C-Ping-program
Then is straight forward
1. Read serial
0-1 serial 1 word, 2 crc, 3-4 serial 2 word, 5 crcCode:SHTAdr=$88
SHTCmd=$89
I2CREAD S_SDA1,S_SCL1,SHTAdr,SHTCmd,[SHTArray[0],SHTArray[1],SHTArray[2],SHTArray[3],SHTArray[4],SHTArray[5]]
2.Start conversion
3. Read Temp and RH data after 20mSCode:SHTAdr=$88
SHTCmd=$FD
I2CWRITE S_SDA1,S_SCL1,SHTAdr,SHTCmd,SensorFailNoAck
0-1 hold temp, 2 hold crc, 3-4 hold humidity, 5 hold crc.Code:SHTAdr=$88
I2CREAD S_SDA1,S_SCL1,SHTAdr,[SHTArray[0],SHTArray[1],SHTArray[2],SHTArray[3],SHTArray[4],SHTArray[5]]
If I add SensorFailNoAck, then it trigers every time, not sure why... I'll use crc to check for correct communication.
CRC8 routine:
Need to check calculation from ticks to T[°C] and RH[%].Code:CalcCRC:
crc=$ff
for byteCtr = 0 to 1
TmpB=CRCArray[byteCtr]
crc = crc ^ TmpB
for i = 0 to 7
if crc.7=1 then
crc = (crc << 1)
crc = crc ^ $31
else
crc =crc << 1
endif
next i
next byteCtr
And to try to understand heater... How and why to use it.