Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Limit light level readings from MiFlora sensors #273

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

shane-kerr
Copy link
Contributor

Description

I noticed that periodically one of my MiFlora-monitored plants would report a DLI way too high, which is impossible for my plants. This turned out to be because they were getting a single illumination value that was incredibly high. I tracked it down, and it seems to be something like 400 million, which is suspiciously like 2^32 / 10, which is the maximum value from the sensor (there is a division by 10.0 in the code).

It might be that an all-1 reading has some meaning within the protocol that the library does not account for. Or it might be that the sensors have some bug that sometimes returns that value. I am not sure.

The solution in this PR is a hack, which basically just throws out any illumination value that is unrealistically high. I chose 10 times the maximum daylight value, as listed on the Wikipedia:

https://en.wikipedia.org/wiki/Lux

It should have no impact on properly-functioning sensors returning reasonable values.

So far it has prevented any additional weird values, although it has not yet been running two days.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

@zewelor
Copy link
Owner

zewelor commented Sep 11, 2023

Thanks !

@zewelor zewelor merged commit b69126d into zewelor:master Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants