RobTillaart / CHT8305

Arduino library for CHT8305 temperature and humidity sensor
MIT License
4 stars 1 forks source link

Mod to support CHT8310? #14

Closed YouCanNotBeSerious closed 5 months ago

YouCanNotBeSerious commented 5 months ago

Hi -

I am repurposing a generic white label Tuya sensor by changing the BK7231 module out for an ESP32-C3 module, and running custom Ardunio code. The sensors I have use a CHT8310 chip.

I found your work here, and wonder if with the information in this link you would be able to modify the calculation part to support the 8310 sensor ? In that thread are PDF extracts that make It seem like the numbers coming from the sensor are different to the 8305 and "just" need some different math (hopefully it's that simple!)

I also found this code contribution.

Naturally i would test and report back both the 8310 results and use on the ESP32 if you were able to do this.

Thanks!

YouCanNotBeSerious commented 5 months ago

Found the full datasheet here - there are plenty of 4 page versions around without the protocol detail...

RobTillaart commented 5 months ago

Thanks for the question, I will look into this tomorrow if time permits.

There are two possible ways, as a derived class or a stand alone project, depending if they are more or less close. To be continued

RobTillaart commented 5 months ago

Analysis

I had a quick look and the register maps are quite different

CHT8305 datasheet (oct 2017 - rev 1.1) image

CHT8310 datasheet (april 2023 - rev 1.0) image

Temperature and humidity registers are on the same index (but different math) The other registers do not match.

Conclusion

The sensors are too different to make a derived class. Patching the 8305 library with only different math for T and H will result in problems with other registers causing more patches / maintenance.

So the only solution is to design and implement a separate library for the CHT8310. The interfaces could be kept similar where possible of course.

RobTillaart commented 5 months ago

note: There is a whole family CHT83xx - there might be compatible ones. image

RobTillaart commented 5 months ago

A minimal class for the CHT8310 would

RobTillaart commented 5 months ago

Created such a minimal class - https://github.com/RobTillaart/CHT8310 (under development)

RobTillaart commented 5 months ago

@YouCanNotBeSerious Released a 0.1.0 version of the CHT8310 library - https://github.com/RobTillaart/CHT8310 It is pretty minimal and should get you started. If there are problems, please open an issue under that repo.

YouCanNotBeSerious commented 5 months ago

@YouCanNotBeSerious Released a 0.1.0 version of the CHT8310 library - https://github.com/RobTillaart/CHT8310 It is pretty minimal and should get you started. If there are problems, please open an issue under that repo.

Wow! Thanks - I will test as soon as I ...ahem... repair my temperature sensor hardware (don't ask!). I also have more units arriving any time now if I can't undo my mistake :-)

RobTillaart commented 5 months ago

@YouCanNotBeSerious

Welcome, it is an interesting sensor and by stripping (a copy) of the CHT8305 I had 50% in place. Still it took a few hours to get it to (beta?) release level, and now there is a reasonable base to start the tests.

I close the issue here, so please open an issue under the cht8310 repo to continue the discussion.