SteamyTea Posted January 19, 2024 Posted January 19, 2024 (edited) I don't know if we have any Python/RPi experts here, but I am struggling to get an i2c infrared thermometer to work. The sensor is a cheap CJMCU one, which is an mlx90614, sometimes also known as a GY-906. I have installed all the relevant libraries i.e. adafruite_mlx90614, smbus2, etc, but may have missed something key. I can get it connected and showing up with i2cdetect -y 1 as 5b and plays nicely with my RTC (which may or may not be UU) When I run the below test python programme it returns [0, 91], which I have no idea what it means but seems to show it is connected and can be locked out import busio from board import * i2c = busio.I2C(SCL, SDA) i2c.try_lock() print(i2c.scan()) i2c.unlock() i2c.deinit() When I come to run the proper Python programme I get this message. from smbus2 import SMBus from adafruite_mlx90614 import MLX90614 bus = SMBus(1) sensor = MLX90614(bus, address=0x5b) print (sensor.get_amb_temp()) print (sensor.get_obj_temp()) bus.close() I then played about and wrote this, but get this message from smbus2 import SMBus, i2c_msg from adafruit_mlx90614 import MLX90614 with SMBus(1) as bus: with MLX90614 as sensor: bus = SMBus() sensor1 = sensor(bus, address=0x5b) print(sensor1.get_ambient()) A bit more playing and I get this message. from smbus2 import SMBus from adafruit_mlx90614 import MLX90614 TemperatureModule._sensor = MLX90614(1, 0x5B) while not i2c.try_lock(): temperature = TemperatureModule._sensor.get_object_1() temperature1 = TemperatureModule._sensor.get_ambient() And after staying up to gone 9PM last night, and a few hours this morning, I am completely at a loss. I have spent literally hours searching this and there seems to be very little information PyPi does suggest a command is tried first, but it made not difference. Can anyone help? (when I say help, I mean actually write it for me) Edited January 19, 2024 by SteamyTea
S2D2 Posted January 19, 2024 Posted January 19, 2024 adafruit_mlx90614 is the CircuitPython library (https://docs.circuitpython.org/projects/mlx90614/en/latest/api.html) so you'd have to flash the firmware to your microcontroller. I'm assuming instead you're using a zero or such with a standard python install, so you'd want another library. The one you linked might work but note the different name for pip/include: https://pypi.org/project/PyMLX90614/ Full disclaimer I've never used any of this stuff so could be completely wrong.
SteamyTea Posted January 19, 2024 Author Posted January 19, 2024 1 minute ago, S2D2 said: I'm assuming instead you're using a zero Yes, a Pi Zero W I think I have an old proper board or 3, may give it a go on that. Thanks for your help, lets see what happens.
S2D2 Posted January 19, 2024 Posted January 19, 2024 1 minute ago, SteamyTea said: Yes, a Pi Zero W I think I have an old proper board or 3, may give it a go on that. Thanks for your help, lets see what happens. Zero and 3 will behave the same (full OS with Python on top). CircuitPython is for things like the Pico. Good luck.
SteamyTea Posted January 19, 2024 Author Posted January 19, 2024 8 minutes ago, S2D2 said: CircuitPython is for things like the Pico. That could account for it then. I have booted up one of my old Pis and shall see if I can get the proper libraries on it. Thanks again, most days are school days. (just spent over a day looking for my old car V5 document, found some "O" level certificates, they are well over 40 years old, and my Birth Certificate, which is even older. I did find the V5, right where I left it.)
TerryE Posted January 26, 2024 Posted January 26, 2024 (edited) Nick, have a look at the Datasheet for the MLX90614. It runs a proprietary 2-wire protocol that isn't quite I2C. This might confuse the RPi I2C driver, but the easiest is to have a look at the various MLX90614 on RPi YouTube videos, e.g. Edited January 26, 2024 by TerryE
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now