mcauser / micropython-mlx90614 Goto Github PK
View Code? Open in Web Editor NEWMicroPython driver for the MLX90614 IR temperature sensor
License: MIT License
MicroPython driver for the MLX90614 IR temperature sensor
License: MIT License
Hey, I tryed to use my mlx90614 but i had some issues by using it. Maybe someone can help?
So i tryed this code from you:
import mlx90614
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4))
sensor = mlx90614.MLX90614(i2c)
print(sensor.read_ambient_temp())
print(sensor.read_object_temp())
if sensor.dual_zone:
print(sensor.object2_temp)
but i got this Output:
Traceback (most recent call last):
File "", line 4, in
TypeError: 'id' argument required
So i added an id = 0 and then i got:
Traceback (most recent call last):
File "", line 5, in
File "mlx90614.py", line 76, in init
OSError: [Errno 5] EIO
And i was not able to fix this until now. I would be thankful if someone would help me :)
_config1 = i2c.readfrom_mem(address, 0x25, 2)
This line is giving me lots of headache, I've tried using the proposed solution of using machine.SoftI2C instead but the sensor just outputs -273.15 which means that it is reading 0 from the sensor itself. I did an i2cscan and it the sensor is fine.
Anything would be of great help, Thanks. Btw, I'm using the Raspberry Pi Pico
Board: Raspberry Pi Pico
Code:
import uos
import machine
import time
print(uos.uname())
print("Freq: " + str(machine.freq()) + " Hz")
i2c = machine.I2C(0, scl=machine.Pin(5), sda=machine.Pin(4))
print(i2c)
print("Available i2c devices: "+ str(hex(i2c.scan()[0])))
import ustruct
_REGISTER_TA = const(0x06) # ambient
_REGISTER_TOBJ1 = const(0x07) # object
_REGISTER_TOBJ2 = const(0x08) # object2
class MLX90614:
def __init__(self, i2c, address=0x5a):
self.i2c = i2c
self.address = address
_config1 = i2c.readfrom_mem(address, 0x25, 2)
_dz = ustruct.unpack('<H', _config1)[0] & (1<<6)
self.dual_zone = True if _dz else False
def read16(self, register):
data = self.i2c.readfrom_mem(self.address, register, 2)
return ustruct.unpack('<H', data)[0]
def read_temp(self, register):
temp = self.read16(register);
# apply measurement resolution (0.02 degrees per LSB)
temp *= .02;
# Kelvin to Celcius
temp -= 273.15;
return temp;
def read_ambient_temp(self):
return self.read_temp(_REGISTER_TA)
def read_object_temp(self):
return self.read_temp(_REGISTER_TOBJ1)
def read_object2_temp(self):
if self.dual_zone:
return self.read_temp(_REGISTER_TOBJ2)
else:
raise RuntimeError("Device only has one thermopile")
@property
def ambient_temp(self):
return self.read_ambient_temp()
@property
def object_temp(self):
return self.read_object_temp()
@property
def object2_temp(self):
return self.read_object2_temp()
sensor = MLX90614(i2c)
while True:
print(sensor.read_ambient_temp())
time.sleep(1)
Output:
(sysname='rp2', nodename='rp2', release='1.14.0', version='v1.14 on 2021-02-09 (GNU 10.2.0 MinSizeRel)', machine='Raspberry Pi Pico with RP2040')
Freq: 125000000 Hz
I2C(0, freq=399361, scl=5, sda=4)
Available i2c devices: 0x5a
Traceback (most recent call last):
File "<stdin>", line 63, in <module>
File "<stdin>", line 23, in __init__
OSError: 5
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?
How to set the emissivity value?
What is the preset value then?
Maixpy IDE
Corgidude board
Code
import mlx90614
from machine import I2C
from fpioa_manager import fm
fm.register(14, fm.fpioa.SCCB_SDA)
fm.register(15, fm.fpioa.SCCB_SCLK)
i2c = I2C(I2C.I2C0, freq=100000, scl=15, sda=14)
sensor = mlx90614.MLX90614(i2c)
print(sensor.read_ambient_temp())
print(sensor.read_object_temp())
if sensor.dual_zone:
print(sensor.object2_temp)
OUTPUT
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "mlx90614.py", line 37, in __init__
OSError: [Errno 5] EIO
MicroPython v0.5.0-47-ge29a95c42-dirty on 2020-07-24; Sipeed_M1 with kendryte-k210
Type "help()" for more information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. đđđ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google â¤ī¸ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.