Pages: [1]   Go Down
Author Topic: MLX90614 sensor  (Read 579 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,
I am trying to use the ir thermometer sensor "MLX90614".

I Connected the sensor to the arduino and I am runnig this code;
Code:
#include <i2cmaster.h>


void setup(){
Serial.begin(9600);
Serial.println("Setup...");

i2c_init(); //Initialise the i2c bus
PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
}

void loop(){
    int dev = 0x5A<<1;
    int data_low = 0;
    int data_high = 0;
    int pec = 0;
   
    i2c_start_wait(dev+I2C_WRITE);
    i2c_write(0x07);
   
    // read
    i2c_rep_start(dev+I2C_READ);
    data_low = i2c_readAck(); //Read 1 byte and then send ack
    data_high = i2c_readAck(); //Read 1 byte and then send ack
    pec = i2c_readNak();
    i2c_stop();
   
    //This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
    double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
    double tempData = 0x0000; // zero out the data
    int frac; // data past the decimal point
   
    // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
    tempData = (double)(((data_high & 0x007F) << 8) + data_low);
    tempData = (tempData * tempFactor)-0.01;
   
    float celcius = tempData - 273.15;
    float fahrenheit = (celcius*1.8) + 32;

    Serial.print("Celcius: ");
    Serial.println(celcius);

    Serial.print("Fahrenheit: ");
    Serial.println(fahrenheit);

    delay(1000); // wait a second before printing again
}

The code himself is running good, my problem is the measurements.

When I am putting my hand 5cm infront of the sensor I am geting result of 22+-, but when I am taking my hand away(15-20cm) the result are changing,.

Is this sensor has some distance limit?

Thank you.
Logged


Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no distance limit. The sensor reports the average temperature of everything in its field of view, which is a cone of roughly 90 degrees. As almost always, if you have questions for how a device works, the data sheet is a fantastic resource!
Logged

"It seems to run on some form of electricity"

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 25
ummm?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Practically speaking, it averages its field of view.

Take your hot soldering iron and slowly move it into the field of view of the device-
and then get closer to it.  It's averaging that hot iron and everything it sees as
the background, and outputting that as one number.

There are several different fields of view available- they seem to do it with lensing.

hth

t
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok guys, thank you for the information!
I found several exmaples for multiple sensros(codes), but I didnt found any circulate(the datasheet doesnt spesificate capasitor and resistors values. And he is workign in 3.3v). Does any one have an example ?
BTW, when I attach 2 sensors to the same pins( analog 4 and 5), the I2C scaner cant find anything.
Thank you
« Last Edit: February 28, 2014, 04:36:26 pm by BN.barak » Logged


Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Of course two sensors will interfere with each other, until you have changed the device address of one.
Get one working first. http://bildr.org/2011/02/mlx90614-arduino/
Logged

"It seems to run on some form of electricity"

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am sorry, maybe I wasn't clear. I made one of them works, but when I attach 2 sensors to the arduino the I2C scanner doesn't find any of them.

What's the best method to connect 2 sensors?

Logged


Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Of course two sensors will interfere with each other, until you have changed the device address of one.
See the data sheet on how to change the device address of one sensor.
Logged

"It seems to run on some form of electricity"

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And I did change the address. Now I have 0x5A and 0x57. But when I try to scan them all in the same time , the scan returns me black. When I scan them individualy they are working perfect.
Logged


Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But when I try to scan them all in the same time , the scan returns me black.
What does that mean?
Post your code, using the code tags (# button) and some sample output.
Logged

"It seems to run on some form of electricity"

Pages: [1]   Go Up
Jump to: