Request support for SHT3x sensors
-
- Posts: 14
- Joined: Sun Nov 19, 2023 10:52 am
- Has thanked: 3 times
Request support for SHT3x sensors
Hello,
Is that possible to add that sensor with commands similar to bme280 (ex: sht3x.setup, sht3x.hum, sht3x.temp, sht3x.heater)
https://wiki.dfrobot.com/SHT31%20Digita ... %20SEN0331
Thank you.
Is that possible to add that sensor with commands similar to bme280 (ex: sht3x.setup, sht3x.hum, sht3x.temp, sht3x.heater)
https://wiki.dfrobot.com/SHT31%20Digita ... %20SEN0331
Thank you.
-
- Posts: 5
- Joined: Sat Nov 23, 2024 2:17 am
- Been thanked: 5 times
Re: Request support for SHT3x sensors
I'm guessing I'd like to second this request?
I have been unable to successfully get information from the SHT31. I can send commands to it via the standard I2C calls, and the acknowledgement comes back properly, but have been unable to retrieve any data back from it. I'm unable to really troubleshoot as to why it isn't working as I don't see any way to actually observe the bytes being sent/received to/from the devices.
This doesn't SEEM like it should be all that difficult. Send a command to tell it to read temp and humidity, then read the results. I think I'll find a space Pi laying around and try to sniff the I2C to see if I can figure out what isn't working.
I have been unable to successfully get information from the SHT31. I can send commands to it via the standard I2C calls, and the acknowledgement comes back properly, but have been unable to retrieve any data back from it. I'm unable to really troubleshoot as to why it isn't working as I don't see any way to actually observe the bytes being sent/received to/from the devices.
This doesn't SEEM like it should be all that difficult. Send a command to tell it to read temp and humidity, then read the results. I think I'll find a space Pi laying around and try to sniff the I2C to see if I can figure out what isn't working.
Re: Request support for SHT3x sensors
There's a Circuitpython library for this sensors: https://github.com/adafruit/Adafruit_Ci ... hon_SHT31D
You could try that first with your sensor.
You could try that first with your sensor.
- cicciocb
- Site Admin
- Posts: 2626
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 549 times
- Been thanked: 1861 times
- Contact:
-
- Posts: 5
- Joined: Sat Nov 23, 2024 2:17 am
- Been thanked: 5 times
Re: Request support for SHT3x sensors
Yeah, I've not had a problem using these on any other platform - just can't seem to get it to read the responses from Annex. If I sniff during the annex requests, I see the proper response from the sensors, but can't figure out how to actually get it read from the annex basic. I'm sure it's some form of timing issue.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Nov 29, 2024 7:03 am There's a Circuitpython library for this sensors: https://github.com/adafruit/Adafruit_Ci ... hon_SHT31D
You could try that first with your sensor.
-
- Posts: 5
- Joined: Sat Nov 23, 2024 2:17 am
- Been thanked: 5 times
Re: Request support for SHT3x sensors
So, as an update to this - I was finally able to get some real data coming in. I essentially removed all the pauses and such I was trying, as well as avoiding using 'easy mode' calls like i2c.readregarray, and am able to read the values IF I use single shot mode AND use Clock Stretching on the SHT31.
The code, for now, doesn't verify the CRC (need to research how to actually DO that), so I just assume everything communicated fine. The checks for being greater than zero are because that's how the failures were presenting themselves before.
Code: [Local Link Removed for Guests]
SUB ReadSHT31(addr,temp,rh)
dim results(6)
i2c.begin addr
i2c.write &h2c
i2c.write &h06
i2c.end
i2c.reqfrom addr, 6
for i = 0 to 5
results(i) = i2c.read
next i
if results(0)>0 and results(1)>0 then
temp = (results(0) << 8 + results(1))*315/65535-49 ' Fahrenheit
' temp = (results(0)*256+results(1))*175/65535-45 ' Celcius
end if
if results(3)>0 and results(4)>0 then
rh = (results(3) << 8 + results(4))*100/65535
end if
END SUB
Last edited by CraziFuzzy on Sun Dec 01, 2024 10:06 am, edited 1 time in total.
- cicciocb
- Site Admin
- Posts: 2626
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 549 times
- Been thanked: 1861 times
- Contact:
Re: Request support for SHT3x sensors
Hi, thanks for your code.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Dec 01, 2024 6:20 am So, as an update to this - I was finally able to get some real data coming in. I essentially removed all the pauses and such I was trying, as well as avoiding using 'easy mode' calls like i2c.readregarray, and am able to read the values IF I use single shot mode AND use Clock Stretching on the SN31.
The code, for now, doesn't verify the CRC (need to research how to actually DO that), so I just assume everything communicated fine. The checks for being greater than zero are because that's how the failures were presenting themselves before.
I bought some SHT31 and SHT41 so I'll do some testing when I'll receive them for integrating their support into Annex
- cicciocb
- Site Admin
- Posts: 2626
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 549 times
- Been thanked: 1861 times
- Contact:
Re: Request support for SHT3x sensors
I think that all the SHT3X have the same protocol and all the SHT4x have also the same protocol, BUT I'm not sure that is the same.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Dec 01, 2024 10:36 am Is the code the same for the SHT45?
Anyway, I plan to support both series
-
- Posts: 5
- Joined: Sat Nov 23, 2024 2:17 am
- Been thanked: 5 times
Re: Request support for SHT3x sensors
Based on the lack of quircky timing information in the 4x datasheet, my guess is that it is likely far easier to implement. Annex's readregarray call MAY be all that is necessary - since everything is 1-byte commands, it just will need some retry logic if it gives a NACK back, as that meant it wasn't ready yet.
The conversion formula for raw to relative humidity percent is also different between the series. The SHT31 ranges 0-65535 from 0 to 100%. The SHT41 ranges it from -6 to 119%.
The conversion formula for raw to relative humidity percent is also different between the series. The SHT31 ranges 0-65535 from 0 to 100%. The SHT41 ranges it from -6 to 119%.