6 #ifndef __SENSORS_SHT10_h__
7 #define __SENSORS_SHT10_h__
10 #include <Sensirion.h>
14 enum Sht10Mode { LOWRES_INT=0x01, LOWRES_FLOAT=0x02, HIGHRES=0x03 };
17 template <u
int8_t DATAPIN,u
int8_t CLOCKPIN,Sht10Mode MODE=Sht10Mode::LOWRES_INT>
22 #if defined(TwoWire_h) || defined(_WIRE_H_)
23 if( DATAPIN == A4 && CLOCKPIN==A5 ) {
30 #if defined(TwoWire_h) || defined(_WIRE_H_)
31 if( DATAPIN == A4 && CLOCKPIN==A5 ) {
37 bool meas(uint16_t& tdata,uint16_t& hdata) {
40 success = (_sht10.measTemp(&tdata) == 0) && (_sht10.measHumi(&hdata) == 0);
47 Sht10 () : _sht10(DATAPIN,CLOCKPIN) {}
51 uint8_t sr = MODE == Sht10Mode::HIGHRES ? 0 : LOW_RES;
52 _present = (_sht10.writeSR(sr) == 0);
56 void measure (__attribute__((unused))
bool async=
false) {
57 if( present() ==
true ) {
59 if( meas(tdata,hdata) ==
true ) {
60 if( MODE != Sht10Mode::LOWRES_INT ) {
61 float t = _sht10.calcTemp(tdata);
62 _temperature = t * 10;
63 _humidity = _sht10.calcHumi(hdata,t);
68 int32_t tt = ((4L * tdata) - 4010);
77 int32_t hh = ((5872L * hdata) - 20468L) - (4L * hdata * hdata);
78 hh = (((tt - 2500) * (100L + (12L * hdata)) / 100) + hh) / 10000;
79 hh = hh > 100 ? 100 : hh;
82 _temperature = tt / 10;