1

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

asked Nov 27, 2018 at 7:54
3
  • what does the datasheet say about resetting the address? Commented Nov 27, 2018 at 7:57
  • I couldnt find anything about it Commented Nov 27, 2018 at 8:02
  • edited the question Commented Nov 27, 2018 at 8:05

1 Answer 1

1

Page 13 of 35 in the datasheet states:

In order to provide access to any device or to assign an address to a SD before it is connected to the bus system, the communication must start with zero SA followed by low RWB bit. When this command is sent from the MD, the MLX90614 will always respond and will ignore the internal chip code information.

Supposedly, all you have to do is to connect only one device and use the address zero to read/write the registers.

answered Nov 27, 2018 at 8:19
4
  • I didn't understand "low RWB bit" part Commented Nov 27, 2018 at 8:41
  • that is the read/write bit ... see figure 4 ..... the library should take care of it Commented Nov 27, 2018 at 8:43
  • I am doint what it says but not sure if zero SA = default adress Commented Nov 27, 2018 at 8:50
  • Maybe the problem is I2C speed. MLX90614 supports only 100KHz i2c. If your i2c is at 400KHz, there would be no response from MLX90614. Commented Oct 22, 2023 at 8:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.