2018年8月11日 星期六

DIY Arduino Wind Speed Meter Anemometer Project

DIY Arduino Wind Speed Meter Anemometer Project

Arduino Wind Speed Meter Anemometer
If you are interested in creating a DIY Arduino wind speed meter or anemometer to monitor the wind strength in your location, you might be interested in this quick tutorial I have put together to create a very basic Arduino wind speed meter, that my family use on a daily basis to capture wind meter readings in mph and record the fastest speed since the last reset.
Having recently moved to a coastal location the winds now play a larger role in our everyday life than they did when we lived more inland and it wasn’t long after moving in that we all wondered how strong the winds actually were that were battering our house during the recent winter storms.

DIY Arduino Wind Speed Meter – Research

A quick bit of research online provided a wealth of ready-made weather stations you can purchase ranging from £40 or $50 up to and above $500. Although they provide a quick and easy way to start monitoring wind speed, most of the installations monitored other variables such as rainfall, which at the moment we are not interested in. They also recorded the wind speed at quite long intervals which and nearly all didn’t provide any way of tinkering or modifying the data output in any way, only viewing it on the provided screen or purchasing additional hardware to explore the data to a computer. So I decided to create a simple DIY Arduino wind speed monitor that we could tweak over time and eventually upgrade to a Raspberry Pi and send the data to a website wirelessly.
Arduino Wind Speed Meter Anemometer
The first stage of this project however was to create the basic DIY Arduino wind speed monitor to check that the parts functioned as required and write the code. A quick look online revealed that a number of wind speed meters or anemometers were available to purchase, ranging in price from just a few dollars up to over $200. I initially opted for the budget end of the scale and purchased a Maplin Anemometer (pictured above) which is sold as a replacement part for the Maplin weather station in the UK and is available to purchase price at around £3.

DIY Arduino Wind Speed Meter – Anemometer

After receipt of the Maplin Anemometer it soon became obvious that you get what you pay for, and the quality of the anemometer would not have lasted long in the conditions in our coastal location. Finally after some more research I opted for a much more robust anemometer from the Adafruit website (product ref: 1733 pictured below) which cost around $45 or £39 and provides a rugged wind speed meter anemometer that has been designed for outside use and easily allows you to measure wind speed using a wide variety of different mini PCs and micro-controllers.
DIY Arduino Wind Speed Meter Anemometer
As you can see from the image above the Adafruit anemometer is supplied with a length of 3 core cable and three connections. A black wire to power and signal ground, a brown wire for power which can be anything from 7-24v DC depending on your needs and availability, and a third blue wire that provides measurements via analog voltage. The Adafruit anemometer is capable of measuring wind speeds up to 70 m/s or 156mph which should be adequate for our location and if the speeds ever get that high will probably blow our house down before the anemometer breaks.
DIY Arduino Wind Speed Meter Anemometer Project
For the micro-controller part of the project I used an old Arduino Uno development board that had been collecting dust in a drawer and combined it with a £2.50 16×2 LCD screen I had previously purchased via eBay for a readout.
DIY Arduino Anemometer
The next stage was to create the Arduino code which I created by modifying code already available from the Hackerscapes website to record mph rather than m/s and added extra code to support the 16×2 LCD display. After the initial setup was wired together and the family were staring at the screen for some time to catch a glimpse at the fastest wind speed. I made another alteration to the code that now recorded the highest wind speed since the last reset of the Arduino Uno, and positioned this in the lower right hand side of the LCD as the max wind speed, while still showing the real time wind speed on the left of the screen.
I mounted the DIY anemometer on one of our fences away from any buildings to try and provide it with enough space to be able to get a clean wind speed reading and connected it to the Arduino Uno which was positioned inside the house using a 15 m length of cable. The Arduino Uno is powered by a mains 12v adapter and now provides us and visitors with hours of fun trying to guess how fast the speed will be during the night or when any storms hit us during the day.

DIY Arduino Wind Speed Meter Code

/*
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;
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);
}
I have embedded the code above which you are free to use and please if you do see any more tweaks that can be made please let me know in the comments below. The Arduino wind speed monitor has been created to provide a rough estimate of the wind speed and should not be used for any important meteorological calculations.

DIY Arduino Wind Speed Meter – Components :

– Adafruit Anemometer (product ref: 1733) – £39 or $44
– Arduino Uno or similar such as the new Arduino 101 or Genuino – £28 or $40 (cheaper clones are available)
– Arduino 16×2 LCD screen with keypad £2.50 or $3.60
– 15m of 3 core cable – £10 or $14
– 12v Mains Power Supply £5 – $7
– Arduino IDE software loaded on to a PC or Mac – Free
In the next stage of the project I hope to develop the system even further during my spare time and upgrade the Arduino Uno to a Raspberry Pi, which will then be capable of transmitting the wind speed data to a website for logging. As soon as this is completed that stage of the build I will keep you updated and add a link to it here once complete. Below is a list of components you will require to complete this easy to build Arduino wind speed meter. As questions about the build please leave them in the comments below and I will do my best to answer them.

沒有留言:

張貼留言

2024_113_RFID 作業2 ESP32 Arduino程式

2024_113_RFID 作業2 ESP32 Arduino程式  const char broker[] = "test.mosquitto.org"; //const char broker[] = "broker.mqtt-dashboard...