Hi,
ich versuche derzeit verzweifelt zwei identische Sensoren (MLX90621 , Temp-Array sensor) mit der selben I2C-Adresse an einem ATMega644P zu betreiben.
Um das zu ermöglichen verwende ich einen PCA9540B (i2c-multiplexer). Link datenblatt: Datenblatt PCA9540
Das Problem ist, dass der Multiplexer den Channel im Betrieb nicht wechselt und somit zwei mal die selben Messwerte ausgibt.
Verwendete Library: PCA9540BD Lib
Es wird folgender code verwendet:
#include <SPI.h>
#include <Arduino.h>
#include <Wire.h>
#include "MLX90621.h"
#include <PCA9540BD.h>
PCA9540BD multiplexer;
MLX90621 MLX; // create an instance of the Sensor class
uint32_t LastSensorUpdate;
void setup() {
MLX.initialise (512);
Serial.begin(9600);
}
void loop() {
MLX.measure(true); //get new readings from the sensor
multiplexer.selectChannel(1);
Serial.println("Channel 1");
//Serial.print(MLX.getAmbient());
Serial.print(millis());
Serial.print("ms");
Serial.print(" | ");
for (int y = 3; y < 4; y++) { //go through all the rows
for (int x = 0; x < 16; x++) { //go through all the columns
int16_t valueAtXY = MLX.irData[y + x * 4]; // extract the temperature at position x/y
Serial.print(MLX.getTemperature(y + x * 4));
Serial.print(" ");
}
}
Serial.println(" ");
multiplexer.selectChannel(0);
Serial.println("Channel 0");
MLX.measure(true);
Serial.print(MLX.getAmbient());
Serial.print(" | ");
for (int y = 3; y < 4; y++) { //go through all the rows
for (int x = 0; x < 16; x++) { //go through all the columns
int16_t valueAtXY = MLX.irData[y + x * 4]; // extract the temperature at position x/y
Serial.print(MLX.getTemperature(y + x * 4));
Serial.print(" ");
}
}
Serial.println(" ");
Serial.println(" ");
delay(3000);
}
Hat jemand ne Idee woran das liegen könnte?