I have a pressure plug working on a JeeNode, transmitting atmospheric pressure to the receiving JN connected to the computer. I am using this code:
void loop() {
//Serial.print("\n A;
// switch to idle mode while waiting for the next event
lowPower(SLEEPMODEIDLE);
// keep the easy tranmission mechanism going
if (radioIsOn && rf12easyPoll() == 0) {
rf12sleep(0); // turn the radio off
radioIsOn = 0;
}
// if we will wait for quite some time, go into total power down mode
if (!radioIsOn){
//Serial.print("\n B;
loseSomeTime(readoutTimer.remaining());
}
//Serial.print("\n AA;
if (readoutTimer.poll(1000)) {
//Serial.print("\n C;
long tempF;
float presHg;
uint16t traw = psensor.measure(BMP085::TEMP);
uint16t praw = psensor.measure(BMP085::PRES);
// omit following code to avoid linking in some complex calculation code
int16t temp;
int32t pres;
psensor.calculate(temp, pres);
// Serial.print (pres); //for testing
tempF=(((temp.9)/5.0)+32.0); //convert Celcius to Fahrenheit
//long value= pres;
//rf12easySend(&value, sizeof value);
presHg=(pres0.00029529983071); //convert pascals to in of Hg
//Serial.println (presHg); //for testing
presHg=(presHg+.625)10000; //elevation correction +resolution adjusdment
//Serial.print("\n D;
long value= presHg;
char sending = rf12easySend(&value, sizeof value);
// force a "sign of life" packet out every 60 seconds
if (aliveTimer.poll(60000)){
//Serial.print("\n E;
sending = rf12easySend(0, 0); // always returns 1
}
if (sending) {
// make sure the radio is on again
//Serial.print("\n F;
if (!radioIsOn)
rf12sleep(-1); // turn the radio back on
radioIsOn = 1;
}
//Serial.print("\n G;
}
//Serial.print("\n H;
}
/pre>
The Serial prints are for debugging. The pressure changes in the fourth and fifth decimal place and therefore the data is transmitted almost constantly. How can I average the data over some period to minimize the transmissions. I need two decimal place accuracy.This is would the receiving software gets.
>May 3, 2010 3:50:39 PM 29.8407 Hg
> May 3, 2010 3:50:40 PM
> OK 33 176 141 4 0
> node id: 1
>May 3, 2010 3:50:40 PM 29.8416 Hg
> May 3, 2010 3:50:41 PM
> OK 33 167 141 4 0
>node id: 1
>May 3, 2010 3:50:41 PM 29.8407 Hg
>May 3, 2010 3:50:42 PM
>OK 33 159 141 4 0
>node id: 1
>May 3, 2010 3:50:42 PM 29.8399 Hg
You can see that If it only changes for the last two digits Any suggestions? Thanks for your help.
