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
Multiple Melexis MLX90614 I2C
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Multiple Melexis MLX90614 I2C
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);
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
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...).
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
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...).
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
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Multiple Melexis MLX90614 I2C
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
Please post code using the code button in the reply
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
Dear all,
meanwhile the serial monitor prompts ambient and object temperature of the two MLX90614 sensors one time before it freezes:
So, the wiring is ok, I also used two different adresses for the sensors; but there is obviously still a problem with the code:
Any suggestions?
Thanks in advance!
JaBo
meanwhile the serial monitor prompts ambient and object temperature of the two MLX90614 sensors one time before it freezes:
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);
Thanks in advance!
JaBo
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Multiple Melexis MLX90614 I2C
If that is your code it should not compile since there is no closing brace at the end of loop.
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
Yep, you're right,
the code looks like this:
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
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);
}
So, what could be the reason for this behaviour?
JaBo
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Multiple Melexis MLX90614 I2C
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.
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
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
JaBo
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Multiple Melexis MLX90614 I2C
Can you post a photo showing how you have everything hooked up?
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
Sure; and I'll try to to make a Fritzing schematic. That will take a little time...
JaBo
JaBo
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
Ok, here are the photo and a Fritzing diagram:
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
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
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Multiple Melexis MLX90614 I2C
That would explain it! Thanks for posting your findings.And I also found the problem -> it was a broken resistor leg...
With a new resistor everythings runs fine now.
- JaBo
- Posts: 14
- Joined: Wed Jul 02, 2014 12:59 am
Re: Multiple Melexis MLX90614 I2C
Thanks for your assistance! I was focussed on the code since I am a programming beginner.
JaBo
JaBo
- Mauro75
- Posts: 4
- Joined: Sat Aug 19, 2017 8:47 am
Re: Multiple Melexis MLX90614 I2C
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
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 (828.22 KiB) Viewed 1983 times
-
- IMG_20170819_144041.jpg (694.71 KiB) Viewed 1985 times
-
- 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.
Please be positive and constructive with your questions and comments.