flipper_md
- 23rd September 2010, 02:35
Hi all
got that sensor for a while an I taught it would be nice to plug and play with it, but it's not behaving nice to me so far.
After a long read of the spec sheet, I came up with the following code
'I2C data communication with HP01D, low cost pressure/temp sensor
;i2Dpin var PORTB.7
;i2CLKpin var PORTB.6
; HP01Pres var WORD
; HP01Temp var WORD
; ******* READING PRESSURE *************************************************
I2CWRITE i2Dpin,i2CLKpin,$EE,$FF,[$F0] ; resquest pressure reading from sensor
; $EE is WRITE command to the HP01D
; $FF is address to write in
; $F0 is to read Pressure , $E8 is to read temp
pause 38 ; at least 38ms is required before we can read the data
I2CWRITE i2Dpin,i2CLKpin,$EE,$FD ; set sensor for retrieve result
; $EE is WRITE command to the HP01D
; $FD set sensor to read?
,
I2CREAD i2Dpin,i2CLKpin,$EF,[HP01Pres.highbyte,HP01Pres.lowbyte],NoREADAck ; Read values
; $EF is READ command to the HP01D
taugh it was pretty slick, but It does not work at all
I think there might be a problem at line
I2CWRITE i2Dpin,i2CLKpin,$EE,$FD ; set sensor for retrieve result
because i'm not sending any data? But that's the way the sensor wants it...
can shiftout do a trick here?
I also tried with I2C_SLOW setting, but no data comes out
got that sensor for a while an I taught it would be nice to plug and play with it, but it's not behaving nice to me so far.
After a long read of the spec sheet, I came up with the following code
'I2C data communication with HP01D, low cost pressure/temp sensor
;i2Dpin var PORTB.7
;i2CLKpin var PORTB.6
; HP01Pres var WORD
; HP01Temp var WORD
; ******* READING PRESSURE *************************************************
I2CWRITE i2Dpin,i2CLKpin,$EE,$FF,[$F0] ; resquest pressure reading from sensor
; $EE is WRITE command to the HP01D
; $FF is address to write in
; $F0 is to read Pressure , $E8 is to read temp
pause 38 ; at least 38ms is required before we can read the data
I2CWRITE i2Dpin,i2CLKpin,$EE,$FD ; set sensor for retrieve result
; $EE is WRITE command to the HP01D
; $FD set sensor to read?
,
I2CREAD i2Dpin,i2CLKpin,$EF,[HP01Pres.highbyte,HP01Pres.lowbyte],NoREADAck ; Read values
; $EF is READ command to the HP01D
taugh it was pretty slick, but It does not work at all
I think there might be a problem at line
I2CWRITE i2Dpin,i2CLKpin,$EE,$FD ; set sensor for retrieve result
because i'm not sending any data? But that's the way the sensor wants it...
can shiftout do a trick here?
I also tried with I2C_SLOW setting, but no data comes out