atc1441 / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter
2.78k stars 467 forks source link

Transmitting sub-zero (negative) temperatures #97

Closed Einstein67 closed 3 years ago

Einstein67 commented 3 years ago

Hello and thanks for this great software.

I know the specification of this sensor is 0-60 degrees. But the sensor also measures negative values without any problems and shows them correctly in the display. However, incorrect values are then sent.

Stock firmware sends a value of "+ 654.78 ° C" at "-1.6 ° C" ATC firmware sends "+ 6532.2 ° C" for the same measured value

Can the measuring range be extended to -9.9 ° C (Limitation of the characters in the display)? It seems that the sensor could, but the communication isn't designed for it.

Or am I making a mistake?

Thanx

atc1441 commented 3 years ago

Hey,

that sounds like you are parsing the Temp as an UINT16_T and not as an INT16_T as it is intened.

When negative values are send the first bit is 1 which indicates negative with an INT value but it represends a very high number at an UINT

hope that helps

Einstein67 commented 3 years ago

Ok, then that needs to be fixed in Tasmota.

Incidentally, "Telink flasher" also shows a wrong value with original software.

stock

Thanks

atc1441 commented 3 years ago

Good catch with the telink flasher.

Will check on that.

atc1441 commented 3 years ago

Fixed it in the newest WebFlasher

Einstein67 commented 3 years ago

TASMOTA will also be fixed soon

ok

Thanks again

ralf-e commented 3 years ago

TASMOTA will also be fixed soon

how did you configure tasmota for ATC, which esp32 binary for BLE?

Einstein67 commented 3 years ago

I compiled with "#define USE_MI_ESP32" and activated BLE with "SetOption115 1".

ralf-e commented 3 years ago

OK, thanks, that's how it works.

Do you know how many BLE sensors Tasmota can correctly query. I have just run a test with 12 sensors (ATC and one LYWSD02). All 12 are displayed in the Tasmota web interface, but only the first 10 of them are sent to the MQTT server.