MLX90614 Infrared thermometer with PICAXE 18X

Mr S

New Member
Hi All,

I am currently trying to use i2c to read data from the MLX90614 IR Thermometer.

data sheet here: http://www.sparkfun.com/datasheets/Sensors/Temperature/SEN-09570-datasheet-3901090614M005.pdf

I have been trawling through the datasheet and PICAXE i2c tutorial materials but withour success.

My code currently looks like this:

' IR thermometer test code

' I2C bus comms
' 100Khz 7bit address

thermoread:

do
i2cslave %10100000,i2cslow,i2cword 'sets up i2c addressing for MLX90614(Slave address0x5A)

readi2c $07,(w0) 'reading from RAM 007h, returning 16 bit value

sertxd (#w0,13,10)

pause 1000

loop

All I keep getting is a return value of 255 which I think is default when things aren't working.

Has anyone had any success with this device or could point out where I am going wrong?

Thanks
Darryl
 

MFB

Senior Member
I sure there was a past thread here about using this sensor. Have you done a search?
 

Mr S

New Member
I did a search and could only find someone interfacing from a picaxe 08 which didn't use i2c.

I may be being incapable but I couldn't seem to find anything by searching the part number.

Darryl
 

Mr S

New Member
"I may be being incapable" - clearly proved myself right.

Thanks for the pointer.

Darryl
 

Mr S

New Member
Thanks Peter,

I have been studying your codes and trying to figure out where I am going wrong. I'm quite new at this and had a couple more questions.

When looking at your code, the slave address appears to be 1/2 that of the $5A in the data sheet. Could you explain why that is?

Also I understand the check sum idea using the CRC, do I need this from the start or is that just used to confirm integrity of data packets?

I am using a picaxe 18X and my code is below, still not functional. All I am trying to do is simply read something from RAM $07 to confirm that the comms are working. At the moment I am just getting "255" returns which I think is default for not functioning.

Any suggestions gratefully recieved.

Darryl
(Currently pulling hair out!)

Code:
' IR thermometer test code

' I2C bus comms
' 100Khz 7bit address
#picaxe 18x
#Terminal 4800

thermoread:

do
	hi2csetup i2cmaster %10110100,i2cslow,i2cbyte       'sets up i2c addressing for MLX90614(Slave address$5A)

	hi2cin  $07,(b0,b1,b2)     'read from RAM $07

	pause 1000

	sertxd (#b0,#b1,#b2,13,10)    'write to terminal

	pause 1000

loop
 
Last edited:

Technical

Technical Support
Staff member
As with Peter's examples try with the 'general' slave address of 0 to start with. Also take the hi2csetup out of the loop.

Code:
    hi2csetup i2cmaster, 0,i2cslow,i2cbyte       'sets up i2c addressing for MLX90614(Slave address$5A)

do
    hi2cin  $07,(b0,b1,b2)     'read from RAM $07

    pause 1000

    sertxd (#b0,#b1,#b2,13,10)    'write to terminal

    pause 1000

loop
 

Mr S

New Member
Thanks technical, I tried those suggestions but still without success.

I have triple checked the connections (I have 4k7 pullups on the sca and scl lines) and the supply/ground voltages are good (5v from linear reg) on both the sensor and chip.

I also put a scope on the sca and scl lines, it appears that data is present but my scope is not able to hold.

Not sure what to try next?

Darryl
 

MartinM57

Moderator
I also put a scope on the sca and scl lines, it appears that data is present but my scope is not able to hold.
Full strong 5v->0v transitions? You've got 4K7 pull resistors on both SCL and SDA? Any chip enable pins on the sensor need setting (not looked at the datasheet)?
 

hippy

Ex-Staff (retired)
Any chip enable pins on the sensor need setting (not looked at the datasheet)?
It's well worth the read - the I/O pins are used for multiple purposes and with a brief reading it wasn't clear how you ensure it's in one mode of use or another !

If moving forward with an 18X isn't going anywhere, but PHA has code which works for a 20X2, I'd suggest getting a 20X2 and seeing if that tried and tested code also works with this particular sensor; if not it's not likely to work with an 18X either.

If it works with the 20X2 but not the 18X it could be a choice between pragmatism and using a 20X2 or the effort of trying to make it work with an 18X. At least at that point it would be known that the sensor does work whereas at the moment we don't know what's working or not at all.

The sensor uses SMbus rather than I2C and, although theoretically compatible, it is possible there's something which makes it work with a 20X2 but not an 18X.
 

Mr S

New Member
Thanks for the suggestions, it had occured to me to get a couple of 20X2 parts and try those using Peter's code.

Many thanks for the suggestions.

Darryl
 

Profw

Member
Darryl,
I too have been trying to get the MLX90614 to work with PICAXE 18"s with no success. I've even tried the 20X with Peter's examples to no avail. Did you ever get yours to work? I called Peter to explain my frustration, but he has passed away according to his son.

Chuck
 
Top