Hi there
I am using the HP03S sensor in a circuit for a weather station. I have read all of the calibration values successfully. My values are within the ranges specified by WestAust55's pdf on this matter. I am using his code to read the raw temperature and pressure readings now. I am having some trouble, however. Both values are identical, and neither of them make sense.
I am using this code on a 20X2 at 4Mhz and 3.101 volts:
The terminal shows "32358 32358". According to WestAust's pdfs, he got 27669 and 6516. As can be seen, I am using PWM in lieu of a crystal for the clock line.
I can think of two reasons for my readings.
1. Do I need any components on the PWM line, or should I plug it directly into the sensor (which I have done)?
2. The code appears to be reading the same location (0) twice and trying to get different readings from it (temp AND pressure). Am I correct?
What should I do?
I am using the HP03S sensor in a circuit for a weather station. I have read all of the calibration values successfully. My values are within the ranges specified by WestAust55's pdf on this matter. I am using his code to read the raw temperature and pressure readings now. I am having some trouble, however. Both values are identical, and neither of them make sense.
I am using this code on a 20X2 at 4Mhz and 3.101 volts:
Code:
#picaxe 20x2
setfreq m4
pwmout C.5, 30, 61
; I2C ADDRESSING
SYMBOL PRE = %10100000 ; HOPERF HP03 Pressure Sensor onboard EEPROM at hard address
SYMBOL PRS = %11101110 ; HOPERF HP03 Barometric Pressure sensor
;
; CONSTANTS
SYMBOL PreConst1 = 16 ; HP03 series module EEPROM location for 1st byte
SYMBOL PreConst2 = 24 ; HP03 series module EEPROM location for 10th byte
SYMBOL Preset = c.2 ; PICAXE output 6 is for the HOPERF HP03 Pressure Sensor Reset
;
; VARIABLE name definitions
SYMBOL Pressure = w4 ; w4 = b9:b8 for the HP03 pressure sensor
SYMBOL PLSB = b8 ; need to separately define the MSB and LSB as I2C can only handle bytes
SYMBOL PMSB = b9
SYMBOL Temperature = w5 ; w5 = b11:b10 for the HP03 temperature sensor
SYMBOL TLSB = b10 ; need to separately define the MSB and LSB as I2C can only handle bytes
SYMBOL TMSB = b11
Main:
;
; perform one data read sequence from the HP03 pressure sensor module - remember to discard the first set of data after power-up
;
HIGH Preset ; place the pressure sensor module into active mode
SLAVEi2c PRS, i2cslow, i2cbyte ; set up to write to and read from the Pressure Sensor
WRITEi2c ($FF,$F0)
PAUSE 50 ; must pause at least 40ms - give it a little more at 50ms
WRITEi2c ($FD,$FD)
READi2c (PMSB, PLSB) ; fetch the Pressure – as MSB and LSB
WRITEi2c ($FF,$D0)
PAUSE 50 ; must pause at least 40ms - give it a little more at 50ms
WRITEi2c ($FD)
READi2c (TMSB, TLSB) ; fetch the Temperature – as MSB and LSB
LOW Preset ; place the pressure sensor module into idle mode
sertxd (#Pressure, " ", #Temperature) ; LCD module is connected to PICAXE Output 1
PAUSE 10000 ; wait for 10 seconds before another set of reading
GOTO Main
I can think of two reasons for my readings.
1. Do I need any components on the PWM line, or should I plug it directly into the sensor (which I have done)?
2. The code appears to be reading the same location (0) twice and trying to get different readings from it (temp AND pressure). Am I correct?
What should I do?