I was using my MLX90614 IRTherm sensor flawless and bought two more. I have connected two sensors serial with pull-ups to SDA --> A4 and SCL --> A5
. After digging the internet I found out that I should change their default slave addresses to different addresses so that Arduino can recognize their 7-bit slave addresses.
After changing their address, now I can't read either two new serial MLX'es or my old MLX.
- I might have messed up with their addresses and don't know how to reset their addresses.
- How can i connect multiple sensors/ how can i change their adress properly?
reading sensor data
#include <Wire.h> // I2C library, required for MLX90614
#include <SparkFunMLX90614.h> // SparkFunMLX90614 Arduino library
IRTherm therm; // Create an IRTherm object to interact with throughout
const byte LED_PIN = 8; // Optional LED attached to pin 8 (active low)
void setup()
{
Serial.begin(9600); // Initialize Serial to log output
therm.begin(0x5A); // Initialize thermal IR sensor
therm.setUnit(TEMP_F); // Set the library's units to Farenheit
// Alternatively, TEMP_F can be replaced with TEMP_C for Celsius or
// TEMP_K for Kelvin.
pinMode(LED_PIN, OUTPUT); // LED pin as output
setLED(LOW); // LED OFF
}
void loop()
{
setLED(HIGH); //LED on
// Call therm.read() to read object and ambient temperatures from the sensor.
if (therm.read()) // On success, read() will return 1, on fail 0.
{
// Use the object() and ambient() functions to grab the object and ambient
// temperatures.
// They'll be floats, calculated out to the unit you set with setUnit().
Serial.print("Object: " + String(therm.object(), 2));
Serial.write('°'); // Degree Symbol
Serial.println("F");
Serial.print("Ambient: " + String(therm.ambient(), 2));
Serial.write('°'); // Degree Symbol
Serial.println("F");
Serial.println();
}
setLED(LOW);
delay(500);
}
void setLED(bool on)
{
if (on)
digitalWrite(LED_PIN, LOW);
else
digitalWrite(LED_PIN, HIGH);
}
Setting address
#include <Wire.h> // I2C library, required for MLX90614 #include <SparkFunMLX90614.h> // SparkFunMLX90614 Arduino library IRTherm therm; // Create an IRTherm object to interact with throughout const byte oldAddress = 0x5A; const byte newAddress = 0x5B; void setup() { Serial.begin(9600); // Initialize Serial to log output Serial.println("Press a key to begin"); while (!Serial.available()) ; therm.begin(oldAddress); // Try using the old address first byte address; if (!therm.readID()) // Try reading the ID registers { // If the read fails, try re-initializing with the // new address. Maybe we've already set it. therm.begin(newAddress); if (therm.readID()) // Read from the ID registers { // If the read succeeded, print the ID: Serial.println("Communicated with new address."); Serial.println("ID: 0x" + String(therm.getIDH(), HEX) + String(therm.getIDL(), HEX)); } else { Serial.println("Failed to communicate with either address."); } } else { // If the read suceeds, change the address to something // new. if (!therm.setAddress(newAddress)) { Serial.println("Failed to set new address."); } else { Serial.println("Set the address to 0x" + String(newAddress, HEX)); Serial.println("Cycle power to try it out."); } } } void loop() { }
Edit 1: Datasheet