I am working on a project, where I'll ultimately need 5 MLX90614 to be running together to control the intensity of an WS2812B LED strip.
I found some help about how to change the adresses of the sensors as to be able to connect multiple of them in chain here: https://www.instructables.com/Multiple-IR-Temperature-Sensors/ and it worked well, have two set up this way, they read out independently, but after maybe 30 secounds or so, the readout on the serial monitor just freezes and stops. start back up when I unpluck and reconnect it, any idea what could be the issue here?
Sorry that I did not react earlier, but my kids got sick and I had my hands full with that for the last few days.
I have added the changes you suggested to make sure I read both sensors and also tested it with putting something hotter in front of each seperately, and it works.
How ever, the original issue for which I posted, persits, the serial monitor stops after like 30 seconds. it starts up perfectly if I switch it op and on, to again run for 30 sek or so. Any ideas what is happening there?
Started expertimenting with adding some LED's to the setup, as in the end the sensors are going to be controling LED's, and it works well and the the issue with the serial monitor stopping has also gone away with that. still no idea why that happened, but it runs kinda stable in this form:
#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#define IR1 0x5A
#define IR2 0x5B
#define LED_PIN 9
#define NUM_LEDS 12
#define LED_COUNT 12
// Setting up the NeoPixel library
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
Adafruit_MLX90614 mlx2 = Adafruit_MLX90614();
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
Serial.println("Adafruit MLX90614 test");
mlx.begin(IR1);
mlx2.begin(IR2);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
strip.begin();
}
float temp1 =0;
float temp2 =0;
float amp1 =0;
float amp2 =0;
void loop() {
Serial.print("IR1: ");
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
temp1 = mlx.readObjectTempC();
amp1 = mlx.readAmbientTempC();
delay(500);
Serial.print("IR2: ");
Serial.print("Ambient = "); Serial.print(mlx2.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx2.readObjectTempC()); Serial.println("*C");
temp2 = mlx2.readObjectTempC();
amp2 = mlx2.readAmbientTempC();
delay(500);
strip.clear(); // Set all pixel colors to 'off'
for(int i=0; i<6; i++) {
// Set the i-th LED to pure green:
strip.setPixelColor(i, (amp1-temp1)*10, 0, 0);
// strip.setBrightness((amp1-temp1)*10);
// Send the updated pixel colors to the hardware.
// delay(500); // Pause before next pass through loop
}
for(int j=6; j<12; j++) {
// Set the i-th LED to pure green:
strip.setPixelColor(j, 0, (amp2-temp2)*10, 0);
// strip.setBrightness((amp2-temp2)*10);
// Send the updated pixel colors to the hardware.
// delay(500); // Pause before next pass through loop
}
strip.show();
}
And sorry for bad form, I am not so good at coding, and mostly try to work thingsout going by disecting examples and spilicing things in and out. kinda like an oldtimy biologist ;).
The final outcome is going to be cool I am sure, an interactive lightup table visualising scientific principles for a musuem exhibit.
thank you for baring with me during the journey and all help and suggestions