adafruit / Adafruit-MLX90614-Library

Arduino library for the MLX90614 sensors in the Adafruit shop
Other
128 stars 97 forks source link

The MLX90614 reports widely incorrect data after setting emissivity #43

Closed TheStranger25 closed 1 year ago

TheStranger25 commented 1 year ago

Hello everyone, I am using this library to use a MLX90614 on ESP8266.

For a couple of days I’ve been trying to solve a problem that involves setting emissivity dynamically. I have already read the closed issue #32 in which it is explained that doing it dynamically is not very reliable but in my case it is essential. I tried various ways like: reset the card after setting the emissivity in a zone that is not the Setup() or tried to call the function SetEmissivityReg setting the register 0x04 to 0 as per manual (which makes no sense as it is already done in the SetEmissivity() library).

Here is the problem described step by step:

Here are some: image image

caternuson commented 1 year ago

This support will need to be taken care of in user code. As discussed in the other issue thread linked above, the MLX requires a power cycle after setting emissivity.

You'd need to do something like the other poster did:

For an immediate countermeasure, I am tying the MLX90614 GND pin to a digital output pin D4 on my MCU. After writing the emissivity, I raise D4 high, wait 50ms, and lower D4 again.

However, this library generally is not setup to handle power cycles. So you may also need to reinitialize sensor state after the power cycle.

TheStranger25 commented 1 year ago

I also tried to raise the pin D4 (2) to which the mass is connected, wait 100ms and then lower it again but this did not work. It didn’t even work by adding an ESP.Reset(); Turning off the power completely can work but not always, sometimes you have to do it several times, not very reliable. How should I reinitialize sensor state after the power cycle.

caternuson commented 1 year ago

Just realized there's an example for setting emissivity: https://github.com/adafruit/Adafruit-MLX90614-Library/blob/master/examples/mlx_set_emissivity/mlx_set_emissivity.ino But it simply covers setting.

To reinitialize, call mlx.begin() again after power cycling. And possibly waiting a brief period of time to allow the MLX to come up after the power cycle. However, the begin() method doesn't really do anything in terms of actual MLX initialization: https://github.com/adafruit/Adafruit-MLX90614-Library/blob/367bc379c981a7b815cb5f3db3488f0af4576f8a/Adafruit_MLX90614.cpp#L32-L38

So it might work OK to skip that.

TheStranger25 commented 1 year ago

So...which is the solution?

caternuson commented 1 year ago
Turning off the power completely can work but not always, sometimes you have to do it several times, not very reliable.

What is the behavior when it does not work? How do you know when it finally works?

How should I reinitialize sensor state after the power cycle.

Depends on what all gets power cycled. If it's just the MLX, maybe no need to reinitialize. Just start querying data from it again.

TheStranger25 commented 1 year ago

What is the behavior when it does not work? How do you know when it finally works?

When it doesn't work anymore I notice it because the ambient temperature exceeds 600 degrees while that of the object goes below -140 degrees, while when it works the temperatures are around 25 degrees

TheStranger25 commented 1 year ago

I found a method to avoid setting the emissivity several times and the following adjustments were necessary: