Maruti Muthu

Photo by Markus Winkler on Unsplash

Reliable Readings from Analog Sensors using Javascript!

While integrating an analog sensor with a microcontroller, it is very important to filter the signal to improve the SNR. On the hardware end, this can be done by using high pass or low pass or band pass filter. The filtered signal from the hardware filter is converted to digital value by the ADC. We then digitally filter this value to get a reliable reading. Tested on ADS1115 and Raspberry Pi.

⭐️ Implementation

  • Set sample size, sampling interval and outliers to be ignored
  • Collect ADC Samples in an array
  • Remove Outliers
  • Calculate the average

Note: Inject actual analog sensor reading in place of “volts” in the code.