Comments on: Connecting MLX90614 infrared thermometer to the Raspberry PI https://olegkutkov.me/2017/08/10/mlx90614-raspberry/ Programming, electronics and diy projects Wed, 06 Mar 2024 01:36:03 +0000 hourly 1 https://wordpress.org/?v=6.5.3 By: Robert O https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-2270 Wed, 06 Mar 2024 01:36:03 +0000 http://olegkutkov.me/?p=25#comment-2270 Really helped me with my project. Thank you

]]>
By: Oleg Kutkov https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1419 Mon, 06 Feb 2023 20:00:13 +0000 http://olegkutkov.me/?p=25#comment-1419 In reply to Team.

The whole article is about using MLX90614 with Raspberry Pi

]]>
By: Team https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1418 Mon, 06 Feb 2023 19:49:33 +0000 http://olegkutkov.me/?p=25#comment-1418 Is the MLX90614 compatible with the Raspberry Pi?

]]>
By: Oleg Kutkov https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1355 Sat, 16 Jul 2022 23:53:19 +0000 http://olegkutkov.me/?p=25#comment-1355 In reply to Stephen Petersen.

The sensor is mounted on the box with Raspberry PI and other electronics inside.
It just tightly sits in a hole and is secured with sealant.

]]>
By: Stephen Petersen https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1354 Sat, 16 Jul 2022 23:47:46 +0000 http://olegkutkov.me/?p=25#comment-1354 In reply to Oleg Kutkov.

Thanks for the very quick response. Are you using a cable gland or something similar?

]]>
By: Oleg Kutkov https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1353 Sat, 16 Jul 2022 23:46:21 +0000 http://olegkutkov.me/?p=25#comment-1353 In reply to Stephen Petersen.

Hello. That’s correct.
I’m using my MLX sensor outdoor without any cover on the top. It’s waterproof. Sure, bottom contacts are hidden inside a box, but the top panel window is exposed to the open sky.

]]>
By: Stephen Petersen https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1352 Sat, 16 Jul 2022 23:42:09 +0000 http://olegkutkov.me/?p=25#comment-1352 I read somewhere that for the sensor to be accurate, you have to expose it to the sky without anything like a plastic dome to cover it. If that is correct, how do you do that? TIA!!

]]>
By: Oleg Kutkov https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1312 Thu, 09 Jun 2022 19:25:23 +0000 http://olegkutkov.me/?p=25#comment-1312 In reply to farm2440.

Thank you for your comment. Fixed!

]]>
By: farm2440 https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1311 Thu, 09 Jun 2022 19:16:46 +0000 http://olegkutkov.me/?p=25#comment-1311 VSS – power supply (3.3 or 5 volts). : Watch out!!! This is wrong! VSS is ground and VDD is positive power supply.

]]>
By: Kulwant Singh https://olegkutkov.me/2017/08/10/mlx90614-raspberry/#comment-1099 Sat, 04 Dec 2021 00:29:08 +0000 http://olegkutkov.me/?p=25#comment-1099 Hi Oleg!
I’m hoping you are still reading this and can help me with an issue I’m having with setting emissivity on 90614DCC sensor.

I’m following the steps in MLX90614-Changing-Emissivity-Unlocking-Key-Application-Note-Melexis section 6.2. I’m able to read and write to the EEPROM locations as specified except for the very first step which is to “Enter EEPROM address 0x0F unlock key”.
I have tried reading from 0x60 (as listed in opcode column) but this address doesn’t exist so there’s an error. Also tried writing 0x0F to 0x60 but that didn’t work either.
If I skip this step and follow the rest of the steps as following, new values written are not saved. I read old values back:
-Write 0x0000 to 0x24 (Erase emissivity)
– write new emissivity to 0x24
– read back emissivity (Reads old value, not new)
– write 0x0000 to 0x2F (Erase )
– write new value to 0x2F
– read 0x2F (returns old value, not new)

I’m wondering if there is an error in the datasheet section 6.2.1 “Enter EEPROM address 0x0F unlock key” or whether I am doing something wrong.

Any ideas to try out are appreciated.

Code:
from time import sleep
import smbus

class MLX90614():

# RAM offsets with 16-bit data, MSB first
# Raw data IR channel 1
MLX90614_RAWIR1 = 0x04
# Raw data IR channel 2
MLX90614_RAWIR2 = 0x05
# Ambient temperature
MLX90614_TA = 0x06
# Object 1 temperature
MLX90614_TOBJ1 = 0x07
# Object 2 temperature
MLX90614_TOBJ2 = 0x08

# EEPROM offsets with 16-bit data, MSB first
# Object temperature max register
MLX90614_TOMAX = 0x20
# Object temperature min register
MLX90614_TOMIN = 0x21
# PWM configuration register
MLX90614_PWMCTRL = 0x22
# Ambient temperature register
MLX90614_TARANGE = 0x23
# Emissivity correction register
MLX90614_EMISS = 0x24
# Configuration register
MLX90614_CONFIG = 0x25
# Slave address register
MLX90614_ADDR = 0x2E
#EEPROM Unlock key
MLX90614_UNLOCK_KEY = 0x2F
# 1 ID register (read-only)
MLX90614_ID1 = 0x3C
# 2 ID register (read-only)
MLX90614_ID2 = 0x3D
# 3 ID register (read-only)
MLX90614_ID3 = 0x3E
# 4 ID register (read-only)
MLX90614_ID4 = 0x3F

comm_retries = 5
comm_sleep_amount = 0.1

def __init__(self, bus_num = 1, address=0x5A):
self.address = address
self.bus = smbus.SMBus(bus=bus_num)

def read_reg(self, reg_addr):
err = None
for i in range(self.comm_retries):
try:
return self.bus.read_word_data(self.address, reg_addr)
except IOError as e:
err = e
# "Rate limiting" - sleeping to prevent problems with sensor
# when requesting data too quickly
sleep(self.comm_sleep_amount)
# By this time, we made a couple requests and the sensor didn't respond
# (judging by the fact we haven't returned from this function yet)
# So let's just re-raise the last IOError we got
raise err

def write_reg(self, reg_addr, data):
err = None
for i in range(self.comm_retries):
try:
return self.bus.write_word_data(self.address, reg_addr, data)
except IOError as e:
err = e
# "Rate limiting" - sleeping to prevent problems with sensor
# when requesting data too quickly
sleep(self.comm_sleep_amount)
# By this time, we made a couple requests and the sensor didn't respond
# (judging by the fact we haven't returned from this function yet)
# So let's just re-raise the last IOError we got
raise err

def read_temp(self, reg):
data = self.read_reg(reg)
temp = (data * 0.02) - 273.15
return temp

def get_ambient(self):
return self.read_temp(self.MLX90614_TA)

def get_object_1(self):
return self.read_temp(self.MLX90614_TOBJ1)

def get_object_2(self):
return self.read_temp(self.MLX90614_TOBJ2)

def get_emmissivity(self):
return self.read_reg(self.MLX90614_EMISS)

def get_unlock0F(self):
return self.read_reg(self.MLX90614_UNLOCK_KEY)

def set_unlock0F(self, data):
return self.write_reg(self.MLX90614_UNLOCK_KEY, data)

def set_emmissivity(self, data):
#self.read_reg(self.MLX90614_UNLOCK_KEY)
self.write_reg(self.MLX90614_EMISS, 0x0000)
return self.write_reg(self.MLX90614_EMISS, data)

if name == “main“:

#bus = smbus.SMBus()
IRTemp = MLX90614(1)

print("TO Max: ", IRTemp.read_temp(IRTemp.MLX90614_TOMAX))
print("TO Min: ", IRTemp.read_temp(IRTemp.MLX90614_TOMIN))
print("Ambient Temperature (deg. C): ", IRTemp.get_ambient())
print("Object Temperature (deg. C): ", IRTemp.get_object_1())

emissOld = IRTemp.get_emmissivity()
print("Old Emmissivity: ", emissOld)
print("unlock 0x60 read: ", IRTemp.read_reg(0x0F))
print(IRTemp.write_reg(0x60, 0x0F))
unlockOld = IRTemp.get_unlock0F()
print("unlock Old: ", unlockOld)
#calculate emmissivity
#Treal = float(input("Real object Temp:"))
#Areal = float(input("Real ambient Temp:"))
Treal = 25.4
Areal = 28.9
Tsens = IRTemp.get_object_1()
Asens = IRTemp.get_ambient()

emiss = ((Tsens+273.15)**4 - (Asens+273.15)**4)/((Treal+273.15)**4 - (Areal+273.15)**4)
emissReg = round((2**16)*emiss - 1)
emisshex = hex(emissReg)

print(f"calculated emmiss:{emiss}, reg value: {emissReg}, hex:{emisshex}")
unlockNew = round(emissOld*unlockOld/emissReg)

print("New Emmissivity: ", emissReg)
print("New Unlock: ", unlockNew)
print("unlock 0x60 read: ", IRTemp.read_reg(0x0F))

IRTemp.set_emmissivity(emissReg)
print("Read Emmissivity: ", IRTemp.get_emmissivity())
IRTemp.set_unlock0F(0x0000)
IRTemp.set_unlock0F(unlockNew)
print("Read Unlock: ", IRTemp.get_unlock0F())

]]>