How to use SHT40

I’m trying to use a SHT40 with a Boron LTE, there is no library in the web IDE for it. I have tried the one from GitHub and it errors. is there any way to change a library for Arduino to one for boron?

I ported the library. It’s in the community libraries as Adafruit_SHT4X_RK.

I don’t have a SHT4x so I’m not 100% sure it works, but it compiles successfully.

This can be your plan B after Rick’s suggestion above.

Hi Isaac and welcome to the community!

I looked at the SHT31 I2C address and they seem the same for the SHT40:

SHT31:

SHT40:

I would try using the SHT31 library (though I have NO experience with either lib/sensors).
Best,
Gustavo.

1 Like

It looks like the SHT3x library might at least partially work. The I2C address is the same (0x44), and the command code to read the data is the same (0xE0). However, it looks like the relative humidity formula is different. Rather than try to figure that out it was easier to just port the correct library.

The only real problem with the SHT4X library is that it needed a src directory. However it also depends on the Adafruit_BusIO library, which I also had to port. It also depends on Adafruit_Sensor, which I had previously ported. Then it needed Particle dependencies in library.properties to pull in the two libraries.

1 Like

when you say it compiled successfully do you mean the library?

The example in the library compiled successfully, which also means the library code compiles with all of the required dependencies resolved.

where can I get the example code?
I’m getting the library from the web IDE.

it works! thanks a million

2 Likes

@isaac2 ,

Thank you for bringing this up. I was looking to add a temperature / humidity sensor to one of my new projects and was not happy with the drivers I found.

I did find this relative to the SHT-40 which uses analog pins so no driver is needed.

https://www.digikey.com/en/products/detail/sensirion-ag/SHT30-ARP-B/5872249

That said, I may end up using the SHT-40 in order to preserve valuable IO pins.

Good luck with your project!

Chip

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.