Hi, I'm trying to create an anemometer with Arduino Nano and Optocoupler Module LM393. I need to write on the display wind speed in km / h. I used a formula 2píR RPM * * (60/100), but it says it only multiples of 1.13.
You advise me please? I need to get out of this rotation speed in km / h.
Thank you
Ivica
CODE:
// Compute the RPM of a simple DC Motor using a photomicrosensor(PMS)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define PMS_PIN A0 // Pin for signal from Photomicrosensor
#define LED_PIN 13 //Using Arduino's Internal LED; just as an indicator
boolean counted=false;
int t1=0,t2=0;
int hits=0;
int rps=0;
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
void setup(){
pinMode(PMS_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH); // NOTE: You can turn the backlight off by setting it to LOW instead of HIGH
lcd.begin(16, 2);
lcd.clear();
}
void loop(){
t2 = millis();
if(t2 >= (t1 + 1000)){
rps = hits;
hits = 0;
t1=t2;
rps = (rps*60);
lcd.clear();
lcd.print("Vitr: ");
lcd.print(0.3142*rps*0.06);
lcd.print(" km/h");
}
if(digitalRead(PMS_PIN) == HIGH){
if(!counted){
counted = true;
hits++;
}
} else {
counted = false;
}
digitalWrite(LED_PIN, digitalRead(PMS_PIN));
}
What is the problem ?
Is it the mathematics of converting the rotational speed of the anemometer to a wind speed. If so, you have to say what the lengths of the anemometer arms are.
Apart from that, does it otherwise look ok. For example, when the wind speed increases, does the value in the display increase etc.?
Yes, it increases. I modified the code a bit and it seems much better, I just wanted to show it to 2 decimal places.
You can peek at it, please?
// Compute the RPM of a simple DC Motor using a photomicrosensor(PMS)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define PMS_PIN A0 // Pin for signal from Photomicrosensor
#define LED_PIN 13 //Using Arduino's Internal LED; just as an indicator
const float pi = 3.14159265;
boolean counted=false;
int t1=0,t2=0;
int hits=0;
int rps=0;
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
void setup(){
pinMode(PMS_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH); // NOTE: You can turn the backlight off by setting it to LOW instead of HIGH
lcd.begin(16, 2);
lcd.clear();
}
void loop(){
t2 = millis();
if(t2 >= (t1 + 1000)){
rps = hits;
hits = 0;
t1=t2;
int rpm;
int speedwind;
rpm = (rps*60);
lcd.clear();
lcd.print("Vitr: ");
speedwind = ((2 * pi * 100.00 * rpm)/60.00) / 1000.00;
//lcd.print(0.3142*rps*0.06);
lcd.print(speedwind);
lcd.print(" km/h");
}
if(digitalRead(PMS_PIN) == HIGH){
if(!counted){
counted = true;
hits++;
}
} else {
counted = false;
}
digitalWrite(LED_PIN, digitalRead(PMS_PIN));
}
In the pursuit of accuracy, the calculation will always be less than the actual wind speed. The wind speed needed to begin and continue rotation needs to be added to the equation. At the conclusion of the calculation, if the wind speed is exactly equal to the added wind speed, the effective wind speed can be assumed to be zero.