Closed jschoch closed 6 years ago
What is the I2C address of the OLED diplay on your I2C bus?
should be 0x3c
https://gist.github.com/jschoch/779e7aae5205bfbcb93a064da627201e#file-mlx90393_esp32_ssd1306-ino-L10
it is the first arg of the display init
here is the output of an i2c scanner when the device is hooked up. You can see both the OLED screen and the mlx device at the correct addresses.
start scan
Scanning I2C Addresses
.. .. .. .. .. .. .. .. .. .. .. .. 0C .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. 3C .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
Scan Completed, 2 I2C Devices found.
Discovering eeprom sizes 0x50..0x57
0x50: Not Present.
0x51: Not Present.
0x52: Not Present.
0x53: Not Present.
0x54: Not Present.
0x55: Not Present.
0x56: Not Present.
0x57: Not Present.
done setup
One more quick test: dump the value returned by readData():
uint8_t status; status = mlx.readData(data); Serial.print("status = "); Serial.println(status);
see if an error code is returned. 255 is an error:
enum { STATUS_OK = 0, STATUS_ERROR = 0xff } return_status_t;
i recall it was 255 previously. I'll test it again.
confirmed status = 255.
also hooked up an uno (my pro micro is 5v without a 3.3v) to a level shifter and have a sensor working with status 0.
I have tested it with an ESP32 dev board here, and it works as expected. So, unfortunately, I am unable to reproduce the problem at this time.
I ordered one of those OLED ESP32 boards, so when that comes I can try again.
You can check the status of the begin() call to see if it fails that early. Next steps are printing values within the begin() call to find the first one that fails.
What MLX90393 PCB are you using?
Interestingly, I first tested the code on an ESP32 without the sensor connected at all, and received similar garbage values as you posted above. I'd suspect that the I2C connections were incorrect, but the scanner finds it on the bus.
One other test is to try using another pair of pins on the ESP32 for I2C. You won't be able to use the display, but it might yield some clues.
Oh, also, I did not need to modify the original sketch from the repo. The ESP32 dev board has SCL on pin 22 and SDA on pin 21. Connecting the sensor to those works for me.
I have a doit esp32 module, but I was not able to get Wire.begin(23,22) working. I will try a few other pins.
Odd the other code referenced above works Wemos with the OLED. Maybe I should try with the SDA and SLC pulled up to 3.3v with a 2.4k resister
I found it. The library breaks if you call Wire.begin() before mlx.begin(). Working on a fix now, but you can verify by commenting out line 63 of MLX90393.cpp:
//_i2cPort->begin();
fixed in fix_wire_begin branch.
You always have to call either Wire.begin() or Wire.begin(sda, scl) now, whether you need to change the pins or not.
Please verify this works for you, and I will close the issue and merge into master.
sweet! working on my board! Thank for the help!!!
Thank you for finding this and chasing it down!
This issue has been there for a while. I'm refraining from hitting the "blame" button on the master branch :-)
Merged into master #31.
I'm unable to get the sample code working with my wemos lolin 32 board. The values do not update. here is the sketch
following is a sample of the output. oddly a few of the values were in fact changed.
the following does work (but not great):
https://gist.github.com/jschoch/779e7aae5205bfbcb93a064da627201e
source for this is: https://github.com/ControlEverythingCommunity/MLX90393/blob/master/Arduino/MLX90393.ino