Hello, I am having a problem with my MLX90614ESF-AAA TO-39 Temperature sensor and my AXE401 (PICAXE 28x2). When running the following code, the serial terminal outputs:
The temperature sensor is connected to SCL on S.13, SDA on S.12, +5V on S.0 power supply, GND on S.0 0V.
The 7-bit slave address (SA) is $5A, upper 7 bits of the slave address 81bit byte is $B4.
Since there is only one device on the i2c bus, I use $00.
How to solve this issue and get temperature data from my temperature sensor?
EDIT: I forgot to mention that I use the AXE408 shield on the AXE401. I have bypassed S.12 and S.13 so they do not connect with the shield. May be good to know.
I've also tried the following code and got the output ($5A and $B4 gave this result. $00 gave nothing.):
EDIT #2: This is how I've set it up in pictures:
There is nothing in between the wiring. Blue power supply cable goes to white cable to the sensor, green gnd cable goes to yellow cable on sensor and so on.
Sorry for the mixture of colors, not very organised.
(Tab is on the right hand side)
Better image:
AXE401 docs: http://www.picaxe.com/docs/axe401.pdf
Sensor docs: https://www1.elfa.se/data1/wwwroot/assets/datasheets/suMELEXIS_IR-tempsensor_EN.pdf
Since the CRC8 isn't 0, this happens.CRC = 18
T_ambient - Error, T_object - Error
Code:
' MLX90614_1.Bas
'
' Continually measures and displays T_ambient and T_object.
'
' PICAXE-28X2 MLX90614ESF-AAA
'
' Term 14 SCL --------------- SCL
' Term 15 SDA --------------- SDA
'
' 4.7K resistors to +5 VDC on SDA and SCL
'
' Note that this is a direct interface with the PICAXE. The Parallax and
' Sparkfun boards are not required.
'
' copyright, Peter H Anderson, Baltimore, MD, Mar 12, 11
#picaxe 28x2
#Terminal 9600
#No_Table
#No_Data
#freq m4
Symbol Lo = B0
Symbol Hi = B1
Symbol PEC = B2
Symbol Status = B3
Symbol Whole = B4
Symbol Fract = B5
Symbol Val = W3
Symbol TC_100 = W4
Symbol SlaveAdr_2 = B10
Symbol RamLocation = B11
Symbol X = B12
Symbol N = B13
Symbol CRC8 = B14
Top:
Hi2cSetup I2CMaster, 45, I2CSlow, I2CByte
SlaveAdr_2 = $00 * 2 ' use general slave adr
Again:
RamLocation = $06 ' ambient temperature
GoSub ReadRAM
If Status = 1 Then
TC_100 = Val * 2 - 27315
SerTxD ("T_ambient = ")
GoSub DisplayTc
Else
SerTxD ("T_ambient - Error")
End If
SerTxD (", ")
RamLocation = $07 ' ambient temperature
GoSub ReadRAM
If Status = 1 Then
TC_100 = Val * 2 - 27315
SerTxD ("T_object = ")
GoSub DisplayTc
Else
SerTxD ("T_object - Error")
End If
SerTxD (CR, LF)
Pause 1000
GoTo Again
ReadRAM:
Hi2cin [SlaveAdr_2], RamLocation, (Lo, Hi, PEC)
Val = Hi
Val = Val * 256 + Lo
'SerTxD ("Hello ", #TC_100, " ", #PEC, CR, LF)
CRC8 = $00
X = SlaveAdr_2
GoSub CalcCRC8
X = RamLocation
GoSub CalcCRC8
X = SlaveAdr_2 + 1
GoSub CalcCRC8
X = Lo
GoSub CalcCRC8
X = Hi
GoSub CalcCRC8
X = PEC
GoSub CalcCRC8
'SerTxD ("CRC = ", #CRC8, CR, LF)
If CRC8 = 0 Then
Status = 1 ' success
Else
Status = 0
Endif
Return
DisplayTc:
Whole = TC_100 / 100
Fract = TC_100 // 100
SerTxD (#Whole, ".")
If Fract < 10 Then
SerTxD ("0")
Endif
SerTxD (#Fract)
Return
CalcCRC8:
X = X ^ CRC8
For N = 0 to 7
If X > 127 Then
X = X * 2
X = X ^ $07
Else
X = X * 2
Endif
Next
CRC8 = X
Return
The 7-bit slave address (SA) is $5A, upper 7 bits of the slave address 81bit byte is $B4.
Since there is only one device on the i2c bus, I use $00.
How to solve this issue and get temperature data from my temperature sensor?
EDIT: I forgot to mention that I use the AXE408 shield on the AXE401. I have bypassed S.12 and S.13 so they do not connect with the shield. May be good to know.
I've also tried the following code and got the output ($5A and $B4 gave this result. $00 gave nothing.):
Temp = 37561
Code:
'Program to read from IR sensor
'SDSU FSAE
'Written by John Langholz
'MLX90615
init:
'symbols and defines
symbol ir_lo = b0
symbol ir_hi = b1
symbol ir_pec = b2
symbol slave_addr = b3
symbol temp = w2 ;b4 and b5
'initialize i2c communications
slave_addr = $B4 ;standard is $B4 but all respond to $00
hi2csetup i2cmaster, slave_addr, i2cslow, i2cbyte ;Set up the i2c protocols 10110100
main:
hi2cin $27, (ir_lo, ir_hi, ir_pec) ;read out of ram at location $07
temp = ir_hi*255 + ir_lo ;shift and add for the full word
temp = temp*2 - 27315 ;convert into *C
SerTxD ("Temp = ", #temp, 13, 10) ;temp output shifted 2 dec left
pause 10 ;wait to update temp set at 100Hz logging rate
goto main
There is nothing in between the wiring. Blue power supply cable goes to white cable to the sensor, green gnd cable goes to yellow cable on sensor and so on.
Sorry for the mixture of colors, not very organised.
(Tab is on the right hand side)
Better image:
AXE401 docs: http://www.picaxe.com/docs/axe401.pdf
Sensor docs: https://www1.elfa.se/data1/wwwroot/assets/datasheets/suMELEXIS_IR-tempsensor_EN.pdf
Last edited: