HOPERF HP03 i2c Pressure Sensor

westaust55

Moderator
Having purchased a HOPERF HP03S i2c pressure sensor I have tonight got it hooked up along with 3 other i2c devices.

The PICAXE and two i2c devices operate at 4.5 to 5Vdc and the HOPERF HH10D (Humidity) and HP03S (Pressure) sensors operate at 3.3Vdc.


Noting that others are also interested in pressure sensors including the HOPERF range and wishing to avoid hijacking other threads, I will present some details here as time permits.

Some background first:

there are a couple of pressure sensors in the HP0x range
1. the HP01 series, and
2. the HP03 series
there are others but they are not discussed here

the HP01 series operate from 2 to 5Vdc but only give a relative pressure value.

the HP03 series operate from 2 to 3.3Vdc and have 11 calibration parameters stored in an onboard EEPROM at address $000 so the calculated result is actual pressure in hPa (or mbar).

The HP03 EEPROM mates well with the HH10D humidity sensor where the EEPROM is at address $001.

Each pressure sensor series is available in two or three formats.

"S" (as in HP03S) is a surface mount format with a board of just 9 x 9mm with 6 contacts along one edge at 1.27mm centres.

"D" (as in HP03D) is a socket mounting module 15mm x 10mm with 6 pins at 0.1" / 2.54mm centres.

I have purchased the HP03S and managed to solder six very short leads from the edge contacts to a 6pin header.

Attached is a table showing the EEPROM locations for the 11 parameters and the values I have read.
All are within the stated ranges for each parameter.

Note that HOPERF modules (HH10D and HP0x range) store the MSByte in the lower byte of a word pair whereas the PICAXE BASIC has the MSByte in the upper byte of a word pair. :)

Get the HOPERF module parameter bytes reversed and things will not make sense. Out of the 11 parameters if I read the byte pairs wrong, I would see 4 parameters out of the stated range and all incorrect (giving crazy values no doubt) :eek:

More another day as I experiment (but very heavy work commitments for the next few weeks) . . . .
 

Attachments

Last edited:

westaust55

Moderator
Had a chance to progress a little further this evening.

Set up to read the pressure and temperature data from the HP03.

Note here: If the Master clock (32kHz) is not functioning, the value you will read for the pressure is zero as the ADC is not functioning. At least this is an indication that the i2c comms is working as a wrong address will give $FF.

Have done some maths in Excel and see that some of the intermediate values are fractional and other may overflow the PICAXE byte/work capabilities.
Attached is an excel calculation. The pressure values I was getting were consistent albeit 6hPa lower than the local BOM reports. Temperatures were showing the correct data.

Ran the Master Clock into the PICAXE with divide by 2 and the frequency is slightly down using the COUNT function which may explain the slightly low pressure readings. Have some other watch crystals, so will try another as a test.

EDIT: found an error in my Excel Spreadsheet maths. Actual error is down to ~3 hPa. Revised attachment uploaded
 

Attachments

Last edited:

jgershonw1

New Member
6 hPa at is about the same error that I was getting at minimum, which was not really good for my application. It will be interesting to see if you can get some improvement in the accuracy.
 

manuka

Senior Member
Is this 6hPa consistently low across the range? In the lower atmosphere air pressure falls ~1hPa for each 10m climb- easily checked by taking a barometer on a lift ascent of course. Your "BOM" value ( unknown abrev.- is this the nearby airport?) will be quoted as if at sea level, so have you factored in local elevation? Hence you're not taking readings at 10m x 6hPa = 60m ASL altitude are you!? That's only a couple of hundred feet, & may not have been appreciated if gradually ascended. Confirm with a GPS or map perhaps.

In contrast,"ear popping" is common while driving the several hundred metre (~500-600 feet) steep hills we have here in Wellington city. Stan
 

westaust55

Moderator
Hi Manuka,

BOM = Bureau of Meteorology (our local Australian weather department)

I was using the Perth city (Mt Lawley) weather station data. While I do not yet have exact altitudes for both Perth and my home, they will I believe be less than 60 metres difference.

Over time I can compare and see if it is a constant offset or how it varies.
Last night, kinowing that temperature affects the presure sensor reading, I found that if I put my fingers around the sensor to warm it up.
The result was then 1012hPa and 30 degC which was spot on.

At the moment my sensor is exposed to light in the room and a quick test shielding the sensor from light did not produce any significant variation in readings as other sources of information suggest.

Can also compare with my handheld GPS to see how the data compares.

This will all be easier once I have the maths done ensuring that I minimise error due to integer BASIC.
 

westaust55

Moderator
@jgershonw1,

Do you still have available the values for the 11 parameters C1 to C7 and A to D
.

About to start looking into some flexible maths that might prevent word variable overflow while doing the calculations yet maximise accuracy to make the integer maths more universal.
 

westaust55

Moderator
OK- but check your nearby BOM insights at => http://weather.gladstonefamily.net/site/94608
The BOM website gives the height of each station.
With the distances between each, pressure gradient, and possible accuracy/error tolerance, data can result in a higher altitude having higher pressure.

eg at this instant in time:
Perth is 25m and presure = 1010.7hPa
Home is approx 24m (northern Suburbs 18km north of Perth)
Perth airport 10m and pressure = 1010.9
Jandakott = 30m and pressure = 1011.1 (southern Suburbs)
Rotnest Is = 54m and pressure = 1011.2 (~20km off WA coast)
Pearce = 50m and pressure = 1011.2 (~20km inland)
Mandurah 3.0m and pressure = 1011.0 hPa ( 100km south)
 

manuka

Senior Member
WestAust55: OK- I've not got a Hope pressure module for my own data reading,tests & calibrations, but still point out that local altitude issues may relate to your deviations. Home barometers are set to match the local weather reports, but these express pressure reduced to sea level, not the actual local atmospheric pressure at the measuring site.

In an extreme case a station, in say northern India at 2000m ASL, may have a local pressure of just ~800hPa (& associated low temp water boiling issues etc), but it'd still be expressed corrected for altitude as ~1000hPa. I'm sure you know all this, but I've found in the past it's not appreciated!
 

westaust55

Moderator
WestAust55: OK- I've not got a Hope pressure module for my own data reading,tests & calibrations, but still point out that local altitude issues may relate to your deviations. Home barometers are set to match the local weather reports, but these express pressure reduced to sea level, not the actual local atmospheric pressure at the measuring site.

In an extreme case a station, in say northern India at 2000m ASL, may have a local pressure of just ~800hPa (& associated low temp water boiling issues etc), but it'd still be expressed corrected for altitude as ~1000hPa. I'm sure you know all this, but I've found in the past it's not appreciated!
True Manuka.
One could go high enough to the point of boiling the water but too cold for a cuppa. :eek:

When IO can collect some data for pressures at significantly different pressure levels and compare with the BOM site, that will give a better indication of what level of error is occuring.

In the meantime I am starting to work on the necessary maths which requires some scaling to keep accuracy and careful manipulation due to minimal PICAXE variables.
 
Last edited:

westaust55

Moderator
Found an error in the maths in the Excel spreadsheet I did prior to starting on PICAXE BASIC maths.

This has seemingly reduced the error from 6hPa to 3 to 4 hPa so getting better.
Uploaded a revised attachement at post 2. The yellow shaded cell is where the corrected value exists.
 

westaust55

Moderator
Working out the maths for the HOPERF HP03 pressure sensor

Have spent some time over the past few evenings and hope (fingers crossed) that I have worked out a series of calculations to determine the barometric pressure from the HP03 pressure sensor within the PICAXE chip.

A bit of fun in variable manipulation considering there are 7 word parameters and 4 byte parameters which vary from module to module, plus 2 word variables to be read in for each measurement. The datasheet has 5 formula in total to determine the pressure.
Also the need to handle large numbers and division by larger numbers where fractional part makes a big difference and fact that some intermediate values can be positive or negative.

All seems to be working in EXCEL with frequent use of the INT function to emulate the PICAXE BASIC integer maths. Results typically come up only slightly higher (+0.077% to +0.13%) than with the Excel floating point calcs.

Typed into the Program Editor last night so as soon as chance permits, will do some further trials with actual PICAXE chip.
 

rjconway

New Member
ANy update on your progress. It would be great to get the humidity and pressure sensors into a PICAXE. Please keep us updated When finished would be great to share some code
 

westaust55

Moderator
Last message from me was only 2 days ago.
Work has been very busy with working back thus slowing progress.
At a birthday party (not mine :) ) this evening so no progress today.

Put the intended code into a PICAXE last night but a few hiccups (ie some parameters not matching what was determined in Excel) that I need to get to the bottom of. :eek:

I am also using a DS18B20 and the temp from the DS18B20 and the HP03S are within 0.1 degC.

Can post some routines once I have code running properly. It is part of an intended larger project.
 

westaust55

Moderator
While I am still sorting out the maths (as time permits), below is the code I am using to extract that calibration parameters and raw pressure and temp data from the HP03 series modules.
Do not forget that you will also need a 32kHz (PICAXE PWM or from watch crystal with logic buffer) as a clock for the pressure sensor.

Code:
; ==========================================================
;   File....... HP03 Pressure Sensor Mini_Weather_Station
;   Purpose.... PICAXE 18X project to measure the barometic pressure 
; 
;   Author..... Westaust55
;   Written.... 07-08-2009
;
;   copyright: westaust55  2009  - okay for home use but not commercial use without approval
;  =======================================================================
;
; I2C ADDRESSING
SYMBOL PRE		= %10100000		; HOPERF HP03  Pressure Sensor onboard EEPROM at address 000
SYMBOL PRS		= %11101110		; HOPERF HP03  Barometric Pressure sensor
;
; CONSTANTS
SYMBOL PreConst1	= 16			; HP01 or HP03 series module EEPROM location for 1st byte 
SYMBOL PreConst2	= 24			; HP01 or HP03 series module EEPROM location for 10th byte 
SYMBOL Preset	= 6				; PICAXE output 6 is for the HOPERF HP03 Pressure Sensor Reset
;
; VARIABLE name definitions
SYMBOL Pressur		= w4			; w4 = b9:b8 = HP03 pressure sensor
SYMBOL PLSB		= b8
SYMBOL PMSB		= b9
SYMBOL Tempera		= w5			; w5 = b11:b10 = HP03 temperature sensor
SYMBOL TLSB		= b10
SYMBOL TMSB		= b11


;
; fetch the HPxx series pressure sensor constants	
	SLAVEi2c PRE, i2cslow, i2cbyte		; set up to read the Pressure Sensor constants
	READi2c PreConst1,(b3, b2, b5, b4, b7, b6, b9, b8)	; read the first 8 values from the pressure module
	WRITE 6, b2, b3, b4, b5, b6, b7, b8, b9	; save the pressure constants in PICAXE EEPROM
	READi2c PreConst2,(b3, b2, b5, b4, b7, b6, b8, b9, b10, b11)  ; read the second 10 values from the pressure module
	WRITE 14, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11	; save the pressure constants in PICAXE EEPROM

;
; perform one read of the HP03 pressure sensor module
	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 MSB and LSB = Pressur
      
	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 MSB and LSB = Tempera
	LOW Preset				; place the pressure sensor module into idle mode
 
Last edited:

ValueAdd

Senior Member
This will be good westy. After jgershonw1 had indicated in another thread that (s)he had some experience with the same pressure sensor recently, I PM’ed twice seeking a copy of the code produced as a starting point but received no reply.
 

westaust55

Moderator
As a part of checking to overall accuracy of the HP03 pressure sensor,
on arrival home this afternoon, found the BOM website is showing a relatively high presure at 1025.7hPa.

Fired up the HP03S and read values of
Raw Pressure =28014 and
Raw Temp = 6143

Using the Excel spreadsheet until I get the PICAXE maths completed gives
1021.83hPa and 17.16degC.

Conclusion, so far, is the temperature is within 0.1 degree of the DS18B20
and the pressure seems to be consistently around 3.2 to 3.3 hPa low.

Will keep my eye on BOM site for pressure readings further from the range 1012 to 1025 and see how the HP03 performance matches reality.
 

westaust55

Moderator
This morning, the BOM website is showing a higher presure at 1029.2hPa.

Fired up the HP03S and read values of
Raw Pressure =28104 and
Raw Temp = 6039

Using the Excel spreadsheet (with floating point maths) I get 1025.13 hPa and 16.4 degC

From the integer only maths of the PICAXE, I also calculate
1025.0 hPa.

Going back over some past raw data I collected, the PICAXE maths and Excel spreadsheet with floating point maths are fairly consistent. Seemingly both are down around 3-4hPa suggesting it is module error and calibration constants.
 
Last edited:

manuka

Senior Member
While appreciating issues with HopeRF's "quality control", I still say altitude may be a factor! As mentioned earlier, atmospheric pressure falls (when near sea level) by ~1hPa for each 10m ascent. Hence a 3hPa low deviation may be due to your local terrain altitude of ~30 metres ( ~100 feet). This is so trivial - even in near horizontal Australia- that you may not have noticed it! Those official BOM values will be adjusted to read as if at sea level, but your raw readings will not be.

By chance I'm playing right now with a stash of Jaycar weather stations (check your email!) & note the inbuilt barometric display has XXXX.xx resolution. This means a 1m ascent should cause a ~.1 hPa fall, & the last digit should respond to as little a height variation as 10m÷100 or just 100mm (a mere ~4 inches). And indeed it does,consistently changing by .04 -.06 hPa when raised & lowered to floor level from a 600mm high stool. (Temp. issues at the cooler floor may naturally influence this).

During stable local weather sensitive digital barometers make handy altimeters of course- I've heard of them even being used to determine slope when considering land drainage/micro hydro. This may seem dated in a GPS era, but heavy forest cover (&-ah- flat GPS batteries!) make it appealing in remote undulating terrain. With no GPS on hand I recently grabbed a XXXX.x one to estimate 162 MHz AIS antenna placement height when calculating distance to the horizon. Even with lower resolution, the ~80m ASL location saw a ~8 hPa display fall.

Stan. (in more vertical NZ)
 
Last edited:
Top