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.
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:
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
}
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.
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.
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.
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.
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
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
#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);
}
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.