'ESP32 | Arduino | to many signals from anemometer
I got this weather station and I am trying to get the data of the station to a website with this ESP32 as an school project. But the weather station isn't original as it is on the hyperlink, it got modified by an former student. So the cable coming from the anemometer and the wind direction indicator got cut of, so the four cables inside (GND, 3.3V, wind speed data, wind direction data) could fit in the ESP32. First I am trying to get the anemometer running. I got the signal but there are obviously too many interrupts and even if the anemometer is just laying in an certain position it counts as an interrupt.
const int RecordTime = 3; //Define Measuring Time (Seconds)
const int SensorPin = 36; //Define Interrupt Pin (2 or 3 @ Arduino Uno)
int InterruptCounter;
float WindSpeed;
void setup()
{
Serial.begin(9600);
pinMode(SensorPin, INPUT);
}
void loop() {
meassure();
Serial.println("------------------------");
Serial.print("Wind Speed: ");
Serial.print(WindSpeed); //Speed in km/h
Serial.print(" km/h - ");
Serial.print(WindSpeed / 3.6); //Speed in m/s
Serial.println(" m/s");
Serial.print("Interrupts: ");
Serial.println(InterruptCounter);
}
void meassure() {
InterruptCounter = 0;
attachInterrupt(digitalPinToInterrupt(SensorPin), countup, RISING);
delay(1000 * RecordTime);
detachInterrupt(digitalPinToInterrupt(SensorPin));
WindSpeed = (float)InterruptCounter / (float)RecordTime * 2.4;
}
void countup() {
InterruptCounter++;
}
RISING in attachInterrupt(digitalPinToInterrupt(SensorPin), countup, RISING); should´ve solve this should´nt it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


