I changed the OpenLog_Artemis_V10-v20 firmware to use the Qwiic IR Thermometer - MLX90614 sensor.
I made two different implementations, one uses the SparkFunMLX90614.h library and the other implementation uses the Adafruit_MLX90614.h library. In both implementations I have the same problem, when reading the I2C data the values I get are always at a high level. I believe I will have to use a logic level converter. I tested it with Arduino Uno and had no problem. Does anyone have any ideas?
Once you have done that, I believe it should work. But I do not have an MLX90614 to test it.
If you are trying to use the MLX90614 library on its own, without using the OLA firmware, then the main thing you will need to do is to enable power for the Qwiic interface. You will need to include:
paulvha:
instead of including in openlog firmware, try to load example2 with the standard library to the openlog board. So what happens…
Thank you so much for replying quickly.
I ran example 2.
The first error is a compilation error in the SparkFunMLX90614.h library because PIN_WIRE_SDA and PIN_WIRE_SCL have not been set. I solved it.
The second error I get the message “asdasd”. This is because the ports used for i2c communication by default are different in Artemis. In Artemis the qwiic communication needs to be energized before starting the communication.
The conclusion I come to is that the SparkFunMLX90614.h library and examples need a lot of changes to make it work in Artemis.
I think I’d better spend my time solving this issue within the OpenLogArtemis firmware.
Once you have done that, I believe it should work. But I do not have an MLX90614 to test it.
If you are trying to use the MLX90614 library on its own, without using the OLA firmware, then the main thing you will need to do is to enable power for the Qwiic interface. You will need to include:
Just out of interest I have connected an MLX90615 that I have around. It has similar specifications to the MLX90614 but not completely the same and different register addresses. BUT they are part of the same family and design. Their interface is very much the same.
Now the fun part… compiled and connected to an Arduino UNO gives good results (around 21 C), compiling the same sketch but now for an Artemis ATP gives me 1037C… What ? Actually checking with a logic analyzer (or you can include print statements in readreg) shows that the ATP is constant receiving 0xffff
Checked the 3v3, in both cases that is 3.25V. So it is not the power supply.
Then looked with a logic analyzer. The time between writing the register address and starting reading from that address on the UNO takes 16.2us, the time on the ATP takes 98.7us. SAME CODE !!
So what ? one could think… well according to the datasheet of the MLX90615 :
Timeout H is the maximum time for which it is allowed for SCL to be high during communication. After
this time MLX90615 will reset its communication block assuming that the bus is idle (according to the SMBus
specification) - not more than 52µs
This means that the MLX90615 with the ATP is now reset and sending incorrect data.
For an MLX90614 the timeout H is 50us (according to the datasheet).
I suspect this is the reason why you get high results. I also suspect this is because of Mbed overhead, which is part of V2. When creating SoftwareSerial for V2 I run into similar microsecond issues.
I will try to spend more time analyzing in the coming days.
Just out of interest I have connected an MLX90615 that I have around. It has similar specifications to the MLX90614 but not completely the same and different register addresses. BUT they are part of the same family and design. Their interface is very much the same.
Now the fun part… compiled and connected to an Arduino UNO gives good results (around 21 C), compiling the same sketch but now for an Artemis ATP gives me 1037C… What ? Actually checking with a logic analyzer (or you can include print statements in readreg) shows that the ATP is constant receiving 0xffff
Checked the 3v3, in both cases that is 3.25V. So it is not the power supply.
Then looked with a logic analyzer. The time between writing the register address and starting reading from that address on the UNO takes 16.2us, the time on the ATP takes 98.7us. SAME CODE !!
So what ? one could think… well according to the datasheet of the MLX90615 :
Timeout H is the maximum time for which it is allowed for SCL to be high during communication. After
this time MLX90615 will reset its communication block assuming that the bus is idle (according to the SMBus
specification) - not more than 52µs
This means that the MLX90615 with the ATP is now reset and sending incorrect data.
For an MLX90614 the timeout H is 50us (according to the datasheet).
I suspect this is the reason why you get high results. I also suspect this is because of Mbed overhead, which is part of V2. When creating SoftwareSerial for V2 I run into similar microsecond issues.
I will try to spend more time analyzing in the coming days.
Hi, you got to the same stage as me and diagnosed that the return value was always 0xffff. I think I was happy, maybe I’m not so lost.
Great datasheet analysis! I didn’t know about this timeout.
Unfortunately, the problem is bigger than my knowledge of the field so far. I don’t know how to go about solving this problem.
This is something that needs to be solved with the V2 library. Nothing you can do on the driver/application level. The I2C on the Artemis is having a couple of challenges, this is just adding to the list. If Openlog on V1 is still available try using that MBED is only part of V2 and brings new features BUT also a lot of overhead.
I have tested on Apollo3 library V1.2.1. It provides good results, but the timing is very critical as there is 49.1us between requesting a register address content and starting to read. (as a reminder there 50us is the maximum according to the datasheet) So it looks that V2 is adding about 40us. More work to analyze and find a potential solution to reduce the time.
I have done a deep dive on the I2C for Apollo3 to understand what is going on and how that relates to the SMBUS specifications as the MLX90614 / MLX 90615 has adopted that. Attached is a detailed document but in short the conclusions :
The Apollo3 V1.x library can be compatible with SMBUS 2.0 specifications starting at 200Khz. Of course your device needs to support that.
The Apollo3 v2.x library is NOT compatible with the SMBUS 2.0 specifications given the 50us boundary. As such MLX-9061x will not work with V2 over I2C.
Will now try to see whether it can be interfaced using PWM
A took some time, but I was able to set the MLX90614 in PWM mode and read it on the Apollo3 ATP board, either running V1.x or V2.x library. The attached zip file has sketches and descriptions on how to switch between SMBUS and PWM mode (and back again if you like) and a sketch to read in PWM mode (e.g. on an ATP).
Has anybody been able to make this work? If so, do you have an example?
I am not sure why this is not working - tried all kinds of possible clock values, wirings, pullups, etc. I found some mention of “repeated start” at Redboard Artemis ATP , can this also play a role?
Based on your question, I gave it try with a version of SoftWire.
It was not as easy and straight forward. Made a couple of changes, and it does with with V1.2.3 on the Artemis ATP.
It can be found on apollo3/MLX90614_SOFTWIRE at master · paulvha/apollo3 · GitHub. You have to replace the original Sparkfun library due to a number of changes. Also see the README.