mcauser / micropython-mlx90614

MicroPython driver for the MLX90614 IR temperature sensor
MIT License
33 stars 14 forks source link

Huge temperatures #7

Closed MauroDiamantino closed 2 years ago

MauroDiamantino commented 3 years ago

Hello, I've tried to use this module but I got huge temperature values, around 1000ºC. Which could it be the reason? Does this module work with single zone MLX90614 sensor?

MauroDiamantino commented 3 years ago

I found a solution: https://forum.micropython.org/viewtopic.php?f=14&t=2433&p=61684#p61684

JamieMackenzieUoA commented 2 years ago

I am having this same issue. All reads from the sensor return \xFF\xFF.

My I2C frequency is set to 100kHz and I have the required pull-ups on the data lines.

Any suggestions?

mcauser commented 2 years ago

Temp 1037.55 C is indeed caused by read16() returning \xFF\xFF. \xFF\xFF == 65535 (65535 * 0.02) - 273.15 == 1037.55

Since the sensor temp maxes at 125 and the object temp at 380, perhaps I should make the read16 throw an error instead of returning a seemingly valid >1000 result.

If you are using the GY-906 module, it has 2x 4.7kΩ pull ups on the back, so you shouldn't need extra ones.

You could try dropping the I2C frequency even further to see how it reacts.

Does the module show up in an i2c.scan()?

What microcontroller are you using? and which I2C pins?

Are you powering it with 3V or 5V?

What version of micropython?

Do you know specifically which version of the MLX90614 sensor your module is using? eg. BAA

JamieMackenzieUoA commented 2 years ago

I am using the sensor from Adafruit (https://www.adafruit.com/product/1747) with the included 4.7k pullups. The specific sensor is the MLX90614ESF-BAA and I'm powering with 3.3V.

I have tried a frequency of 50kHz, but will try lower...

Yes, the sensor shows up fine on i2c.scan() and the correct address (0x5a).

I am using the PyBoard D-series (https://pybd.io/hw/pybd_sfxw.html) with the i2c = I2C('Y', freq=100000) command.

I will have to check version when I'm in the office tomorrow and report back. It's a fresh PyBoard but don't know if they come with latest or legacy versions.

JamieMackenzieUoA commented 2 years ago

OK, have tried adjusting the frequency all the way down to 10kHz, with no change in the output.

The micropython version is: MicroPython v1.10-445-ga9b1d3ca3

I had a look and the current version is 1.17 from what I can see, so this one seems fairly old. I'll figure out how to update and give it another test.

JamieMackenzieUoA commented 2 years ago

That did the trick! All seems to be working now.

In case others have the same issue, I found this to be the best explanation of how to update the firmware:

https://learn.sparkfun.com/tutorials/how-to-load-micropython-on-a-microcontroller-board/pyboard

It's a bit old, but still worked for me.

One last gotcha that had me stumped for a bit was that, with the newer firmware, you need to explicitly enable the 3.3V output on the PyBoard to power the I2C peripherals using this command: machine.Pin('EN_3V3').on()

mcauser commented 2 years ago

Glad you got it sorted!

Power control in the docs: https://pybd.io/hw/pybd_sfxw.html#power-control

Theres onboard 5.6k pull ups you can use too: https://pybd.io/hw/pybd_sfxw.html#i2c-buses

JamieMackenzieUoA commented 2 years ago

Thanks! Those are both really useful to know.