Weather MeterKit connected to Weather Shield register faulthy data

Hello,

I’m using a weather Meter Kit (https://www.sparkfun.com/products/15901) connected to weather shield(https://www.sparkfun.com/products/13956) that is stacked on a Sparkfun Redboard Photon (https://www.sparkfun.com/products/13321) . All goes well when I’m supplying the board from an USB laptop port , but when I’m using SunnyBuddy (https://www.sparkfun.com/products/12885) with a set of acumulators in paralel that together have 6000 mAh and 3.7V and a solar panel of 3.5 W I’m seeing faulthy data from rain gauge and anemometer.

From 0.0 mm 0 kph to 160.93 mm, Avg:22kph, Gust:24kph , sometime the anemometer start to work properly but still rain gauge receives this high value when I’m using an external supply(DC jack ).

//===========================================================================
// Rain Guage
//===========================================================================
int RainPin = D2;
volatile unsigned int rainEventCount;
unsigned int lastRainEvent;
float RainScaleMillimetres = 0.2794; // Each pulse is .2794 millimetres of rain

void initializeRainGauge() {
  pinMode(RainPin, INPUT_PULLUP);
  rainEventCount = 0;
  lastRainEvent = 0;
  attachInterrupt(RainPin, handleRainEvent, FALLING);
  return;
  }
  
void handleRainEvent() {
    // Count rain gauge bucket tips as they occur
    // Activated by the magnet and reed switch in the rain gauge, attached to input D2
    unsigned int timeRainEvent = millis(); // grab current time
    
    // ignore switch-bounce glitches less than 10mS after initial edge
    if(timeRainEvent - lastRainEvent < 10) {
      return;
    }
    
    rainEventCount++; //Increase this minute's amount of rain
    lastRainEvent = timeRainEvent; // set up for next event
}

float getAndResetRainMillimetres()
{
    float result = RainScaleMillimetres * float(rainEventCount);
    rainEventCount = 0;
    return result;
}

//===========================================================================
// Wind Speed (Anemometer)
//===========================================================================

// The Anemometer generates a frequency relative to the windspeed.  1Hz: 1.492KPH, 2Hz: 2.984KPH, etc.
// We measure the average period (elaspsed time between pulses), and calculate the average windspeed since the last recording.

int AnemometerPin = D3;
float AnemometerScaleKPH = 2.401; // Windspeed if we got a pulse every second (i.e. 1Hz)
volatile unsigned int AnemoneterPeriodTotal = 0;
volatile unsigned int AnemoneterPeriodReadingCount = 0;
volatile unsigned int GustPeriod = UINT_MAX;
unsigned int lastAnemoneterEvent = 0;

void initializeAnemometer() {
  pinMode(AnemometerPin, INPUT_PULLUP);
  AnemoneterPeriodTotal = 0;
  AnemoneterPeriodReadingCount = 0;
  GustPeriod = UINT_MAX;  //  The shortest period (and therefore fastest gust) observed
  lastAnemoneterEvent = 0;
  attachInterrupt(AnemometerPin, handleAnemometerEvent, FALLING);
  return;
  }
  
void handleAnemometerEvent() {
    // Activated by the magnet in the anemometer (2 ticks per rotation), attached to input D3
     unsigned int timeAnemometerEvent = millis(); // grab current time
     
    //If there's never been an event before (first time through), then just capture it
    if(lastAnemoneterEvent != 0) {
        // Calculate time since last event
        unsigned int period = timeAnemometerEvent - lastAnemoneterEvent;
        // ignore switch-bounce glitches less than 10mS after initial edge (which implies a max windspeed of 239kph)
        if(period < 10) {
          return;
        }
        if(period < GustPeriod) {
            // If the period is the shortest (and therefore fastest windspeed) seen, capture it
            GustPeriod = period;
        }
        AnemoneterPeriodTotal += period;
        AnemoneterPeriodReadingCount++;
    }
    
    lastAnemoneterEvent = timeAnemometerEvent; // set up for next event
}

float getAndResetAnemometerKPH(float * gustKPH)
{
    if(AnemoneterPeriodReadingCount == 0)
    {
        *gustKPH = 0.0;
        return 0;
    }
    // Nonintuitive math:  We've collected the sum of the observed periods between pulses, and the number of observations.
    // Now, we calculate the average period (sum / number of readings), take the inverse and muliple by 1000 to give frequency, and then mulitply by our scale to get KPH.
    // The math below is transformed to maximize accuracy by doing all muliplications BEFORE dividing.
    float result = AnemometerScaleKPH * 1000.0 * float(AnemoneterPeriodReadingCount) / float(AnemoneterPeriodTotal);
    AnemoneterPeriodTotal = 0;
    AnemoneterPeriodReadingCount = 0;
    *gustKPH = AnemometerScaleKPH  * 1000.0 / float(GustPeriod);
    GustPeriod = UINT_MAX;
    return result;
}

This is just a guess, but maybe try altering this portion:

// ignore switch-bounce glitches less than 10mS after initial edge (which implies a max windspeed of 239kph)

if(period < 10) {

return;

by increasing the ms allowed from 10 to maybe 25? (wondering the SunnyBuddy and parallel power situation is creating larger or longer bounces?)

It doesn’t change anything , thanks for the proposition .

I have the same problem, I connect everything and it works fine, but the rain gauge sometimes shows values ​​like 16 interruptions without any intervention. I changed all the circuits and checked the filter, but still got noise. I have also relocated it and checked to see if the rain gauge sounds but there is nothing physical that seems to affect it.