×

Please see all COVID-19 updates here as some shipments may be delayed due to CDC safety and staffing guidelines. If you have an order or shipping question please refer to our Customer Support page. For technical questions please check out our Forums. Thank you for your continued support.

Member #1082551

Member Since: July 31, 2017

Country: United States

  • Anyone have a problem using this type of sensor and getting a lot of noise or spikes in the output signal? I tried using an electrolytic capacitor to help mitigate the noise but it keeps showing spikes in output.

    I tried a filter, but the noise spikes are there and I need a consistent and steady output value. I read in a blog that when using arduino if you are plugged into a computer there may be ambient noise from the PC itself through the USB cable.

    here is the code I have.

    #include <Filters.h>
    
    const int output = 6;
    const int input = 0;
    
    const long referenceMv = 5000;
    
    
    float windowLength = 1;     // how long to average the signal, for statistist
    
    
    
    void setup() {
    
    }
    void loop() {
      // filters out changes faster that 5 Hz.
    float filterFrequency = 50.0;  
    
    // create a one pole (RC) lowpass filter
    FilterOnePole lowpassFilter( LOWPASS, filterFrequency );   
    RunningStatistics lowpassFilterStats;                    // create running statistics to smooth these values
    lowpassFilterStats.setWindowSecs( windowLength );
    
    while( true ) {
    
      lowpassFilter.input( analogRead(input) );
      lowpassFilterStats.input(analogRead(input));
      // do something else
      // put your setup code here, to run once:
      Serial.begin(9600);
      pinMode(output, OUTPUT);
      // put your main code here, to run repeatedly:
      //int val = lowpassFilter.output();
      int val = lowpassFilterStats.mean();
      int mV = (val * referenceMv) / 1023;
      int percent;
      percent = map(val,0,1023,0,10000);
      Serial.print(mV);
      Serial.print(",");
      Serial.println(percent);
      analogWrite(output, val);
      delay(10);
     }
    }
    

No public wish lists :(