Go Down

Topic: Adafruit Anemometer | Readings are wrong (Read 261 times) previous topic - next topic

Dichill

Feb 16, 2020, 11:20 pm Last Edit: Feb 16, 2020, 11:21 pm by Dichill
I have been working on a weather station for some time and I already have the sensors I need. When the anemometer came I looked at its datasheet and I did what it told me to do. Here is the product: https://www.adafruit.com/product/1733

Then I used this code to test the windSpeed
https://www.geeky-gadgets.com/arduino-wind-speed-meter-anemometer-project-30032016/

I tried stopping the anemometer from turning, and the windspeed is still going up. No changes of value.
Any help is appreciated.

Regards, Dichill

Railroader

Please attache the code here, using code tags. Also attache the datasheet here. I don't download files.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Dichill

#2
Feb 16, 2020, 11:43 pm Last Edit: Feb 16, 2020, 11:44 pm by Dichill
The datasheet is in chinese so I used google translator and it seems understandable
https://cdn-shop.adafruit.com/product-files/1733/C2192+datasheet.pdf
Code: [Select]

/*
Arduino Wind Speed Meter Anemometer mph - Adafruit anemometer (product ID 1733).
Modified code created March 2016 from original code created by Joe Burg 11th November 2014 at http://www.hackerscapes.com/ with help from Adafruit forum users shirad
*/

//Initialise LCD display

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int serial_in;

//Setup Variables

double x = 0;
double y = 0;
double a = 0;
double b = 0;
const int sensorPin = A1; //Defines the pin that the anemometer output is connected
const int numReadings = 10; //Defines number of reading to calculate average windspeed
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int totalWind= 0; // the running total
int averageWind = 0; // the average
int inputPin = A1;
int sensorValue = 0; //Variable stores the value direct from the analog pin
float sensorVoltage = 0; //Variable that stores the voltage (in Volts) from the anemometer being sent to the analog pin
float sensorVoltage2 = 0; //Variable that stores the voltage (in Volts) from the anemometer being sent to the analog pin
float windSpeed = 0; // Wind speed in meters per second (m/s)

float voltageConversionConstant = .004882814; //This constant maps the value provided from the analog read function, which ranges from 0 to 1023, to actual voltage, which ranges from 0V to 5V
int sensorDelay = 2000; //Delay between sensor readings, measured in milliseconds (ms)

//Anemometer Technical Variables
//The following variables correspond to the anemometer sold by Adafruit, but could be modified to fit other anemometers.

float voltageMin = .4; // Mininum output voltage from anemometer in mV.
float windSpeedMin = 0; // Wind speed in meters/sec corresponding to minimum voltage

float voltageMax = 2.0; // Maximum output voltage from anemometer in mV.
float windSpeedMax = 32; // Wind speed in meters/sec corresponding to maximum voltage

void setup()

{
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}

//Setup LCD display with welcome screen

lcd.begin(16, 2);
lcd.print("Geeky Gadgets");
lcd.setCursor(0, 1);
lcd.print("Windspeed Sensor");
delay(2500);
lcd.clear();
lcd.setCursor(0, 0);
Serial.begin(9600); //Start the serial connection

}

//Anemometer calculations

void loop()
{

sensorValue = analogRead(sensorPin); //Get a value between 0 and 1023 from the analog pin connected to the anemometer

// subtract the last reading:
totalWind = totalWind - readings[readIndex];
// read from the sensor:
readings[readIndex] = sensorValue;
// add the reading to the total:
totalWind = totalWind + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
sensorVoltage2 = sensorValue * voltageConversionConstant; //Convert sensor value to actual voltage
// if we're at the end of the array…
if (readIndex >= numReadings) {
// …wrap around to the beginning:
readIndex = 0;

// calculate the average:
averageWind = totalWind / numReadings;

sensorVoltage = averageWind * voltageConversionConstant; //Convert sensor value to actual voltage

//Convert voltage value to wind speed using range of max and min voltages and wind speed for the anemometer
if (sensorVoltage <= voltageMin) {
windSpeed = 0; //Check if voltage is below minimum value. If so, set wind speed to zero.
} else {
windSpeed = ((sensorVoltage - voltageMin) * windSpeedMax / (voltageMax - voltageMin))*2.232694; //For voltages above minimum value, use the linear relationship to calculate wind speed.
}
}

//Max wind speed calculation

x = windSpeed * 0.88;
if (x >= y) {
y = x;
} else {
y = y;
}

//Max voltage calculation

a = sensorVoltage;
if (a >= b) {
b = a;
} else {
b = b;
}

//Print voltage and windspeed to serial

Serial.print("Voltage: ");
Serial.print(sensorVoltage);
Serial.print("Average: ");
Serial.print(averageWind);
Serial.print("\t");
Serial.print("Wind speed: ");
Serial.println(windSpeed);

//Display Wind Speed results to LCD with Max wind speed

lcd.setCursor(0, 0);
lcd.print("Wind Speed=");
lcd.setCursor(11, 0);
lcd.print(windSpeed);
lcd.setCursor(0, 1);
lcd.print(b);
lcd.setCursor(5, 1);
lcd.print(readIndex);
lcd.setCursor(7, 1);
lcd.print("Max=");
lcd.setCursor(11, 1);
lcd.print(y);

delay(sensorDelay);
}

groundFungus

#3
Feb 16, 2020, 11:46 pm Last Edit: Feb 16, 2020, 11:46 pm by groundFungus
How is YOUR sensor powered?  How is the Arduino board powered?  What is the supply voltage to the sensor measured at the brown wire to ground?

Paul_KD7HB

Looking at you program, I see no time factor in any of the calculations that are supposed to give "wind speed". So, the program looks like a nice exercise, but cannot give a "speed" value.


Paul

groundFungus

Wind speed is a function of the voltage output of the anemometer (a DC generator?).

From the Adafruit page in the OP.
Quote
The voltage will range from 0.4V (0 m/s wind) up to 2.0V (for 32.4m/s wind speed).

Paul_KD7HB

Wind speed is a function of the voltage output of the anemometer (a DC generator?).

From the Adafruit page in the OP.
Ok. I wonder about the DC generator. They show an output voltage at 0 wind speed, so there is some process going on other than generation. My anemometer needs 1 mph wind speed to begin turning, but then can go to almost zero wind and keep turning. Looks like theirs is similar. I looked for a graph for linearity in the PDF, but there is none, so I suspect it is like mine, a reed switch operated by a magnet turned by the rotator, but they add some electronics and that is the reason for the power going to the device.

So time is already incorporated in their voltage output. I looked for, but didn't fine how quickly the machine responds to wind changes. Like my machine, it is almost linear by design.

Paul

Railroader

Such a still standing sensor has a friction to overcome in order to start. Once rotating it can rotate at really low speeds. This is the same for many different things. Getting a multi ton train rolling calls for forces but slowing down,  it does not wanr to stop....
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Dichill

Sorry for the very late reply, Im a student and I had to go to school (GMT +8) Timezone.

Answers:
The Arduino is powered by a 9volts battery or sometimes a pc usb plug which gives out 5 - 10 volts (doesn't really changes the value when I tested it out)

Yes the Wind speed is a function of the voltage output of the anemometer. Based on my research the anemometer works by calculating how much voltage it gives in every turn.

Hmm So I have to buy a new one?

Thank you for answering my questions

Regards, Dichill

TomGeorge

#9
Feb 17, 2020, 11:40 am Last Edit: Feb 17, 2020, 11:40 am by TomGeorge
Hi,
To get your code this far I'm surprised the problem has not occurred earlier.
Did you write your code in stages?
If so you must have some code that JUST reads the anemometer output and puts it on the Serial.print.

What output do you get with the anemometer held stationary?

With your existing code, if you short the analog input to gnd, what does your code indicate?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

dave-in-nj

#10
Feb 17, 2020, 01:35 pm Last Edit: Feb 17, 2020, 01:40 pm by dave-in-nj
Break down the input into every single step

Input goes hi
Pause
Input goes low
Pause

Write a simple sketch
InputA = digitaread pin

If inputA not equal to last_read
If inputA eq high
Then count++
Serialwrite count
Put your math here
}
}
 
Do other things
At the end of loop
lastread = inputA

}  // end of loop


This will only increment when there is a change

Warning  the above is NOT actual code.

Wind speed does not need to be measured constantly.   You could dedicate 30 seconds out of every 3 minutes.   In 30 seconds or less you can get a good sense of wind speed

Dichill

#11
Feb 17, 2020, 01:45 pm Last Edit: Feb 17, 2020, 01:47 pm by Dichill
Looking at the codes that was found on https://www.geeky-gadgets.com/arduino-wind-speed-meter-anemometer-project-30032016/

We have the anemometer and the same type as well, The output ill get when the anemometer is held stationary the value increases which can go to 100+ or so.

I did what you did, I put the analog input to gnd and the results were different.

I made the anemometer stop from moving, then waited around 1 min then the output of the Wind speed: is 0. Then after a couple of minutes the windspeed when to 2 - 5. I think it is working but its taking so long to update.

putting the analog pin to gnd made different results than the analog pin to a1
Data: https://imgur.com/a/UNsTmcD

dave-in-nj

IIf You work up to the simple test
The results will be instanious

Use the serial graph option 

Railroader

Could You try and use a multimeter at the Arduino input pin and check? Maybe use an oscilloskope. Something is strange but what?
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Dichill

#14
Feb 18, 2020, 11:40 am Last Edit: Feb 18, 2020, 11:41 am by Dichill
I dont have an multimeter nor oscilloskope, since I have a spare arduino board, I decided to use that board and the results are still the same.

Here is the graph plot for the anemometer. (The inputPin is connected to A1)
sometimes the line is constant then suddenly it goes up (The anemometer is moving at a low speed because Im blowing it and I sometimes use a fan.)
https://imgur.com/a/qH3KS08

Graph plot (The inputPin is connected to GND)
https://imgur.com/a/UcYAaS6

Go Up