as the data is offset by 2 leading bits. As such the sign is picking off the wrong bit, which inadvertently makes the temperature sign dependent on the value of the RH reading.
My experience is that these sensors almost always fail on the first read as if there is some sort of initialization that the datasheet doesn't document. After that they always seem to read OK as long as the read rate is limited to 2 Hz per data sheet. Earlier code did not include the 500 ms delay (line 42) between repeat reads, which may explain some of the speed dependencies and why lengthening the read delay in earlier code helps (noted in another thread).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The negative temps readings are due to an error in line 39 of the module.
should be
as the data is offset by 2 leading bits. As such the sign is picking off the wrong bit, which inadvertently makes the temperature sign dependent on the value of the RH reading.
My experience is that these sensors almost always fail on the first read as if there is some sort of initialization that the datasheet doesn't document. After that they always seem to read OK as long as the read rate is limited to 2 Hz per data sheet. Earlier code did not include the 500 ms delay (line 42) between repeat reads, which may explain some of the speed dependencies and why lengthening the read delay in earlier code helps (noted in another thread).