Go Down

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


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.


Mar 14, 2010, 02:45 pm Last Edit: Mar 14, 2010, 03:23 pm by mem Reason: 1
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:
Code: [Select]
 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

 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

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


Mar 14, 2010, 07:44 pm Last Edit: Mar 14, 2010, 07:46 pm by nscadarduino Reason: 1
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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131