M0 Express i2C problems

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jhihn
 
Posts: 9
Joined: Mon Dec 14, 2020 9:59 pm

M0 Express i2C problems

Post by jhihn »

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

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 368 times

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

Post by dastels »

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

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

Re: M0 Express i2C problems

Post by jhihn »

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

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

Re: M0 Express i2C problems

Post by jhihn »

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 365 times

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

Post by dastels »

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

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

Dave

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

Re: M0 Express i2C problems

Post by jhihn »

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

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: M0 Express i2C problems

Post by dastels »

Hmm. Have you looked at the Adafruit guide? https://learn.adafruit.com/using-melexi ... ct-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

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

Re: M0 Express i2C problems

Post by jhihn »

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

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

Re: M0 Express i2C problems

Post by jhihn »

Bump..

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”