MLX90614 Temperature sensor won't connect to ESP8266

Need Help ASAP! My project wants to connect MLX90614 temperature sensor to ESP8266 as our microcontroller. We connected the SCL to D1, SDA to D2, VIN to 3V3, and GND to GND. We used the example program from the Adafruit_MLX90614 library to test this sensor. Below is the screenshot of our code and the error we get.

#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

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

  Serial.println("Adafruit MLX90614 test");

  if (!mlx.begin()) {
    Serial.println("Error connecting to MLX sensor. Check wiring.");
    while (1);
  };

  Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
  Serial.println("================================================");
}

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);
}

There are 2 models of this sensor.

One for 3V and one for 5V.

What is your model?

See if this tutorial help.

we used the 3V model

Maybe you missed the 10kohm pullup resistors (on SDA and SCL) ?

I think the module we used already have built in pull up resistor for its SDA and SCL, it said that 472 on each pin

You soldered the pinheader / wires to the sensor, right?
Inspect the soldering.
Keep wires short.

When you have trouble with I2C, it is a rule of thumb to check the connection with I2C_Scanner.

4K7 ?

If you are using some kind of breakout board instead of a single sensor, check the slave address in the datasheet.

Then if it is connected correctly and the slave address stored in the EEPROM in the MLX90614 has not been changed, I2C_Scanner should display 0x5A. If another address is displayed, specify it in begin().

The following diagram is the recommended circuit from the datasheet:

How to check it using I2C_Scanner? Is there any manual about it?


Using I2C_Scanner i got this result. My ESP8266 board is already connected to my MLX90614 sensor, but it deosn't detect any I2C modules/sensors

Try this code:

I run at my ESP8266 and see printou:

Scanning...
I2C device found at address 0x39 !
done


// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
    //Wire.begin(); // Arduino
   Wire.begin(D2, D1); // ESP8266
 
  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  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.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

I remember the I2C_Scanner link I posted was the same code that @ruilviana posted, but it seems to be richer and more complicated than before :roll_eyes:

Either way, if the I2C scanner doesn't find the sensor, you'll have to check the hardware side, as @kmin posted in post #7.

Can you post a clear picture of the MLX90614 and ESP8266 connections? That might help us to figure out the cause.

The example link above shows more “include” items than just the sensor library. Not sure if the sensor library will already include the wire.h library. Another thing I noticed is that the example defines the SDA and SCL pins explicitly. My quick internet search for the ESP-8266 I2C pinout says that the I2C is in software and the pins must be defined in the firmware.

The I2C buss scan shows an unknown error on the addresses 0x76 through 0x7E. Does it have the same error on all addresses below the ones visible in the image? If so, there may be an issue with the software starting the I2C connection.


Those are our wiring for ESP8266 to MLX90614 where the green wire connects SCL to D1 pin, blue wire connects SDA to D2 pin, GND to GND, and VIN to 3V3. Is there any miscofiguration about this? We have tried to use other codes, but still the I2C scanner found nothing.

Thanks for the photos. The connection looks good. However, your sensor is not a new one and the solder seems to be oxidized.

The following is a photo of a sensor I found on Amazon that I believe is the same as yours:

I think you should assume that one of the following is defective: I2C Scanner (software), ESP8266 (I2C, VDD/GND), or MLX90614 (solder connection, SDA/SCL).

Here are all the things I can think of to check.

  1. I2C Scanner
    I think you tried Arduino-I2CScanner, and I also tried it with my ESP32 and sensor (MLX90640). Although the microcontroller is different from yours, it worked properly, so I think this software should be OK.

  2. ESP8266
    Check with a digital multimeter (DMM) to see if 3.3V is being output correctly. (I assume your sensor is 3V type) Also if you have another I2C device, connect it to D2 (SDA) and D1 (SCL) and check with an I2C Scanner.

  3. MLX90614
    I don't know the length of the BLUE and GREEN wires, but just to be sure, you should check each terminal with a DMM and check the wiring to the ESP8266. You may find oxidized solder defects. In this case, you may also need to re-solder.

If these things don't work, I would buy a new MLX90614 if I were you :roll_eyes:

EDIT: Your sensor breakout board appears to have a regulator on it, so you should probably provide 5V to VIN.

Thanks for the suggestion, just tested our board using other I2C device which is VL53L0x Time of Flight Sensor for distance. The I2C Scanner can detect it and outputting 0x39 class. Now I want to focus on testing this sensor first, but using examples from the Adafruit VL53L0x it said the error like image below


And here's the code:

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

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

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 
}


void loop() {
  VL53L0X_RangingMeasurementData_t measure;
    
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
  delay(100);
}

Which board are you selecting ?
Be specific.

Try include this function at begin of loop().

yield();

First, it looks like you selected "ESP8266 Generic Module" as the board package, but since there are many variants of ESP8266, please specify the board you are using for future reference as @runaway_pancake posted. If you are unsure, a photo of the front of the board would be fine.

Now, you reported the I2C address of the VL53L0X you are using as follows.

Your VL53L0X is not new one, right? Because the default I2C address of the VL53L0X should be 0x29.

I think the previous owner changed the I2C address for some reason.

Either way, try specifying the detected I2C address in the begin() method as follows:

if (!lox.begin(0x39)) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}

Instead of using the magic number 0x39 as above, it's a good idea to define symbols for the addresses of multiple I2C devices such as the MLX90614.

Oh, yours is not adafruit product.

Anyway, discussion about VL53L0X should be kept in: