Thank you for all the help with connecting the Melexis MLX90614. I have not been getting a response from the device whatsoever. By going through your code, I found that the code never progresses beyond the code line "i2c_start_wait(dev+I2C_WRITE);" I've yet to get a response by the MLX90614 any other method, and I would be very gracious if anyone could help explain to me what I'm doing wrong. Thanks!

I have been trying to get the i2cmaster.h library to work in my arduino development board with no success. I renamed the twinmaster.c to a .cpp file and changed the F_CPU definition as well as the SCL_CLOCK . . . However, when I include i2cmaster.h, I am not able to even get a "Hello World" program to work . . . here is some example code:

Make a folder in /{arduino root}/hardware/libraries and extract thei2cmaster.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)

Did you mean /{arduino root}/libraries ? Because there is no /{arduino root}/hardware/libraries folder . . . only /{arduino root}/hardware/arduino and /{arduino root}/hardware/tools

Is there any reason the code isnt working? i tried using Serial.println to see till what stage the program executes and it stops before

i2c_rep_start(dev+I2C_READ);

doesnt go beyond thatAny ideas?Also does the 5v version require me to pull-up to 5v or 3.3because thts SMBus spec?Also the melexis datasheet gives a figure which shows the pin configurations and is labelled "TOP VIEW"Does that mean it shows the pins coming out of the page or the other way round??Im confused

i have tried the codes too, but no output appear at all. i think it is stuck in the i2cmaster. even the printf doesnt work at all but when i remove the i2cmaster.h and comment out the unnecessary codes-left only the prints--it works. so i believe it is caaused by the i2cmaster.h

I have purchased one of these sensors and with the help of this thread I was able to get it up and running rather quickly. Per the data sheet, changing the read address from 0x007 to 0x006 will give you the temperature of the internal device (Ta). This works great.

I'm using this sensor to measure the temperature of a steel surface, which has an emissivity of 0.35. These sensors are set at a default emissivity of 1.0. This is giving me large errors in measuring my surface.

The data sheet lists the EEPROM address for several objects that can be customized, page 11. The 0x004 address corresponds to the emissivity constant. Equal to 65535 * E.

My question is, how do I access the EEPROM on this device? Page 18 of the data sheet lists some Opcode's for certain commands. (what is an "Opcode" anyway?) 000x xxxx = RAM Access and 001x xxx is EEPROM Access.

I'm confused on how to implement the switch to EEPROM access. Could someone help me out on how to modify the code to read and write to the 0x004 address on the EEPROM?

I'm making some progress. Slowing understanding more how this I2C communication works. I figured out that the addresses shown in table 5 on page 11, must have 20 added to them. So 0x004 becomes 0x024x. Someone can probably explain the reason why better.

So I can now read the existing emissivity coefficient correctly. High & low byte = 255, which gives you 65535 combined. Exactly what the data sheet says.

In order to write a new value you must first erase (write 0) to the cell, and then proceed to write your value. This is where I am having problems. Take a look at my code.

My first post to this forum.. I just wanted to share my solution for the problem I and several others seem to have faced when trying to interface with the MLX90614.

I first tried everything suggested in this thread, then googled through a loads of other sites and forums, and also browsed through an extensive amount of documentation and other material provided by Melexis web site. I tried virtually everything without success and finally returned back here..

First of all, lots of thanks for Sensorjunkie, his(?) instructions really work if you just follow them (and adapt a bit if you are using newer version of Arduino software - mine is the Arduino 0021 which is the latest one at the moment).

Below are some comments/details/minor adaptations to Sensorjunkie's instructions..

Use two 4K7 (4.7 KOhms) resistors to physically pull-up the SCL and SDA connecting them to Vdd on the breadboard. THIS was the reason why the connection to my sensor could not be properly started. So the analog-pull-up-PORTC-stuff on the code is definitely not enough to make things work.

2) Download Peter Fleury's nice library...

BUT place it under /{arduino root}/libraries/"what-ever-folder" where the current Arduino software looks for the libraries when started. You also have to rename the "twimaster.c" to "twimaster.cpp" as instructed so that Arduino can build it when launched. You also have to create a "keywords.txt" file inside the "what-ever-folder" where you define the library functions (function names and KEYWORD2 only). Without doing this Arduino cannot find and build the library. You can copy and edit the keyword file from some other library or see some help at Arduino's LibraryTutorial (Sorry, but it seems I cannot mail any links - just google for it..)

3) Modify the twimaster.cpp to reflect the Arduinos 16 MHz clock (I have Arduino UNO & Duemilanove with ATMEGA 328P). You can also scale down the speed of the SMBus to 50 KHz as instructed but mine works just fine using the 100 KHz as well. Generally, I think they suggest selecting anything b/w 10 to 100 KHz for SMBus rate. F_CPU 16000000UL SCL_CLOCK 50000L // or 100000LDon't otherwise touch the code if you don't really know what you are doing..

4) Now just copy Dave Eaton's code (and remember to mention him in your file:) and it should work like a charm. I adapted the code by Martin Nawrath (Google for "Nawrath MLX90614"..) that gives you also the ambient temperature values (i.e., the temperature of the sensor itself). But you can also add that part to Dave's code as well.

Some other points: - you can use either the general device address 0x00 that works for all MLX90614 sensor models or the address of the specific sensor sub-model you have (0x5A in my case)- remember to do the "<<1" operation for the address as its not done automatically by the twimaster library- use 100nF capacitor (I use metallic film capacitor of type 104) between Vdd and Vss to minimize the power supply noise (keep the leads as short as possible between the pins)- the addresses for object temperature (0x07) and ambient temp (0x06) are correct- you cannot use the Wire library to interface with the SMBus protocol of the sensor, it just doesn't work

That's my two cents.. I hope this helps you to take most of the sensor.

Stepper_Easy_Driver_1_7_With_Cloud_detector_zip.cpp:7:23: error: i2cmaster.h: No such file or directoryStepper_Easy_Driver_1_7_With_Cloud_detector_zip.cpp: In function 'long int readMLXtemperature(int)':Stepper_Easy_Driver_1_7_With_Cloud_detector_zip:345: error: 'i2c_init' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:346: error: 'I2C_WRITE' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:346: error: 'i2c_start_wait' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:347: error: 'i2c_write' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:347: error: 'i2c_write' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:349: error: 'I2C_READ' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:349: error: 'i2c_rep_start' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:350: error: 'i2c_readAck' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:352: error: 'i2c_readNak' was not declared in this scopeStepper_Easy_Driver_1_7_With_Cloud_detector_zip:353: error: 'i2c_stop' was not declared in this scope

I have the ic2mater files in the correct directory and renamed twimaster.c to twimaster.cpp

Anyone help please

Here's the sketch Im using

//START OF FOCUS CONTROL INITIALISE// include the library code:#include <LiquidCrystal.h>#include <Stepper.h>#include <Servo.h>#include <i2cmaster.h>

//If there is a command in the buffer then run the process command subroutine if (bCommandReady == true) { bCommandReady = false; // reset the command ready flag cliProcessCommand(); // run the command }

if (UPDATE){ UPDATE=false; FocusPrintStepsFun(); //Print the number of steps FocusPrintPositionFun(); //Print the Position SerialDATAFun(); // debug mainly, gives detailed information about the current state of the machine

void FocusPrintPositionFun (void) {//Print the current position on the second line of the LCD, this is not absolute. lcd.setCursor(0, 1); //lcd.clear(); lcd.print("Position = "); lcd.print(Position); lcd.print(" ");

}

void FocusINFun (void) {//Move the Stepper IN. int Steps = 0;

switch (MotorType){ case 0: //Serial.println("Stepper Focus IN"); // add stepper movement function and call it here // will need to 'reset' the arduino via serial to invoke the motor code? // we need to start saving data in eeprom, it will make things much easier. // will need to use double the amount of eeprom space for the variables // one set for the user data and 1 set for defaults. Also means we can start to pack // some flags as bits break;

if (Absolute == false) { //If not Absolute move the number of steps if ((Position-NoOfSteps)>=0) { //myStepper.step (NoOfSteps); EasyDriverStep(true,NoOfSteps); Position=Position-NoOfSteps; } } else if (NoOfSteps < MaxStep) //Absolute :- work out the number of steps to take based on current position { if (NoOfSteps<Position){

if (Absolute == false) { //If not Absolute move the number of steps if ((Position+NoOfSteps)<=MaxStep) { //myStepper.step (NoOfSteps); EasyDriverStep(false,NoOfSteps); Position=Position+NoOfSteps; } } else if (NoOfSteps < MaxStep) //Absolute :- work out the number of steps to take based on current position { if (NoOfSteps<Position){

The errors indicate that - for some reason - your compiler cannot find the library you are trying to use.

First, I suggest that you try to place the "#include <i2cmaster.h>" line before the other includes as sometimes small things have surprisingly big consequences..

Second, you should recheck (once more) that you have put the "twimaster.cpp" and "i2cmaster.h" files it in a right place (i.e., /{arduino root}/hardware/libraries for older Arduino sw, /{arduino root}/libraries for the newer ones).

Inside the correct library folder you should see other folders, for example, "Servo", "SorftwareSerial", "Wire", etc.. I named my folder as "I2Cmaster" and put the two files inside that.

After that YOU HAVE TO create a separate file called "keywords.txt" inside the very same folder. You can copy/paste the lines that I have in my keyword file at the end of this post. Without this file the Arduino software cannot automatically figure out what you've defined in your library.. A bit stupid, yes, but that's the way it's done. The Arduino environment has to be closed (if running) as it is documented to find the new stuff only when started.

Given just a quick glance the code otherwise seems valid although it does not really show neither the readMLXtemperature(int) function nor where you call it. Just to check the other part of the code you can comment the function and the library include to see if it otherwise compiles ok.

new to the conversation, I am curious if anyone has tried using the PWM output mode of this device instead of the SMBus. It seems like this would be much easier. That is, assuming one would be able to correctly configure it for PWM mode. The datasheet seems to say that EEPROM value PWMCTRL at address 0x003 would need to be changed. (I do not know how to do that... new to Arduino and microcontrollers)

however, after that step, the device would appear to be quite easy to read from. Am I missing something?

I just purchased this device on a board from Parallax because I thought it might be easier to interface but after further reading I am not so sure... didn't receive the device yet.