PDA

View Full Version : i2c and barometer HP01D



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

Kamikaze47
- 24th September 2010, 04:54
I would also change the line you mentioned to:
I2CWRITE i2Dpin,i2CLKpin,$EE,[$FD]

I would also change the 1st one to:
I2CWRITE i2Dpin,i2CLKpin,$EE,[$FF,$F0]

If that does not help, I would try adding the define: DEFINE I2C_HOLD 1

Do you have 4.7k pull-up resistors on both i2c lines?

flipper_md
- 24th September 2010, 22:35
I've moved to a simple 12F683 to drive the chip and I could get readings, but nothing valid as for results

now with your suggestion it seems to be getting better!

well at least for the pressure reading which in the spec sheet should be in the 30000 range.
I get 37771

still have a bug with temperature reading tough....
I get 29591 where the spec sheet call for 4100 as reference(D2).
It also swing a lot more than expected over time. With my finger on the sensor it climbs to 30096 and those should be degre units..

I will dig into that a bit more

thanks for the suggestion