I connected turbidity sensor TSD-10 to Arduino-Uno via 16bit ADC ADS1115. The output sensor data is slightly unstable, hence I wanted to smoothen the data with the help of "Running average". I am not able to figure out why the running average doesn't seem to work. the ADS1115 is connected to Arduino-Uno via SDA and SLC. Below is the code. I will be thankful for help.
#include <Wire.h> #include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1115(0x48);
const int numReadings = 10;
int readings;
int readIndex = 0;
int total = 0;
int average = 0;
int inputPin = SDA;
Not that it's part of your issue, but why set readings to 0 ten times? It's already set to 0 by "int readings;". It's not hurting anything. Just seems odd.