Multiple Melexis MLX90614 I2C

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Multiple Melexis MLX90614 I2C

Post by JaBo »

Dear all,

I am trying to measure plant canopy temperature remotely using IR-sensor MLX90614, Adafruit data logging shield and Adafruit CC3000 WiFi shield.
Since plant canopy temperature may be very heterogenous I want to use 3 replications per plot. Also it is essential to measure object and ambient temperature. Using the adafruit MLX90614 library it is no problem to measure these parameter with one IR-sensor attached. But I get stuck to find a way to get 3 sensors running. Using I2C I know to assign different adresses to each sensor, which is no problem, but I can't figure out how to change the arduino code to get all sensors working. Your assistance is highly appreciated.

Greetings JaBo

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Melexis MLX90614 I2C

Post by adafruit_support_bill »

You can specify an address in the constructor. Just be sure to give each sensor instance a different name.

Code: Select all

Adafruit_MLX90614 mlx_1 = Adafruit_MLX90614(); // default address is 0x5A
Adafruit_MLX90614 mlx_2 = Adafruit_MLX90614(0x5B); 
Adafruit_MLX90614 mlx_3 = Adafruit_MLX90614(0x5C); 

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Dear Bill,

thank you for the swift reply.
I tried to add your suggestion to the code (unfortunately I am a much better natural scientist than a coder...).
mlxtest.txt
Code for two MLX90614
(1.41 KiB) Downloaded 348 times
With the code as it is now, I tried to get 2 MLX90614 with different adresses running, but only one shows correct data in the serial monitor.
Could you please give me a hint whether there is a problem with the code or the problem might be with the wiring?

JaBo

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Multiple Melexis MLX90614 I2C

Post by Franklin97355 »

In your code you are only starting mlx_1 (mlx_1.begin()) if you want to read mlx_2 you need to start that also.

Please post code using the code button in the reply
2014-06-30_17h43_42.png
2014-06-30_17h43_42.png (6.65 KiB) Viewed 2866 times

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Dear all,

meanwhile the serial monitor prompts ambient and object temperature of the two MLX90614 sensors one time before it freezes:
serial monitor.jpg
serial monitor.jpg (33.21 KiB) Viewed 2841 times
So, the wiring is ok, I also used two different adresses for the sensors; but there is obviously still a problem with the code:

Code: Select all

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx_1 = Adafruit_MLX90614(); // default address is 0x5A
Adafruit_MLX90614 mlx_2 = Adafruit_MLX90614(0x5B);

void setup() {
  Serial.begin(9600);

  Serial.println("Adafruit MLX90614 test");  

  mlx_1.begin();
  mlx_2.begin();  
}

void loop() {
  Serial.print("Ambient1 = "); Serial.print(mlx_1.readAmbientTempC()); 
  Serial.print("*C\tObject1 = "); Serial.print(mlx_1.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient2 = "); Serial.print(mlx_2.readAmbientTempC()); 
  Serial.print("*C\tObject2 = "); Serial.print(mlx_2.readObjectTempC()); Serial.println("*C");

  Serial.println();
  delay(2000);
Any suggestions?

Thanks in advance!
JaBo

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Multiple Melexis MLX90614 I2C

Post by Franklin97355 »

If that is your code it should not compile since there is no closing brace at the end of loop.

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Yep, you're right,

the code looks like this:

Code: Select all

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx_1 = Adafruit_MLX90614(); // default address is 0x5A
Adafruit_MLX90614 mlx_2 = Adafruit_MLX90614(0x5B);
//Adafruit_MLX90614 mlx_3 = Adafruit_MLX90614(0x5C); 

void setup() {
  Serial.begin(9600);

  Serial.println("Adafruit MLX90614 test");  

  mlx_1.begin();
  mlx_2.begin();  
}

void loop() {
  Serial.print("Ambient1 = "); Serial.print(mlx_1.readAmbientTempC()); 
  Serial.print("*C\tObject1 = "); Serial.print(mlx_1.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient2 = "); Serial.print(mlx_2.readAmbientTempC()); 
  Serial.print("*C\tObject2 = "); Serial.print(mlx_2.readObjectTempC()); Serial.println("*C");

  Serial.println();
  delay(2000);
}
And as mentioned in the post, I can run it, but the serial monitor freezes after prompting one measurement cycle.
So, what could be the reason for this behaviour?

JaBo

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Melexis MLX90614 I2C

Post by adafruit_support_bill »

So it always stops in the same place? Freezing can be a symptom of a communication problem (e.g. a loose connection), but that would tend to fail at random times.

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Yes, it stops as soon as the first cycle is printed on the monitor. Then I have to disconnect the arduino from the USB und restart it before it works again for a short time. Once in a while (10%) the prompting is interrupted even after 1 or 2 characters and no measured values are shown. But it never prints more than one cycle, even if I set the delay to a very short time.

JaBo

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Melexis MLX90614 I2C

Post by adafruit_support_bill »

Can you post a photo showing how you have everything hooked up?

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Sure; and I'll try to to make a Fritzing schematic. That will take a little time...

JaBo

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Ok, here are the photo and a Fritzing diagram:
multiple MLX90614_small.jpg
multiple MLX90614_small.jpg (417.99 KiB) Viewed 2789 times
Fritzing_Multiple_MLX.jpg
Fritzing_Multiple_MLX.jpg (857.07 KiB) Viewed 2789 times
And I also found the problem -> it was a broken resistor leg...
With a new resistor everythings runs fine now.
I will upload photo and diagram anyway. Maybe it is useful for somebody...

Thanks for your assistance!
JaBo

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Melexis MLX90614 I2C

Post by adafruit_support_bill »

And I also found the problem -> it was a broken resistor leg...
With a new resistor everythings runs fine now.
That would explain it! Thanks for posting your findings.

User avatar
JaBo
 
Posts: 14
Joined: Wed Jul 02, 2014 12:59 am

Re: Multiple Melexis MLX90614 I2C

Post by JaBo »

Thanks for your assistance! I was focussed on the code since I am a programming beginner.

JaBo

User avatar
Mauro75
 
Posts: 4
Joined: Sat Aug 19, 2017 8:47 am

Re: Multiple Melexis MLX90614 I2C

Post by Mauro75 »

Dear all,
I tried to follow everything you said.
Unfortunately I can only read one sensor.
Even the sensor measurement I can read is incorrect.
Do you have any idea? I give you my photos
Attachments
IMG_20170819_150950.jpg
IMG_20170819_150950.jpg (828.22 KiB) Viewed 1983 times
IMG_20170819_144041.jpg
IMG_20170819_144041.jpg (694.71 KiB) Viewed 1985 times
IMG_20170819_144218.jpg
IMG_20170819_144218.jpg (596.62 KiB) Viewed 1985 times
Last edited by Mauro75 on Sat Aug 19, 2017 9:17 am, edited 1 time in total.

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

Return to “Arduino”