I2C Scanner hanging

Hi, I know others have had similar problems but I think I checked everything over and can’t see what the problem is. Actually I’m trying to help my 8 year old son with this, but I have rewired everything from scratch twice, tried a different UNO in case the first one had the SDA/SCL fried, checked with a meter that he is using 10k ohm resistors, and added print statements to the scanner code.

We only have the one I2C device (which cost $30) so I am thinking maybe it is no good?

The sensor is a melexis MLX90614ESF-ACF-000-SP. (We’ve built a little “robot” and he wants to make it heat-seeking – hey, he’s 8 yr old, he wants it to follow people around.)

So, I am trying to attach halfway-decent pics of our set-up, and our board info. I have stared at this quite a bit and believe we are following Overview | Using Melexis MLX90614 Non-Contact Sensors | Adafruit Learning System (which is for a wide-angle sensor whereas ours is a 10-degree FOV which we had to get from Mouser).

Here is the code:

#include <Wire.h>

void setup() {
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");

void loop() {
  byte error, address;
  int nDevices;
  nDevices = 0;
  for (address = 1; address < 127; address++ ) {
    // The i2c_scanner uses the return value of the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Serial.println(": After beginTransmission");
    error = Wire.endTransmission();
    Serial.print("After endTransmission, error=");

    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
      Serial.println("  !");
    } else if (error==4) {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
  if (nDevices == 0) {
     Serial.println("No I2C devices found\n");
  } else {
  delay(5000);           // wait 5 seconds for next scan

And this results in only the following monitor output:

I2C Scanner
1: After beginTransmission

After which it hangs.

If I unplug the yellow wire, it rolls right along (and says no devices found):

I2C Scanner
1: After beginTransmission
After endTransmission, error=2
2: After beginTransmission
After endTransmission, error=2
3: After beginTransmission
After endTransmission, error=2
4: After beginTransmission
After endTransmission, error=2
5: After beginTransmission
. . .
123: After beginTransmission
After endTransmission, error=2
124: After beginTransmission
After endTransmission, error=2
125: After beginTransmission
After endTransmission, error=2
126: After beginTransmission
After endTransmission, error=2
No I2C devices found

I’m an old programmer but fairly new to electronics, so I may be doing something stupid… would at this point be glad to be proven stupid if it means we can move forward.


I added the pinout from the Melexis datasheet, which is available in its entirety at Digital Non-Contact Infrared Thermometer (MLX90614) #Melexis



That code works for me. It finds two devices on the I2C bus. A DS3231 RTC and the EEPROM on the same board. You must have something wired incorrectly. The photos are useless - very blurred and poor lighting.


Thanks, Pete, for replying, and sorry about those grungy cell-phone photos. I hope the new ones will help. (My digital camera goes back to the CompactFlash days; I no longer had a working reader, but was able to dig up a cable.)

I think the wiring conforms to the Adafruit tutorial I linked to. I am usually slow to blame hardware, but I can't see what we did wrong. And it works (though it finds no I2C device) if the sensor is disconnected.

I suppose the sensor pinouts could be wrong, whether misinterpreted by me or misrepresented by Adafruit.

VSS = ground VDD = supply(+)

You seem to have reversed the power connections of the sensor. Leo..

If those are 10k pullup resistors, they may be too high. The specified value of those for I2C is 4.7k and in some cases even lower values have to be used. Try changing the resistors. The wiring looks correct otherwise. (but @Wawa has noticed a problem!)


10k pull up is fine for that short distance.

Compare OP's wiring2.jpg with the breadboard view on the Adafruit site. Leo..

@Wawa was right. We had the power supply backwards. Fixing this did not help. We now get rather erratic results. Given the max reverse voltage is 0.4V, I think we may have fried it.

We had this wired up and had to break it down for travel, and I rewired it before testing again and posting this question. So I can't really say whether it was right or wrong the first time.

The 51-page data sheet has a lot of info. The factory slave address is supposed to be 5A, but it configurable. And the whole thing is configurable for PWM output vs the SMBus output. I'd like to try reconfiguring it, but must admit the datasheet is stretching the limit of my understanding. If anyone wants to look at this and give a step-wise explanation of how to configure the EEPROM and read the PWM, I would be grateful. But maybe I'm just getting in over my head here. :(

Ok, so in case anyone comes here with a similar problem, here’s our follow-up. I gave Mouser another $30 and got the same exact Melexis sensor a 2nd time. My son and I were very careful not to reverse-voltage it. And it worked perfectly. Image attached in case anyone wants to see.

My son confesses he thinks he had it backwards.

It made me wonder why they don’t slip a diode in there to goof-proof it. But I suppose a diode to handle up to 6V reverse voltage might make the can considerably larger. Curious if any EE out there can comment on that.

Thanks to everyone who replied to us.

John’s dad