atc1441 / ATC_MiThermometer

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

LCD going off after some time / when under a specific Temperature #11

Closed 6Xkljk8Vj7Tk1k4 closed 3 years ago

6Xkljk8Vj7Tk1k4 commented 4 years ago

Hi,

I try to flash LYWSD03MMC with following firmware: ATC_Thermometer_custom.bin. However after some time (like 60 seconds) LCD is going off - it is still possible to connect/send firmware using TelinkFlasher.

With ATC_Thermometer LCD is on only on "bootup" process then it goes off and doesn't show temperature.

With stock firmware LCD is on and shows temperature all the time...

Please advise.

Best Regards

atc1441 commented 4 years ago

Hey, it seems @leahneukirchen also hat that problem with one Thermometer,

did you try to reinsert the battery?

there is one unknown pin goin to the lcd controller and it may have something to do with that.

my devices all work fine so its hard for me to debug

leahneukirchen commented 4 years ago

I have one running your firmware, which went out in the freezer and came back fine later.

I have one running on stock firmware again which showed this behavior, it went out after 5-30s with your firmware after power cycling.

In general, power cycling made the display work again, but then it went off with the latter one again.

atc1441 commented 4 years ago

Do any one of you may have the possibility to open one ?

that way its could be compared against the other ones to see if they are a different revision

leahneukirchen commented 4 years ago

I need to find such a small torx, maybe I have one at work. Gonna take a few days.

I ordered both in the same shipment, I can compare the numbers on the back next wekk.

6Xkljk8Vj7Tk1k4 commented 4 years ago

I took few more from my order and they work as expected. I had a problem with one more, however after turn off and on again it shown temperature. Anyway the first one is still off, switching on/off, reflash or battery replace didnt help. board1 board2

:)

atc1441 commented 4 years ago

Thank you for the images. My boards are exactly the same.

Must be something else

benek984 commented 4 years ago

I have flashed my 14 sensors and all are experience that same issue. After several minutes screen freeze and doesn't display current temperature correctly. Power cycle fixing the issue but just for a another several minutes. I haven't have this problem on the stock firmware.

bbbenji commented 4 years ago

I flashed 4 of my sensors, and one of them is experiencing the aforementioned screen blanking. Reinserting the battery fixes it, but only temporarily. It may have to do with the fact I use that one in the fridge as I pulled it out this morning and it hasn't blanked yet. I will swap it with another and see if I can replicate the issue.

benek984 commented 4 years ago

I have flashed my 14 sensors again this morning using the latest .bin file. After flashing I set them to as follow: Smiley: OFF Advertising Type: Mi Like Show battery in LCD: Disabled Advertising interval: 10 Seconds

So far all good, sensors doesn't freeze anymore and reporting back to my Home Assistant by connecting via ESPHome BLE_tracker and xiaomi_cgg1 platform.

example of my configuration:

esp32_ble_tracker: sensor:

bbbenji commented 4 years ago

Reporting back that the thermometer that was working fine for days now, blanked after 30min of being in the fridge. I suspect it has to do with low temperatures. Will try another thermometer.

benek984 commented 4 years ago

Reporting back that the thermometer that was working fine for days now, blanked after 30min of being in the fridge. I suspect it has to do with low temperatures. Will try another thermometer.

try my settings:

Smiley: OFF Show battery in LCD: Disabled

This prevent sensor on blinking between two screens (battery or humidity) in my case those settings have solved the issue.

bbbenji commented 4 years ago

@benek984 Unfortunately those settings did not help. I can quite consistency reproduce the screen blanking by placing any of my 4 thermometers in the fridge. Need to try using ATC format, using Mi at the moment.

atc1441 commented 4 years ago

@bbbenji ok the not showing of data on the lcd when in freezer is also same for me. Havent tested that with stock firmware but i think that is display related. If i press on the lcd when in freezer it comes back while pressing it.

Dies this work as well?

bbbenji commented 4 years ago

Pressing the screen does not do anything for me. Sounds like a hardware issue. However, my fridge is approx. +6 degrees celsius, well within the spec'ed range. I have not tested stock firmware yet.

Edit:

Also, letting it come up to room temperature does not help, only reinserting the battery does, and it can't be too fast. Seems the caps need to discharge first.

atc1441 commented 4 years ago

Tested a bit further, Stock vs. Custom rom in freezer, the display of the Stock rom stays on the custom not 20200908_111931

Hard to do an i2c capture while in freezer, i could imagine they set the voltage of the lcd controller higher when under a specific °C

atc1441 commented 4 years ago

Looking further onto the PCB i following the unknown pin i already mentioned and will try to capture if that one has something to do with it.

20200908_115524

atc1441 commented 4 years ago

20200908_130408

Good news, setting that pin (PB6) to a level and not leaving it floating fixed the issue :) The 2 on the left are the new firmware the one on the right the old custom version https://github.com/atc1441/ATC_MiThermometer/blob/master/ATC_Thermometer/main.c#L30

Its already updated in the repo and can be flashed.

nikito7 commented 4 years ago

Still an issue at 26° on one sensor

atc1441 commented 4 years ago

Thank you for the info. Is it instant off after inserting the battery or how is the behavior?

nikito7 commented 4 years ago

After new flash. When I connect I waiting 60s its ok, then connect with flasher turn off.

Maybe related with some ble discovery

Because now, after insert battery, goes off 10-20s after

nikito7 commented 4 years ago

Now after blink one time 28° Maybe temperature related.

I flashed stock again, and then custom, I never reached the 60s as the first time

nikito7 commented 4 years ago

At 17°C works fine....

leahneukirchen commented 4 years ago

I flashed the firmware of HEAD on the Mi that went dark quickly, and it turns off immediately after the MAC now... Bluetooth works fine.

I also opened it and wiggled the LCD connector a bit, but I think that is not the issue, as it displays fine in the begining.

(Display was fine with the stock firmware, too.)

nikito7 commented 4 years ago

Maybe are clones I have one with a "very soft purple" background lcd

leahneukirchen commented 4 years ago

Indeed, the LCD colors are different. The working one is "very soft purple", the non-working one is "dark greenish".

nikito7 commented 4 years ago

The problem is above 20°C

It's working at -10°C (-9.9 on lcd)

Cold kills battery fast :)

leahneukirchen commented 4 years ago

It was only cold for a few minutes. But we have 20°C inside, so....

nikito7 commented 4 years ago

Maybe less

Put in freezer, remove/reinsert the battery less 15° because hot hands

My works that way. If I take it out freezer. Go blank after a while

leahneukirchen commented 4 years ago

Powercycled it at 11.8°C, display came back; warmed up in ~15min to 20°C. Still on.. let's see.

leahneukirchen commented 4 years ago

Went out at ~20.5°C again. :(

nikito7 commented 4 years ago

Maybe is the Humidity...

21.3°C 78% still on

leahneukirchen commented 4 years ago

Humidity fell to 60%.

atc1441 commented 4 years ago

I could also imagine that the display needs to be set into a different mode on different temperatures. So like pull pin low on low temp and high on high temp.

A reinit of the lcd is needed after setting a different level on that pin. But that shouldnt be a problem to do.

To bad there is no info on the lcd controller

atc1441 commented 4 years ago

On mine i had only problems on very low temp so far maybe someone can upload an comparison of the two lcds in one picture

If i pull the pin low now in the current firmware, when pulled high on tests the display was turning of after the mac showing just like you mentioned @leahneukirchen

leahneukirchen commented 4 years ago

Perhaps expose the pin over bluetooth so we noobs can toggle it over the browser. :)

nikito7 commented 4 years ago

10s broadcast maybe faulty

the event: 20200909_205456

atc1441 commented 4 years ago

@leahneukirchen only toggle would help to much as the init is needed. So needed compine that somehow first :-/

@nikito7 can you explain that a bit more? I can imagine that the newly added alarm do somethong wrong there, it will do an instant advertise if the Temp or Humi changes more than 0.5C / 5% between a main loop delay (5-6 seconds), there is a bug in it that will advertise twice if in the same loop a timed advertising was happening. Will change that

atc1441 commented 4 years ago

@nikito7 fixed that particular bug right now

nikito7 commented 4 years ago

chart was for lcd off event

atc1441 commented 4 years ago

Yeah should not fixed that one. Only changed the instant advertising.

Will look deeper into what the stock firmware is doing with the pin. Maybe even capture some data while im freezer with a wire to a logic analyzer or something.

nikito7 commented 4 years ago

Can you confirm that 10s broadcast is working?

If working. Esphome or homeassistant is filtering data

atc1441 commented 4 years ago

@nikito7 yes can confirm that it does work at 10s interval just tested it again. Its 10-15 Seconds to be precise as its only tested for the interval if the main loop interval was overflowed as well.

There is a problem with interval bigger than 3minutes but that will be fixed later.

Calcu2006 commented 4 years ago

Hi benek984

I did everything like you, but maybe i'm forgetting something... i can read the values in MQTT.. can you please put an example about how are you reading it?

I created this sensor:

but status is always unknown..., what i'm missing ?

Thanks for answering!

I have flashed my 14 sensors again this morning using the latest .bin file. After flashing I set them to as follow: Smiley: OFF Advertising Type: Mi Like Show battery in LCD: Disabled Advertising interval: 10 Seconds

So far all good, sensors doesn't freeze anymore and reporting back to my Home Assistant by connecting via ESPHome BLE_tracker and xiaomi_cgg1 platform.

example of my configuration:

esp32_ble_tracker: sensor:

* platform: xiaomi_cgg1
  mac_address: "A4:C1:38:BD:89:4E"
  temperature:
  name: "Bedroom Temperature"
  humidity:
  name: "Bedroom Humidity"
  battery_level:
  name: "Bedroom Battery Level"
nikito7 commented 4 years ago

Hi benek984

I did everything like you, but maybe i'm forgetting something... i can read the values in MQTT.. can you please put an example about how are you reading it?

I created this sensor:

  • platform: mqtt name: "testing pc" state_topic: "esp_entrada/sensor/temperatura_ordenador/state" unit_of_measurement: "°C"

but status is always unknown..., what i'm missing ?

Thanks for answering!

Use api in esphome.yaml

api: password: pass

And add integration "esphome" in homeassistant

edit: -Or you miss mqtt integration -Ip address changed -reboot

That should be easy, its auto discovery No edit yaml needed in homeassistant

benek984 commented 4 years ago

Hi Calcu2006,

I use ESPHome plugin with Home Assistant, to read values from sensors I have ESP32 board with ESPHome on board. As mentioned by nikito7 this will autodiscover sensors added to the ESP32 config so you don't need to edit your yaml config file in home assistant. Example config below:

esphome: name: esp32_ble_01 platform: ESP32 board: nodemcu-32s

wifi: ssid: "xxxx" password: "xxx" power_save_mode: none use_address: 192.168.10.135

Enable fallback hotspot (captive portal) in case wifi connection fails

ap: ssid: "xxx" password: "xxx"

captive_portal:

Enable logging

logger:

Enable Home Assistant API

api: password: "xxx"

ota: password: "xxx"

web_server:

Enable Bluetooth scanning for this ESP32

esp32_ble_tracker:

sensor:

Calcu2006 commented 4 years ago

Thanks, i was creating MQtt sensors... now everything works, thanks again !

rnizametdinov commented 4 years ago

Same issue - revert to stock firmware

giannoug commented 4 years ago

Same issue here. Right after flashing, the boot screen appears (showing "Atc", happy face and mac), then screen turns off. This is what happens all of the time, but it stayed a couple of seconds in the temperature / humidity screen once.

atc1441 commented 4 years ago

I compiled a version now where it pulls the LCD pin high and not low, maybe someone who has the error can flash it and test it, that way we would know if looking into that direction would help. especially @rnizametdinov and @giannoug

Edit. File deleted to prevent miss flashes

giannoug commented 4 years ago

@atc1441 Just flashed ATC_Thermometer_LCD_HIGH.bin. Doesn't seem to fix the issue. It goes to blank screen straight after booting