Melexis SMBus IR Thermometer - NFI

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..

  1. Connect as instructed (if you haven't changed the pins, of course)
    SCL --> Analog5
    SDA --> Analog4
    Vdd --> 3V3
    Vss --> Gnd

AND (this is really important!)

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.

  1. 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..)

  1. 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 100000L
    Don't otherwise touch the code if you don't really know what you are doing..

  2. 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.