i2c Pressure Sensor

Have you tried measuring at significantly different altitudes? Is the variation still +-1.5 hpa or does the error increase or decrease at different altitudes.

I've had mixed results so far with the HP03. I develop using a netbook running Ubuntu Linux, and was not able to fix compiling errors using version 0018. I tried installing 0011 and 0012 but they would not run (I guess this is a limitation of the OS--I'm a Mac guy without a lot of experience with Linux).

Next I switched to Mac OSX Leopard and loaded 0012. With the adjustments to wiring.h as described earlier in this thread, I was able to get the data stream in the serial monitor. According to Google Earth I'm located at 77m but the HP03 says I'm -44m, and although Environment Canada gives the pressure at 1031, the HP03 says it's 1018.

I'm interested in the barometric pressure delta so absolutes are not necessary, but it is troubling that I can't get accuracy as close as is claimed by the datasheet.

Later on in this thread mem offers another sketch, which I loaded and tried to run with 0012 but had similar compile errors to ricarDOGS. mem suggests upgrading to 0013. Has anyone had success using this library with the most recent distribution 0018?

Has anyone had success using this library with the most recent distribution 0018?

The code posted compiles without errors on 0018, although I have only tested this on a windows machine.

What errors did you get?

I get two errors with the newer sketch. I'm running Ubuntu Linux 9.04 and Arduino release 0018 (with the revisions to Wiring.h as prescribed earlier in this thread):

/home/mbl/Desktop/arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long int)':

/home/mbl/Desktop/arduino-0018/hardware/arduino/cores/arduino/HardwareSerial.cpp:144: error: 'abs' was not declared in this scope

Thanks for the quick response... I'm anxious to get the new sketch working since, as you say, it may give more reliable data than the original one through averaging.

The changes that I made to wiring.h broke other sketches in 0018, so I restored wiring.h back to its original state.

With the original wiring.h, I receive a different set of errors:

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

/usr/lib/gcc/avr/4.3.2/../../../avr/include/stdlib.h:111: error: expected `)' before 'int'

These errors look familiar to me but I don't know my way around things well enough to make sense of this.

the errors are because there are some definitions in wiring.h that cause conflicts with the standard C libraries.

try replacing the includes in the HP03.cpp library so just the following are included:

#include <avr/pgmspace.h>
#include <WProgram.h>
#include <FrequencyTimer2.h>
#include <Wire.h>
#include "HP03.h"

The top of the file should look like this:

/*
  HP03.cpp - Arduino library support for HP03 Pressure sensor
Copyright (c)2008 Michael Margolis All right reserved

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Version:   1.0 - July14 2008
*/

// Note that this code uses the return values in Arduino version 0012 wire.c library

#include <avr/pgmspace.h>
#include <WProgram.h>
#include <FrequencyTimer2.h>
#include <Wire.h>
#include "HP03.h"

#if !defined(NULL)
#define NULL 0
#endif

The rest of the file should be unchanged

Thanks! I'll take a look later today.

Is it easy to explain why the second include does not have a "#" in front of it?

its a cut and paste errror

I have modifed the post to show the correct includes

No joy. Precisely the same errors (as I last mentioned in reply 77) remain. One thing I did not notice earlier is that in the upper sketch code portion of the window, the FrequencyTimer2 include is highlighted, suggesting that the problem is there...?

[glow]#include <FrequencyTimer2.h>[/glow]

If the problem is in FrequencyTimer2 then try moving this include:
#include <wiring.h>
from FrequencyTimer2.h to FrequencyTimer2.cpp

When I moved the include as instructed, I encountered these errors:

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.h:30: error: 'uint8_t' does not name a type

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:27: error: 'uint8_t FrequencyTimer2::enabled' is not a static member of 'class FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::setPeriod(long unsigned int)':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:96: error: 'enabled' is not a member of 'FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::enable()':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:146: error: 'enabled' is not a member of 'FrequencyTimer2'

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::disable()':

/home/mbl/sketchbook/libraries/FrequencyTimer2/FrequencyTimer2.cpp:156: error: 'enabled' is not a member of 'FrequencyTimer2'

I thought that maybe I should have not removed the include from FrequencyTimer2.h, so I put it back in, but this did not change the situation from the three errors encountered before.

try including only <WProgram.h> in FrequencyTimer2.h

Thanks mem, it works, and it's a beautiful thing! If I'm ever in London I'll buy you a beer.

good to hear you have it going.

Have fun

I ran the sketch overnight but at some point it hung, giving an indeterminate number of error statements in red. I had hoped to be able to transcribe the error but Arduino 0018 has frozen and the window is now white. I remember that it mentioned that it was a JAVA out of memory error.

I realize that this could be caused by a wide variety of factors, but we did make some changes to some of the libraries and I thought I should mention it.

Sounds like its the Serial monitor, do you have another serial program you could use to view the serial output to ensure that is ok.

I don't think anything that was changed on the arduino side would cause the Serial Monitor to freeze.

I think you're right; I restarted 0018 and left the Serial Monitor open. When I returned about 6 hours later the program had hung again.

I just installed a program called "GtkTerm"--also known as "Serial Port Terminal"--and when I started it up and selected the USB port that connects to my Duemilanove, the data streamed right in.

I'll be jettisoning the Serial Monitor anyway in favour of an LCD display (for now anyway). Thanks again.

Another question relating to Arduino's Digital Pin 11, which is used to drive the MCLK on the HP03: I want to use the liquidcrystal library, which uses pin 11 for LCD Enable.

The frequencytimer2 page in the Playground says that (if it's running on an atmega168) this library uses pin 11 and pin 3. I've looked at the frequencytimer2.cpp code to see if there is any mention of pin allocations but if it's there, it's not in clear text. Simply changing the pin in HP03.cpp from 11 to 3 doesn't seem to work.

I'm wondering if this is a case of diminished returns--should I just rig up a 32kHz 555 timer and be done with it?

The LiquidCrystal library uses ANY 6 pins. No need to work around any special pins. Just plug the LCD into 6 pins, and tell the library WHICH 6 pins you used.