My UNO R3 and I2C sensor can't recognize each other after powering off

Greetings. Thank you for reading this.

I am connecting my MLX90614 sensor in I2C bus with 16x02 lcd. I used Adafruit library, I2C LCD library and Wire.h.

When I uploaded the code, the lcd displays weird numbers and letters that I didn't expect. I scan first using I2C Scanner and it found an address of "90" or "0x5A" and upload the code again. This time, it works perfectly fine. The lcd display what I want to see.

HOWEVER, when I want to change the power supply from USB cord (I can't bring my laptop all around) into power adapter. I remove the USB cord and insert the barrel jack, reset the UNO hoping to read the code again. This time, the LCD is displaying weird again. I think, the MLX90614 address wasn't recognize/found by my UNO R3.

If you please, HELP me with this? Your advice is so much appreciated. Thank you so much.

It looks like the I2C scanner returned the address of the MLX90614 :

#define MLX90614_I2CADDR 0x5A

That is embedded in the Adafruit library, so you shouldn't need to touch it.

It is not clear, from your description, what I2C address you changed. What happens if you remove the MLX90614 and repeat an I2C scan ?

What power source are you connecting to your Uno, via the jack, when you have these problems ?

Thank you 6v6gt.

No I haven't change the sensor address, its just the UNO can't retain the mlx90614 address after disconnecting the USB cord to insert a barrel jack as new power supply when I reset the UNO.

#include <Wire.h>
#include <Adafruit.MLX90614.h>
#define MLX90614_I2CADDR 0x5A

The serial monitor displays a data of :
Ambient = 1037.55C. Object = 1037.55C
Ambient = 1899.59F. Object = 1899.59F

That temperature looks uncomfortably high.
Post all your code, a diagram of how it is all connected together and state what power supply (voltage etc.) your are connecting to the Uno when not using your laptop.

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
Serial.begin(9600);

Serial.println("Adafruit MLX90614 test");

mlx.begin();
}

void loop() {
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

Serial.println();
delay(500);
}

That is the code I used. Its from Adafruit.

Wiring:
Sensor = UNO R3
SDA = A4
SCL = A5
VNN = 3.3V
GND = GND

Power supply = Connected via USB cord

After I uploaded the code above, the monitor displays different readings (i.e. Object = 1037.55*C). However, if I upload the I2C scanner first and detect its adress and upload the code again from Adafruit, it works perfectly fine.

If I plug out the USB cord from laptop and plug in again and hit reset, the sensor displays different reading again (i.e. Object = 1037.55*C). Its seems that I need to scan first before I upload the code from Adafruit.

OK. You've followed this: Wiring and Test | Using Melexis MLX90614 Non-Contact Sensors | Adafruit Learning System ?

You have the two 10k pullup resistors on the I2C lines ?

Have you the 3volt or 5volt sensor ?

I don't have 10k ohms on i2c lines. I have a 3.3V sensor.

I test based on the link, still, it didn't work. The reading is still inaccurate. :frowning:

To me, it looks like you need 10k pullps between the I2C lines and the 3.3 volt power source for your sensor.
You spoke earlier about an I2C LCD display. Is that also 3volt or is it 5 volt ?
If you mix different voltages on an I2C bus, you should use a level shifter.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Have you tried adding 4k7 pullup resistors to the SDA and SCL lines, to the 5V supply.

Can you post a link to where you got the sensor module please, as there is a 5V and 3.3V version of the sensor.

Thanks.. Tom.. :slight_smile:

To 6v6gt,

May I know what's the reason in adding pull up resistors in SDA and SCL lines to i2c address?

My mlx90614 have an on-board pull up resistors of 4.7k ohms.

5V is the i2c lcd. Maybe I should connect the mlx90614 to 5V by adding another pull up resistors?

To TomGeorge,

I bought it from a store, how foolish I am without asking if it is a 3V or 5V mlx. Honestly, I didn't know that there are two versions of it.

It has an on-board 4.7k ohms pull up resistors.

Wiring:

MLX90614 > UNO R3
SDA > A4
SCL > A5
GND > GND
VNN > 3.3V (I just used 3.3V to be safe)

Ok. If the 3.3volt module you are using (provide a link to this) already has I2C pull up resistors, you don’t need to add any. These are needed to so the lines don’t float and can pulled hard down during communication.

However, since the Uno is a 5volt device, you should really use an I2C level shifter for connecting 3.3volt devices to its I2C bus.

I suppose you could also, as a test, copy the main part of the I2C scanner code into setup() in your test sketch to see if that helps to isolate the problem.

Hi,
Thanks for the info.
Can you read the full part number on the sensor IC?
Can you post a picture of the module you have?

Thanks.. Tom.. :slight_smile:

THANK YOU 6v6gt.

I ask the store, he said "Power supply: 3-5v (internal low dropout regulator)".

I copy the code of the i2c scanner in the void setup() and void loop(), but the mlx90614 sensor doesn't give the data correctly.

To TomGeorge,

B89736X16E MLX90614

iamphysics:
I copy the code of the i2c scanner in the void setup() and void loop(), but the mlx90614 sensor doesn't give the data correctly.

Use this code and see what the monitor says, use 115200 baud.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include <Wire.h>
void setup() {
  Serial.begin (115200);
//  Wire.begin(4, 15);
 pinMode(16, OUTPUT);
  digitalWrite(16, LOW);
  delay(50);
  digitalWrite(16, HIGH);
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
    {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
    } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup
void loop() {}

It will only run once, so press reset on the controller board to run it each time.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you post a picture of your project so we can see your component layout?

Thanks.. Tom... :slight_smile:

Thank you Tom.

I tried the code but the Serial monitor doesn't give any address.