arduino / ArduinoCore-megaavr

Arduino Core for the ATMEGA4809 CPU
103 stars 62 forks source link

MLX90614 I2C communication on Arduino Nano Every #88

Closed omersa closed 3 years ago

omersa commented 3 years ago

I have bought 6pack of Arduino Nano Every and built a splecial shield plate, so I can connect thermal sensor MLX90614, which communicate over I2C (A4,A5). The sensor was well tested on few Nano devices and on all it's OK. But with Arduino Nano Every it does not work. The device can be found on port I2C (search address), but no communication is going through. No data can be read or write. Tried many libraries and the problem persists with all.

As this device is has different processor then classic Nano, it seems that libraries for megaAVR boards are not OK. Also I am not alone with this problem. I think it persist on all Wire communication with Every.

alranel commented 3 years ago

Hi @omersa, could you provide some more details about your setup? Which libraries are you using? Did you add pullups? Are you using a "naked" thermal sensor or does it have a breakout?

omersa commented 3 years ago

Sensor is in a 5V package with SDA and SCL out and is working well on all other Nano boards. The connection of SDA is A4 port and SCL A5 port, as normally. When you query the device on address 0x5A it confirms the connection, but no data is transmitted or received. Normally I am using Adafruit_MLX90614 library, but is also not working with any other wire type library.

I think pull-up resistors are on a sensor's board: 128930899_770627040192051_7426625885471462101_n

omersa commented 3 years ago

I have done some deep search into sources and I have found out that Wire and Twi libraries for megaavr (Arduino Nano Every) are completelly different from avr libraries that work on Nano. They are much older with no timeouts and many other changes. It seems that until somebody renew the libraries for megaavr boards, ther will be no solution. Have tried to take libraries from avr, but does not work, as it seems there is much difference in all other libraries.

alranel commented 3 years ago

@omersa, we are definitely going to check this - give us some time and we'll get back to you :)

alranel commented 3 years ago

I got a GY-906 breakout board like yours and I was able to reproduce the issue. I did these tests:

omersa commented 3 years ago

You right. I manage to make it work with MegaCoreX. Thank you.

omersa commented 3 years ago

I changed the twi.c and - YES, it works fine now. Thank you for all your help.

alranel commented 3 years ago

Thank you for reporting the issue @omersa!

Nolan-Walker commented 2 years ago

Hi there @alranel , I am having the same issue as above but the change is not working for me. I have the MLX90614-DCI version of the sensor without the PCB ("naked version"); I have also soldered a 100nF capacitor between VSS and VDD... When using the regular Arduino Nano the sensor works fine, but when I use the Arduino Nano Every, the sensor does not work and returns "nan". I have the updated version of the arduinocore - megaavr board package and I also have tried using MegaCoreX board package and neither of these are fixing the issue for me.

Any help would be greatly appreciated! Thank you for your time!