Posts: 81
Joined: Mon Aug 08, 2022 2:02 am

Adafruit SHT45 Temp Sensor.

Wed Jun 07, 2023 6:29 pm

Hello great minds,
I have purchased a SHT45 from Adafruit.

I'm kind of a nutcase for precision so I bought this to replace some of my trusty DHT22's. (tbh they are pretty accurate already but I digress).

I figured I could take either Adafruits Arduino code or better yet the simpler option of editing the files from the vendor in pure C using the SDK. I program in C (still not great at it), and know a little C++. Basically, the only thing you need to per the vendor is make some changes to implement the I2C calls using the SDK of the given MCU.

I thought ok I can stumble my way through this. HA! That was a complete failure I didn't get anywhere. All of my Pico adventures have been done in pure C using the SDK. This one has me stumped I do not know how to properly build this in C. Is anyone willing to take a stab and provide a functional C/SDK version for the Pico, I looked on GitHub and found no examples. I'll gladly buy ya a cup of coffee or two! If someone can help me out. I have 3 of these sensors now sitting around useless because of my inept skills in programming.

Hoping someone can help me get started. C/Visual Studio Code is my programming is my platform.

(I am slowly starting to learn MPY because it seems like everyone uses it and makes things much simpler).

Hoping someone has the time to help a newbie out :)


Posts: 14352
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Adafruit SHT45 Temp Sensor.

Sat Jun 10, 2023 1:05 pm

anglerfish27 wrote:
Wed Jun 07, 2023 6:29 pm
I do not know how to properly build this in C.
Nor me so I simply grabbed the 'sht4x.h' and 'sht4x.c' files, hacked about and created a 'glue.h' and 'glue.c' to make it build without errors.

This is what I have which builds for me but is incomplete. I don't know how useful that is but it may help you on your way -
(5.48 KiB) Downloaded 19 times

You would need to look around in the GitHub to discover what the functions in 'glue.c' need to be and adjust the 'glue.h' header and the #define for SENSIRION_NUM_WORDS which is most likely wrong.

Posts: 81
Joined: Mon Aug 08, 2022 2:02 am

Re: Adafruit SHT45 Temp Sensor.

Fri Jun 16, 2023 10:12 pm

Nice, thank you!! I will take a poke at this. Sorry for the delayed response, haven't had a lot of free time. What kills me is for giggles i installed python from Adafruit and its Wiresnapper setup (basically automagically connects your picoW to adafruits IoT site. I was able to drag and drop a PicoW and a SHT45 on the website and it displayed the values of my SHT45. Crazy stuff. They can automate all that down to literally just a username and password but can't provide a true pure C implementation. Sigh. It was cool for about 5 minutes seeing it working. Knowing my lack of proper i2c functions was the only thing blocking me from using the company's C code. Regardless of if this works THANK YOU for sharing !! If it doesn't work I hope one day someone who knows C like a rockstar writes an implementation for the Pico. Time will tell...likely not.


Return to “SDK”