Go Down

Topic: i2c Pressure Sensor (Read 21732 times) previous topic - next topic


The HP03 was so many projects ago I can't remember the pin assignments but suspect that I may have changed from generating the clock within the library using that analog pin to using FrequencyTimer2 which has a hard coded output pin.

Unfortunately, I am travelling for the next week or so and won't be able to check my notes until I get back.  There may also be some clues in the posts earlier in the thread.


No problem. The following line pretty much describes it:
pinMode(11,OUTPUT);  // frequencyTimer2 is hard coded to output on this pin

Just to be sure, I've checked the board with oscilloscope and I confirmed the signal is on pin 11. Resoldered MCLK wire and now I am getting some data back from the sensor.

I wanted to verify the coefficient values, so I uncommented #define PRINT_CALIBRATION_DATA and tried to compile the HP03 library. I've got a bunch of errors about missing references to printCalibrationData().

After some head scratching I moved the definition line before #include "HP03.h" line. This removed some of the errors.

I also replaced

void HPO3class::printCalibrationData();
void printCalibrationData();

in the HP03.h file.

That helped and the errors are now reduced to the following:

HP03.cpp: In member function 'void HP03class::printCalibrationData()':
HP03.cpp:174: error: 'Serial' was not declared in this scope
HP03.cpp:177: error: 'DEC' was not declared in this scope

Any idea how to add a reference to Serial here?



if you include HardwareSerial.h you will get the definitions for Serial and DEC.


Included the reference and the library compiles OK. However, no calibration information is sent to the serial port. Not a big deal, since I am getting some good data back from the sensor - 992 hPa, and 175m altitude, which seems about right . I can move forward with my project now. Thank you again for your help.


You must remove the initial comment from the following line in HP03.cpp to print the calibration data:
// #define PRINT_CALIBRATION_DATA  //uncomment this to print low level data for debug purposes

Anyway, good to hear you have it working. Why not post the changes needed for the HP02 version for others that want to use this module


Uncommenting that line is the first thing I did, as posted already. Still, no data is sent to the port.

Regarding my HP02 sensor, it turned out it is closer to this spec: http://www.picbasic.org/forum/attachment.php?attachmentid=2040&d=1188053824
which is different from the spreadsheet I was initially working with: http://www.futurlec.com/HP02D.shtml

This is very confusing, since both documents claim to be version 1.0, yet they contain different data.

Reverting back to the original code published here gives me good results with my HP02.


Jun 18, 2009, 08:51 am Last Edit: Jun 18, 2009, 09:38 am by nikivan Reason: 1
mem, do you know if it is possible to speed up the readings from the sensor? Right now it takes 95mS to complete a sensor reading. This gives me approximately 10 readings per second, which might not be enough in my application. Any thoughts?


hi, i need help.
i'm using the HP03D , compile and works ok. But the readings are not correct, i dont know the correct altitude o pressure on my city, but when start the reading, temperature stars on 29.xx and few minutes later is 36.xx, however the real temperature is about 22 degrees. How calibrate the sensor or what i need to do. Thanks.  Greetings from puebla, Mexico.


do you know if it is possible to speed up the readings from the sensor

The I2C works at 100kHz, I believe it is possible to hack the library and get it to run at 400kHz. There was a post on this a few months back.


Nikivan, the spec sheet says the conversion time is 35ms and you need some time for all those floating point calculations. Its just a guess, but I would be surprised if  you could more than double the conversion rate, no matter how fast the i2c clock rate.

What is your application and how fast do you need it?

ricarDOGS, not sure what to suggest, can you post a picture of your wiring.


mem, my application is an altitude hold function for RC helicopter. So far I have the Arduino generate audio signal which indicates when the helicopter ascends, descends, or it hovers at fixed altitude. My next step is to have the board read a receiver channel (or several channels) and generate a servo impulse. This presents some challenges since the Timer 2 is already taken and I am working at the hardware limits here. Now that you mention the 35mS conversion time, I think 50mS is probably the best time I would ever achieve (after some optimization of the calculations code). This might be OK for my needs.

@ricarDOGS. I also noticed my temperature readings are a little bit high, but not as extreme as yours. Your problem could be as simple as defective sensor.


nikivan, looks like a fun project, I would like to see more. Why not start a thread in the exhibition area with more info and updates from time to time. I am sure others would also be interested in following progress.

I doubt the HP03 sensor has an output that can be relied on to indicate the distance a heli would move vertically in less than a tenth of a second. Bear in mind that the sensor output is not absolutely stable, mine fluctuated by at least a few feet when sitting on a desk (I can't remember the exact figure, it could have been higher) . If you are primarily looking for tight control of altitude you may want to consider adding an accelerometer through a Kalman filter to drive your altitude control ( I presume you are using a variable pitch head, I would think fixed pitch would not be responsive enough)

If timer2 is used for the 32khz signal, perhaps replace that with an external signal source (a 555 timer may be good enough - plenty of circuits can be found using google)


i use the files HP03.pde, HP03.h and HP03.ccp. I removed the lines indicates in Post #6,#10,#13. On arduino Duemilanove conected :

MCLK-Pin 11
XCLR-Analog 3
SDA.Analog 4
SCL-Analog 5

4,7 uF between 3.3V and GND
10Kohm between 3.3V and SDA

it´s  Right??


The HP03 is not rated for 5 volt operation. I use FET level translators on the I2C pins and simple resistor voltage dividers on the sensor inputs (2.2k and 3.6k resistors).

I posted a diagram the FET level translator here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225292345/6#6

I never got around to documenting the wiring but FWIW, here is a picture of the mini shield I made to test the sensor


Ok, thanks. It´s possible that i get damaged the sensor?

Go Up