In my little weather station I collect temperature, humidity, MQ-2 smoke sensor, and wind speed readings for display on a 20x4 LCD display, every 500 ms.
The Anemometer readings jump up and down by quite a bit.
Initialization of variables before Setup is like so:
// Wind Speed Anemometer
const int sensorPin = A3;
int sensorValue = 0;
float sensorVoltage = 0;
float windSpeed = 0;
float voltageConversionConstant = 0.004887586; // (5/1024)
float voltageMin = .33; // 0.4 in the documentation
float windSpeedMin = 0;
float voltageMax = 1.5; // 2.0 in the documentation
float windSpeedMax = 32;
// 20 x 4 LCD Display
#include <LiquidCrystal_I2C.h>
// set the LCD address to 0x3F for a 20 chars 4 line display\/ Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
Then in Setup I initialize the LCD and flash the backlight.
lcd.begin(20,4);
lcd.clear();
for(int i = 0; i< 3; i++) {
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
In Loop, I paint the initial screen then take readings and display them
void loop() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Weather");
...etc... to display time and show temp and humidity
// Wind Speed
sensorValue = analogRead(sensorPin);
sensorVoltage = sensorValue * voltageConversionConstant;
if (sensorVoltage <= voltageMin) windSpeed = 0;
else windSpeed = ((sensorVoltage-voltageMin)*windSpeedMax /(voltageMax-voltageMin)*2.23694);
lcd.setCursor(0,3);
lcd.print(windSpeed);
lcd.print(" MPH ");
...etc... to display smoke detection...
delay (500);
} // end loop
So the question is: How can I slow down the Wind Speed fluctuations? It jumps up and down quite widely.