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 ![]()