Symbol DEVICE_ADDRESS = 0x68 * 2
Symbol FIRM_ADR = 0x38
Symbol TEMP_ADR = 0x08
PowerOnReset:
HI2cSetup I2CMASTER, DEVICE_ADDRESS, I2CSLOW, I2CBYTE
Pause 3000
SerTxd( "Starting", CR, LF )
MainLoop:
Do
w1 = 0
HI2cIn FIRM_ADR, ( b0 )
HI2cIn FIRM_ADR, ( b3, b2 ) ; w1 = Firmware
Sertxd( "Firmware = ", #b3, ".", #b2, CR, LF )
Pause 1000
w2 = 0
HI2cIn TEMP_ADR, ( b0 )
HI2cIn TEMP_ADR, ( b5, b4 ) ; w2 = Temperature
b1 = w2 / 100
b0 = w2 // 100
If b0 < 10 Then
Sertxd( "Temperature = ", #b1, ".0", #b0, "C", CR, LF )
Else
Sertxd( "Temperature = ", #b1, ".", #b0, "C", CR, LF )
End If
Pause 5000
SerTxd( CR, LF )
Loop
#Picaxe 28x2
#no_table
#no_data
Symbol DEVICE_ADDRESS = 0x68 * 2
Symbol CO_ADR= 0x10
Symbol FIRM_ADR = 0x38
Symbol TEMP_ADR = 0x08
Symbol ERROR_ADR = 0x00
PowerOnReset:
HI2cSetup I2CMASTER, DEVICE_ADDRESS, I2CSLOW, I2CBYTE
Pause 3000
SerTxd( "Starting", CR, LF )
MainLoop:
Do
w1 = 0
HI2cIn FIRM_ADR, ( b0 )
HI2cIn FIRM_ADR, ( b3, b2 ) ; w1 = Firmware
Sertxd( "Firmware = ", #b3, ".", #b2, CR, LF )
Pause 1000
w2 = 0
HI2cIn TEMP_ADR, ( b0 )
HI2cIn TEMP_ADR, ( b5, b4 ) ; w2 = Temperature
b1 = w2 / 100
b0 = w2 // 100
If b0 < 10 Then
Sertxd( "Temperature = ", #b1, ".0", #b0, "C", CR, LF )
Else
Sertxd( "Temperature = ", #b1, ".", #b0, "C", CR, LF )
End If
pause 1000
w3 = 0
Hi2cin CO_ADR,(b0)
Hi2cin CO_ADR,(b7,b6)
sertxd("CO2 = ", #w3," ppm",cr,lf)
pause 1000
Hi2cin ERROR_ADR, (b2)
Hi2cin ERROR_ADR, (b1,b0)
sertxd("ERROR BITS = ",#bit15,#bit14,#bit13,#bit12,#bit11,#bit10,#bit9,#bit8,#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,cr,lf)
Pause 5000
SerTxd( CR, LF )
Loop
It could be that some power-on delay needs adding, or one needs to discard some initial readings until it has settled down.It now reading the 2 values as you intended not sure
what I did.
Looking at the PSP4731.pdf datasheet link in your second linked datasheet that says; 3.05V to 5.5V. Table 1, page 3.The data sheet shows it conected to a 1.8v device would both the device and the picaxe at 3.3v cause a problem