I have entered the world of Arduino and have gone through some tutorials and have picked up the language ok. I also purchased a Melexis IR Thermometer model # MLX90614ESF-AAA. It uses a SMBus data connection and from my reading its the same as I2c. This unit however only supports the commands read word and write word. I've been playing with the Wire library to get it to read data from the device but I'm not having much luck. Specifically the problem is working out how to send a command to the unit and how the ram addressing and eeprom addressing works.

I'd appreciate it if anybody could give me some clues and have a quick read of the spec sheets from the melexis website http://www.melexis.com/Sensor_ICs_Infrared_and_Optical/Infrared/Digital_plug__play_infrared_thermometer_in_a_TO-can_615.aspx

Its got some assembler examples there but I would like to use the Wire library to do talk to this thing. The spec sheets says the default SMBus address is 0x5A (90) but then I read in the wire library the addressing is using only the top 7 digits so it becomes 45. Is this right? I can get numbers back from the device but I don't know what they mean, I'm supposed to be reading the temperatures from the device but I don't think thats what I'm doing.

I think if it I just got on the right track with how to communicate to this thing I should be ok.

My question is, does my above code accurately reflect what the pseudo code ( supplied by melexis) is demonstrating. When I compile and run this code allI get is 700 ( 7 first byte - data byte low, 0 data byte low, 0 PEC). The 7 however is just the command I sent it in the fist place.

Still working on this. I made a logic analyser from a website I found and managed to get a clock diagram of what is happening:

I think the issue is the stop bit after the send command. Reading the pseudocode I posted above it doesn't mention a stop bit so I am not sure if this is stuffing it up. All I know isthat I shouldn't be getting 255,255,255 as the three bytes. Reading the melexis forums (whom made the ir thermometer) they mention that a 0xFF suggests a timing issue.

I also read this on the SMBus spec sheet:

"Specific SMBus protocols require the master to generate a repeated START condition followed by theslave device address without first generating a STOP condition."

I think, from my timing diagram, this is exactly what I am doing.

Please can anyone suggest how I would use the wire library but stop sending that stop bit halfway through until all the 3 bytes (low,high and PEC) are recieved.

I have had contact with the manufacturer of the device who has agreed that the stop bit should not be in there after the command only a repeated start condition. Does anyone know how to send only a repeated start condition and not a stop/start condition using the wire library?

Well I got it working using a different library. It appears wiring cannot do it.

I used Peter Fleurys libray here:

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

Scroll down and download the i2c master libraries. Create a folder in /{arduino root}/hardware/libraries and copy thei2cmaster.h and which .c file you want (it supports hardware and software i2c, I only used the hardware one twimaster.c).

You need to change the .c file to .cpp (otherwise it won't link when compiling) and don't forget to change some of the valuesin the .h and .c file depending on your mcu etc.

Once you load arduino ide, it should build a .o file in the folder you created and then you can import the library from the menu or put in your code:

Then write your program, the help file lists all the functions available and it worked on the first try for me. So I can say this library works for smbus devices. Here's my sample code using the library (NB: You must bit shift left whatever your device address is):

The device could not accept a stop/start condition transmission during a transaction. From what I understand, you cannot send a repeated start condition in the wire library without first sending a stop condition. This does not work with the smbus device I was using. I don't know if the device is out of spec or the wire simply doesn't support all smbus communication protocols.

CalculusAE, I hope you're still getting emails for this thread. I have been trying your code to get readings from the MLX90614 and haven't had any luck. Now I don't know if I might have damaged the device or what. I'm new to Arduino and as you know SMBus is not easy. Anyway, I have the pin voltage in the Arduino's 3.3V, and SDA into Analog4 and SCL into Analog 5. I have 4.7k pull-ups, but have also tried without.

It fires the init but doesn't get past the i2c_start_wait. Any help GREALY appreciated!

Thanks Grumpy Mike, wrote that thing too fast. I also failed to mention those are the resisters I used for the TPA, don't know if they'd work with the Melexis. Also, while I'm here. This is also a good thread on Sparkfun where I posted Dave Eaton's code.

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.

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

3) 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

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

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.

BTW....Hooking up an Xbee is easy using the standard breakout board and Xbee to USB converter for the PC end of things. Just make sure all of the baud rates are the same (in the code and in the Xbee based on the setup in the XCTU program from Digi).

Thanks to Dave Eaton for making a fun afternoon successful, CalculusAE for a great trail of technical breadcrumbs and Peter Fleury for posting the libraries.

Now....how does one get more than one MLX sensor to work on this two wire inter face? I assume the wiring is simply in parallel. How can I identify and call out different MLX sensors in the code?

Thanks Sensorjunkie for taking the time to put this all in one place! In the past few months I've learned a few things that might be helpful here.

First, most Melexis Thermopiles for sale have a wide field of view, about 35-degrees. There is a model F with a 10-degree field of view but seems difficult to get.

For reference, a standard webcam has a field of view of 40-degrees by 30 degrees. It's difficult to focus a thermopile because glass and plastic absorb around half of radiation between 3 and 20 micrometres. Germanium is the best material, but any research will show you that those lenses are a fortune. To get around the absorption issues in plastic you'll notice that the IR thermometer you buy from Sears uses a fresnal lens. These lenses magnify with the least amount of lensing material.

Also, let me point out a common misconception I come across, the infrared that the Melexis picks up has almost NOTHING in common with the infrared that your digital camera can be converted to see. Infrared photography deals with 800 to 1,000 nanometers, or just below the red spectrum. If you measure that distance as a football field, thermal radiation starts about 10 football fields lower. Silicon is basically transparent to that radition. YOU CANNOT MODIFY YOUR DIGITAL CAMERA OR BUY A LOW COST SECURITY CAMERA that sees true thermal radiation from your PC power supply, let's say.

In the January, 2010 issue of Nuts and Volts there is an interesting article by L. Paul Verhage, that uses a parallax thermopile for a near space infrared telescope. The Melexis could be used in similar applications. I think his technique for limited the field of view of the thermopile would work well with the Melexis.

Thanks again Sensorjunkie for making a go-to-place for getting the Melexis to work with Arduino!