ARDUINO UNO ANEMOMETER PROBLEM!!

Hi all,
I have a problem with the wind speed sensor “SEN0170”.
1)The wind speed value that i get all the time is '30" in m/s .
2)If i spin faster the anemometer or slower doesnt change.
3)If i dont spin anyway the anemometer and is not in motion, still show me the value of “30”.Nothing changes.
4)I have connect it to the arduino uno with external DC power supply 12v.

What i do wrong? The connection diagram is below in Attach.

The sketch code is:
//Written by Jonathan Pereira on 21st November 2015 public domain
/*
Hardware Connections (Breakoutboard to Intel Edison):
-Pin1(Brown):VCC/5V
-Pin2(Black):Ground
-Pin3(Blue)(Signal):Analog Pin A0
*/

int adawind= A0;
void setup()
{
pinMode(A0,INPUT);
}

void loop()
{
adaanemometer();
float windspeed;

String stringMsg = “Wind Speed:”;
char wind[10];
dtostrf(windspeed,1,0,wind);
stringMsg += wind;
stringMsg += “m”;
}

// the loop routine runs over and over again forever:
void adaanemometer() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
float windspeed =map(voltage,0.4,2.0,0,32.4);
Serial.println(windspeed);
}

You have defined this twice in the program:

float windspeed;

You compute one windspeed and then display the other.

Paul

Because you keep putting float in front so defining new variables with different scope, the 'windspeed' that is calculated in adaanemometer() is not the same 'windspeed' that you are using in loop().

I think they should be the same variable so try defining it as global i.e. put 'float windspeed;' immediately below 'int adawind= A0;' then take the version out of loop() and remove the 'float' from the line in adaanemometer().

Also map() uses integer arithmetic so you using it with floats may not produce what you are expecting.

Steve

Paul_KD7HB:
You have defined this twice in the program:

float windspeed;

You compute one windspeed and then display the other.

Paul

I fixed the code that you mentioned but doesnt fix my problem.
I have tried and different anemometer sketches and gave me the same results!
Thanks for your reply!

Hi, I'm not familiar with the SEN 0170, but a quick look tells me you are connected to the current output (blue) not the voltage output (yellow). At least that is what the dfrobot web page says.

They also have some sample code here: Wind_Speed_Sensor_Voltage_Type_0-5V__SKU_SEN0170-DFRobot

slipstick:
Because you keep putting float in front so defining new variables with different scope, the ‘windspeed’ that is calculated in adaanemometer() is not the same ‘windspeed’ that you are using in loop().

I think they should be the same variable so try defining it as global i.e. put ‘float windspeed;’ immediately below ‘int adawind= A0;’ then take the version out of loop() and remove the ‘float’ from the line in adaanemometer().

Also map() uses integer arithmetic so you using it with floats may not produce what you are expecting.

Steve

I done what you mentioned to me but with no success!
I have tried and another anemometer sketch code and gave the same output!
If you have any free time check the 'another" sketch code and the screenshot from the output that i have attached!
The values of serial monitor is when the anemometer sensor doesnt spin or if i spin the sensor the output values still the same, doesnt change!
Thanks in advance!

anemometro.ino (2.18 KB)

JohnRob:
Hi, I'm not familiar with the SEN 0170, but a quick look tells me you are connected to the current output (blue) not the voltage output (yellow). At least that is what the dfrobot web page says.

They also have some sample code here: Wind_Speed_Sensor_Voltage_Type_0-5V__SKU_SEN0170-DFRobot

Hi JohnRob,
My anemometer doesnt have yellow cable.
It has 1) BROWN wire for VIN pin. 2)BLACK wire for GND. 3)Blue wire for A0 pin.
I also tried the code from the site that you send me.The speed if i spin the anemometer or not doesnt change!Remains at 30 m/s every second!
I cant find any solution!
If you have time check the sketch code and the screenshot that i replied to STEVE.
Thanks for your help!

Your diagram shows the output connected to pin A1, but your program is looking at A0.

Paul

Paul_KD7HB:
Your diagram shows the output connected to pin A1, but your program is looking at A0.

Paul

I already change to A0.Sorry that i didnt mention it!
The problem is i think that the Black Wire (Ground) of the anemometer must ground with the 9V power supply first and then into the Ardunio Uno.But i cant find any diagram on google to make the circuit!
Thanks for your reply Paul i appreciate that :slight_smile: