Hello Blynk community, I want to integrate an Anemometer/Wind Speed Sensor into my Blynk project, but I have the Following Problem.
My Anemometer uses this Code to work:
const int RecordTime = 3; //Define Measuring Time (Seconds)
const int SensorPin = 3; //Define Interrupt Pin (2 or 3 @ Arduino Uno)
int InterruptCounter;
float WindSpeed;
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++;
}
But i obviously can’t use the Delay function in Blynk, so I tried solving it this way:
const int RecordTime = 3; //Define Measuring Time (Seconds)
const int SensorPin = 3; //Define Interrupt Pin (2 or 3 @ Arduino Uno)
int InterruptCounter;
float WindSpeed;
void Wind() {
InterruptCounter = 0;
attachInterrupt(digitalPinToInterrupt(Pwind), countup, RISING);
timer.setTimeout((1000 * RecordTime), Wind2);
}
void Wind2() {
detachInterrupt(digitalPinToInterrupt(Pwind));
Wspeed = (float)InterruptCounter / (float)RecordTime * 2.4;
}
void countup() {
InterruptCounter++;
}
But as I found out that doesn’t work, because the attachInterrupt apparently needs to be interrupted for a set time and I haven’t been able to figure out how I can do that with the Blynk Timer.
Your help would be greatly apprechiated.