Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errno 5 by useing mlx90614.py #8

Open
MartenFrehse opened this issue Mar 20, 2023 · 5 comments
Open

Errno 5 by useing mlx90614.py #8

MartenFrehse opened this issue Mar 20, 2023 · 5 comments

Comments

@MartenFrehse
Copy link

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 :)

@jmodrako
Copy link

I think that you have a wrong declaration of i2c. Try this:

    i2c = I2C(id=0, sda = Pin(4), scl = Pin(5), freq=100000)

@jmodrako
Copy link

Here you can find out working example of mine: https://github.com/jmodrako/astroclouds/blob/main/app/main.py

@mcauser
Copy link
Owner

mcauser commented Mar 20, 2023

Hey, @jmodrako, this library was originally written to work with the ESP8266 port and its software I2C.
It's been a few years now and I've pivoted all of my projects to the ESP32.

According to the docs, these are the latest I2C init patterns for ESP32.
https://docs.micropython.org/en/latest/esp32/quickref.html#software-i2c-bus

# software I2C
from machine import Pin, SoftI2C
i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=100000)

# hardware I2C
from machine import Pin, I2C
i2c = I2C(0)
i2c = I2C(1, scl=Pin(5), sda=Pin(4), freq=400000)

I'll update the example code

Also, the datasheet mentions a requirement about the I2C frequency needing to be 100k or less

@MartenFrehse
Copy link
Author

Sadly none of these examples where working. I am using an raspberry pi pico w and not an ESP32.

I alwasy get Errno5 or some other errors not even the "working example" of @jmodrako where working with my pico. I dont know what i am doing wrong. ^^

@MartenFrehse
Copy link
Author

I have found my Problem ... I was not using the ADCs. After i switched that all was working just fine.

Code:
import mlx90614
import time
from machine import SoftI2C, Pin

i2c = SoftI2C(scl=Pin(27), sda=Pin(26), freq=100000)
sensor = mlx90614.MLX90614(i2c)

while True:
print(sensor.read_object_temp())
time.sleep_ms(500)

Thanks for your fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants