I'm new to the Arduino area.
I'm trying to get a MLX90614 temperature sensor via I2C on a Nano to run.
It works so well. But I face the problem that I can read only every 100 ms a new temperature. Of course I can query the sensor faster, but then I get the same temperature several times. Does anyone have an idea how I can increase the readout rate?
Thanks for any help - Kauf
#include <Wire.h> // I2C
#include <Adafruit_MLX90614.h> //Thermopile IR Sensor
// Init MLX90614
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
void setup(void)
{
// start serial port
Serial.begin(2000000);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Start up the I2C Port
Wire.begin();
// Start up the MLX 90614 IR- Sensor
mlx.begin(); }
void loop(void)
{
//mlx.begin();
Serial.print(mlx.readObjectTempC());
Serial.print("\t");
Serial.println(millis());
}
Also: how are you going to make sure the temperature in your system is the same at your sensor at such short times? It takes time for temperatures to equalise.
I have a very fast temperature change. Within 0.1 second, the temperature change is over. That is, the change has its maximum after about 0.05 seconds. So that I can roughly estimate the temperature profile with at least one fit, I actually need at least 3-4 measuring points in the 0.1 second.
On-chip filtering and settling time:
The MLX90614 features configurable on-chip digital filters. They allow customization for speed or noise.
Factory default configurations and the typical settling time and noise for the MLX90614 family are given below.
Device Settling time, sec Typical noise, °C rms Spike limit
MLX90614AAA, BAA, DAA 0.10 0.05 100%
Table 8: factory default IIR and FIR configuration, settling time and typical noise
Details on the filters are given in the application note “Understanding MLX90614 on-chip digital signal
filters” available from www.melexis.com.
For faster sampling you may tap into the continuous PWM output this sensor offers:
The 10-bit PWM is as a standard configured to transmit continuously the measured object temperature for an object temperature range of -20 to 120 ˚C with an output resolution of 0.14 ˚C.
This way you can receive one sample every 1.024 ms, so almost 1000 samples per second. Your big challenge with that is to retain only the data of interest as an Arduino can record no more than about half a second of such data in its RAM (2 bytes per reading makes for 2048 bytes per second - and that's the same as all the RAM an ATmega328 processor has - including what is needed to run your program).
I2C with all it's overhead, plus the need for the sensor to do a temperature conversion, means that it is comparatively slow. As you say you can read faster but you get the same temperature reading, the sensor probably converts only ten times a second. I'm sure you can find the details of that in the data sheet, as you will be able to find the details on how that PWM works exactly (if your library doesn't support it).
As you can see, the temperature will change about every 100 ms as described in the datasheet, which is too slow for me.
I also added Wire.setClock(400000); but the temperature will also change every 100 ms.
I want to give PWM a try but have no Idea how to prog it because I am a newbie...
Using google I could not find a arduino lib for using PWM with the MLX90614.
kaufpark:
As you can see, the temperature will change about every 100 ms as described in the datasheet, which is too slow for me.
I think this is simply not the correct sensor for you.
Actually I can't find the update frequency in the data sheet, but other web sites refer to a 0.1 second minimum update time.