0

M0 Express i2C problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

M0 Express i2C problems

by jhihn on Thu Apr 29, 2021 10:24 am

I've connected several mlx90614 ( https://learn.sparkfun.com/tutorials/ml ... okup-guide )
to the M0X powered by USB. I connect 3v to the VCC, G to G, SDA to SDA and SLC to SLC.

At first, the board works, then it stops working.

in the guide, at "Using the MLX90614 Library" it says:
Code: Select all | TOGGLE FULL SIZE
temp.begin(); // Initialize I2C library and the MLX90614
if (temp.read()) // Read from the sensor
{ // If the read is successful:
  float ambientT = temp.ambient(); // Get updated ambient temperature
  float objectT = temp.object(); // Get updated object temperature
  Serial.println("Ambient: " + String(ambientT));
  Serial.println("Object: " + String(objectT));
  Serial.println();
}



But for me, temp.read() works for a while, then fails, then I reset and temp.begin() locks up the board.
Sometimes it'll make it past that statement, and fail to read any temp, other times it works fine.

I've also tried https://www.amazon.com/HiLetgo-MLX90614 ... r_1_1_sspa, which is just the sensor plus the components for the I2C bus.

The only thing that is constant is the M0X board. I've tried multiple of those, but's the only component that has stayed the same. I'm wondering what could possibly be wrong with my minimal setup?
Attachments
20210429_100918.jpg
20210429_100918.jpg (217.52 KiB) Viewed 172 times

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Re: M0 Express i2C problems

by dastels on Thu Apr 29, 2021 11:04 am

Does that breakout board have pullup resistors on SDA and SCL? Adafruit MCU boards do not have pullups and require them to be on I2C device boards. The Qwiic version of SparkFun's breakout does include pullups.

I don't see anything in the datasheet on sampling rate, but does it work better if you put a delay in the loop?

Dave

dastels
 
Posts: 6436
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

by jhihn on Thu Apr 29, 2021 11:20 am

Update on this: I plugged a Uno R3 into it and it seems to be working better than the Itsy.

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Re: M0 Express i2C problems

by jhihn on Thu Apr 29, 2021 11:24 am

dastels wrote:Does that breakout board have pullup resistors on SDA and SCL? Adafruit MCU boards do not have pullups and require them to be on I2C device boards. The Qwiic version of SparkFun's breakout does include pullups.

I don't see anything in the datasheet on sampling rate, but does it work better if you put a delay in the loop?

Dave


Yes, it has 4.7k pull-ups on the back.

I get a reading ever 100ms
Attachments
20210429_112107.jpg
20210429_112107.jpg (194.88 KiB) Viewed 169 times

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Re: M0 Express i2C problems

by dastels on Thu Apr 29, 2021 11:50 am

I figured it did as you would have likely had other problems.

So you mean it works taking a reading every 100mS?

Dave

dastels
 
Posts: 6436
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

by jhihn on Thu Apr 29, 2021 11:54 am

dastels wrote:I figured it did as you would have likely had other problems.

So you mean it works taking a reading every 100mS?

Dave



The 100ms rate has never generated a problem when it was "working".
The problems I have are that:
1. temp.begin() sometimes locks up the device.
2. temp.read() often reports read errors.

These two problems are not perfectly correlated.

However, I have scrounged up a Uno R3, and it has not had any of these issues. I suspect the I2C interface as it is implemented on the Itsy is bad.

EDIT: I hope we can figure out what is going on. I rather like these boards

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Re: M0 Express i2C problems

by dastels on Thu Apr 29, 2021 4:10 pm

Hmm. Have you looked at the Adafruit guide? https://learn.adafruit.com/using-melexis-mlx90614-non-contact-sensors

This might shed some light:
This sensor uses a slightly non-standard type of I2C called "repeated-start". If you are not using an Arduino, make sure your microcontroller can support "repeated start I2C requests"!


Dave

dastels
 
Posts: 6436
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

by jhihn on Fri Apr 30, 2021 10:10 am

Excellent find Dave.

Our microcontroller is the Adafruit ItsyBitsy M0 express, so when the guide says: "make sure your microcontroller can support 'repeated start I2C requests'" I look to Adafruit and ask, "Does this board support repeat-start requests?"

It seems like it does not.
In fact we were only able to get the sensor working with an Uno R3.

Today I will make sure we are using the Adafruit library, but immediately out of the gate I have concerns. I compared the SF vs AF drivers:
https://github.com/adafruit/Adafruit-ML ... 14.cpp#L40
vs
https://github.com/sparkfun/SparkFun_ML ... 14.cpp#L36

The Adafruit begin() always returns true, but the Sparkfun returns isConnected(). Seems like Sparkfun has the edge there (you'd get bein()==true if it's not even on the bus! Interestingly, I have found that begin() can fail, and you still get temperature readings! (Or it can fail and you don't get temperature readings)

Also, the link in github is wrong for the 3.3v version:
https://www.adafruit.com/product/1749 should be https://www.adafruit.com/product/1747

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Re: M0 Express i2C problems

by jhihn on Sun May 09, 2021 10:47 am

Bump..

Can I get an official confirmation that I2C repeat-start protocol variant is supported and working on this board?

jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

Please be positive and constructive with your questions and comments.