MLX90615 in PWM mode interfaced with Arduino UNO

HELLO!

I want to interface the MLX90615 IR temperature sensor with my Arduino UNO. I tried SMBus configuration but the i2cmaster library seems to be blocking out the rest of my code or atleast is blocking out my serial communication. wire library isn't working either. :~

So I tried switching to the PWM mode, but I am not able to figure out writing the code. =( Help please?

If anybody could tell me how to unblock the serial communication or could help me write the PWM code, it would really help me out! Thanks! :%

This is what I tried to work on till now :

  1. Hardware:
    Connect the MLX90614 (refer to the datasheet) as follows:
    Pin 1 on MLX (SCC) connect to ANALOG pin 5 on Arduino
    Pin 2 on MLX (SDA) connect to ANALOG pin 4 on Arduino
    Pin 3 on MLX (VDD) connect to 3.3V on Arduino
    Pin 4 on MLX (VSS) connect to GROUND on Arduino

Now use "pull ups" on the SCC and SDA lines by connecting a 4.7K ohm resistor from the Pin 3 VDD line to the SCC line and a 4.7K ohm resistor from the Pin 3 VDD line to the SDA line.

  1. Software:
    a) Download the I2c libraries as follows:

Go to:

homepage.hispeed.ch/peterfleury/avr-software.html

and download the i2cmaster.zip

Make a folder in /{arduino root}/hardware/libraries and extract the
i2cmaster.h and twimaster.c files. Now rename the .c file of twimaster to .cpp (YES I KNOW IT SOUNDS WIERD BUT RENAME AND MAKE SURE THESE FILES ARE IN THE RIGHT LOCATION I.E. IN THE LIBRARIES FOLDER OF THE ARDUINO CODE)

Make sure you restart Wiring if you load a new library into it so it can be found when it is called.....

  1. Now you need to modify twimaster.c
    Open it in a simple text editor and change the following if you are using an Arduino Duemilanove

Edit the twimaster.c to reflect the 16MHz clock, and change the bus frequency to 50Khz by changing the code at the beginning to:

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

/* I2C clock in Hz */
#define SCL_CLOCK 50000L

  1. Now copy Dave Eaton's EXCELLENT code into Wiring. You may have issues with seeing the new libraries or with missing brackets when you verify the code.
    Dave's fix for the high precision (2 decimal place) thermal read also works well (this sensor is incredibly sensitive).

This is Dave's code as I used it:

#include <i2cmaster.h>

void setup()
{
Serial.begin(9600);
Serial.println("Hello!");
i2c_init(); //Initialise the i2c bus
Serial.println("Return from i2c_init");
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);


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
double tempData = 0x0000;
int frac;

// 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;
tempData = tempData - 273.15;
Serial.print((int)tempData); //Print temp in degrees C to serial
Serial.print(".");
tempData=tempData-(int)tempData;
frac=tempData*100;
Serial.println(frac);
delay(100);  
}

Upload the code in the Arduino making sure you are on the correct COM port (obviously). Open the serial port viewer (COM port correct?) and make sure the baud rate corresponds with the the baud rate in the code and you should be able to see the temperatures streaming live from the serial port.

This was a reply by Sensorjunkie to a post in the forum

http://forum.arduino.cc/index.php?topic=21317.msg158269#msg158269

See the "smiley-cool" below? That won't work! Find some known working code that you can download, rather than cut and paste from a forum post. Also, please use code tags (# button) when you post.

tempData = (double)(((data_high & 0x007F) << smiley-cool + data_low);

Thank you so much for taking time to reply! I changed that. It's supposed to be.. << 8 ) .. In my code, I did modify it and try. Still no luck =(
I did use the "insert code" option! :astonished:

I use Pololu's code for the MLX90614 and have no problems. It uses the I2C hardware directly, so no library is needed.
Pololu - 3. Software Of course, you will need to change the print statements.

:cold_sweat: Thank you! :.

I was running into this problem with MLX90615, either. The libraries I used were found on github, and the i2c address was changed from 0x5A to 0x00. The sensor seemed working since it gave out ambient temperature and object temperature values, but the two values did not vary at all, even though my hand was 1-2cm close to it or was left.

Ambient = 49.43C Object = 49.43C
Ambient = 120.97F Object = 120.97F
Ambient = 49.43C Object = 49.43C
Ambient = 120.97F Object = 120.97F
...

Hi friends.

I need change de output on mlx90614 at PWM.

I can't do it. Anyone still in this thread?