Raspberry Pi Anemometer: Measuring Wind Speed!
Summary
TLDRIn this video, the creator builds a homemade anemometer to measure wind speed as part of a Raspberry Pi weather station project. Using low-cost components like ping-pong balls, an infrared sensor, and a Raspberry Pi, the video walks through the assembly, wiring, and coding process. The goal is to track wind speed alongside temperature, pressure, and humidity data. The project introduces key concepts in electronics, Python programming, and sensor integration. The creator hints at future plans to expand the weather station and explore plant cultivation monitoring using Raspberry Pi sensors.
Takeaways
- 😀 The video is a tutorial on building a homemade anemometer to measure wind speed and integrate it with a Raspberry Pi weather station.
- 🛠 The project uses a Raspberry Pi 3 B+, but any model can be used. An infrared reflectance sensor is employed to detect rotation.
- 💡 The anemometer is constructed with simple materials like ping-pong balls, a biro, M3 nuts and bolts, and a high-impact polystyrene sheet.
- 🔍 The infrared sensor works by emitting infrared light that reflects off a surface and is detected by a phototransistor.
- 📏 The anemometer's design includes a black disc with a white mark to enable the sensor to track rotation.
- 💻 The video demonstrates writing Python code to process the sensor's input and calculate the wind speed.
- 🔢 The code accounts for the anemometer's efficiency by using a factor to adjust the final wind speed calculation.
- 📈 Data including temperature, pressure, humidity, and wind speed is recorded and can be exported to a spreadsheet.
- 🌤️ The anemometer was tested both indoors with artificial wind and outdoors in a garden, showing variable results with real weather conditions.
- 🌱 The creator plans to expand the project by adding more sensors and exploring Raspberry Pi applications in plant cultivation and monitoring.
Q & A
What is the purpose of the video?
-The purpose of the video is to demonstrate how to build a low-cost homemade anemometer using a Raspberry Pi to measure wind speed and integrate it into an existing Raspberry Pi weather station project.
What is an anemometer, and how does it work in this project?
-An anemometer is a device used to measure wind speed. In this project, the anemometer is constructed using ping-pong balls, a biro, and a sensor. The wind spins the device, and the Raspberry Pi records the number of rotations using an infrared reflectance sensor to calculate wind speed.
Which Raspberry Pi model is used in the project?
-The project uses a Raspberry Pi 3 B+, but the creator mentions that any model of Raspberry Pi can be used.
What is the role of the infrared reflectance sensor in this project?
-The infrared reflectance sensor is used to measure the rotation of the anemometer. It detects the reflection of a white mark on a rotating disc attached to the anemometer, allowing the Raspberry Pi to count the number of rotations.
What materials are used to construct the anemometer?
-The materials used include ping-pong balls (cut in half to create cups), a biro (for the axle), m3 nuts and bolts, a high-impact polystyrene sheet, liquid polystyrene adhesive, and a black disc with a white mark for rotation detection.
How is wind speed calculated using the anemometer?
-Wind speed is calculated by measuring the number of rotations of the anemometer in a set period, determining the distance traveled by the wind based on the circumference of the rotating cups, and applying an anemometer factor to account for inefficiencies in the measurement process.
What coding languages and libraries are used in the project?
-The project uses Python for coding. Libraries such as the GPIO library are used to interact with the Raspberry Pi's pins, and additional libraries handle timing and sensor inputs.
What is the purpose of the 'anemometer factor' in the wind speed calculation?
-The anemometer factor is a multiplier used to account for inefficiencies in the anemometer's operation, such as friction and energy loss. The factor is estimated based on the design and efficiency of the specific anemometer.
How does the Raspberry Pi record the weather data?
-The Raspberry Pi runs Python code that collects data from the anemometer (wind speed) and a BME280 sensor (temperature, pressure, humidity). This data is recorded in a spreadsheet every 10 minutes.
What future plans does the creator have for this Raspberry Pi weather station project?
-The creator plans to add more sensors to the weather station and explore using the Raspberry Pi to control and monitor plant cultivation in a greenhouse.
Outlines
🌦️ Introduction to Raspberry Pi Weather Station Project
The video begins with an introduction to a Raspberry Pi weather station project. The presenter explains that they previously built a sensor-based station for temperature, pressure, and humidity recording, which was popular. Now, the project is expanded by adding a homemade anemometer to measure wind speed. This low-cost project focuses on learning, using an infrared sensor and Python code for wind measurement. A Raspberry Pi 3 B+ is used, although any model can work. The presenter also mentions that the BME 280 sensor from the previous project will be reused later.
🔧 Introduction to the Infrared Reflectance Sensor
The presenter introduces the main sensor, an infrared reflectance sensor bought from Adafruit, explaining its components: an infrared LED and an infrared phototransistor. The sensor detects reflective surfaces and will be used to measure wind rotation. The plan is to mount the sensor on a Raspberry Pi, with reflective surfaces being tracked to monitor rotation. The presenter also mentions using components like ping-pong balls, a biro, and polystyrene sheet to build the anemometer cups and arms, which will help measure wind speed.
⚙️ Assembling the Anemometer and Initial Tests
In this segment, the presenter constructs the anemometer by cutting ping-pong balls in half to create wind-catching cups and attaching them to arms connected to a biro axle. The parts are assembled using liquid polystyrene cement. Despite uncertainty about its success, the anemometer rotates when blown on. The next step involves adding a black disc with a white mark to the axle, allowing the sensor to track rotation and eventually calculate wind speed.
🔩 Mounting the Anemometer and Sensor Setup
The presenter showcases the completed anemometer assembly, with the white mark for the sensor attached to the axle. The setup includes a plastic housing to protect the sensor, which will be mounted on a pole to measure wind speeds at a height. Inside the housing, the sensor is temporarily secured, connected to the Raspberry Pi via a cable. The resistors and jumper leads are properly wired, and the circuit is explained in detail with a diagram of how the components interact with the GPIO pins. The presenter moves on to write and test basic Python code for detecting wind rotation.
💻 Writing and Testing Wind Speed Calculation Code
A detailed explanation of the code for measuring wind speed is provided. The code uses GPIO inputs to track sensor rotations, calculates the wind speed based on rotations per second, and adjusts for real-world inefficiencies using an anemometer factor. The presenter tests the code, first with no wind to confirm zero rotations, and then by manually spinning the anemometer. The test shows accurate wind speed readings, with further improvements made by removing test outputs. The use of a high-pressure air device for stronger wind tests yields more accurate and faster rotations.
🌬️ Refining the Project with a BME 280 Sensor
The presenter reintroduces the BME 280 sensor from the previous weather station project and integrates it with the anemometer. Combined code is written to measure temperature, pressure, humidity, and wind speed, logging the results into a spreadsheet every 10 minutes. The code structure is explained, showing how it collects sensor data and saves it in real time. A test run is performed indoors to ensure the system records accurate weather data, with plans to test the setup outdoors.
📊 Outdoor Testing and Final Data Analysis
The video concludes with the anemometer mounted outside on an eight-foot pole, connected to the Raspberry Pi indoors. Using SSH, the presenter monitors the real-time data from the setup, including temperature, pressure, humidity, and wind speed. Over the course of a day, the weather conditions vary, and the anemometer continues functioning, logging wind speeds into the spreadsheet. The gathered data reflects changing weather patterns, confirming the success of the project. The presenter expresses satisfaction with the results and hints at future Raspberry Pi projects, including plant monitoring in a greenhouse.
Mindmap
Keywords
💡Raspberry Pi
💡Anemometer
💡Infrared Reflectance Sensor
💡Python Code
💡BME 280 Sensor
💡Ping-Pong Balls
💡High-Impact Polystyrene Sheet
💡Wind Speed Calculation
💡GPIO Pins
💡Weather Station
Highlights
Introduces the Raspberry Pi weather station project using temperature, pressure, and humidity sensors.
The video focuses on building a homemade, low-cost anemometer to measure wind speed.
The key components for the anemometer include an infrared reflectance sensor, ping-pong balls, an old biro pen, and a high-impact polystyrene sheet.
An infrared LED and photo transistor are used to detect rotation by measuring reflections from a marked disc.
Explains the construction process of the anemometer, cutting ping-pong balls to create cups for capturing wind.
A black disc with a white mark is attached to the biro axle to help monitor rotation using the reflectance sensor.
The sensor is connected to a Raspberry Pi via GPIO pins, and code is written to measure wind speed based on the anemometer's rotation.
The Python code uses GPIO libraries to calculate rotations per second and wind speed in meters per second and miles per hour.
The diameter of the anemometer's cups and the inefficiency factor of the device are used to calculate wind speed accurately.
An initial test shows the code registering accurate readings based on manual rotation of the anemometer.
The video includes a demonstration of using high-pressure air to test the anemometer's response to wind speed.
The project also integrates a BME 280 sensor to measure temperature, pressure, and humidity alongside wind speed.
A combined code is written to log data every 10 minutes into a spreadsheet, capturing both wind speed and weather conditions.
The anemometer is mounted outdoors for real-time weather monitoring, and the project successfully logs hours of data.
Future plans are hinted at, including using the Raspberry Pi for controlling and monitoring plant cultivation in a greenhouse.
Transcripts
[Music]
welcome to another video from explaining
computers
earlier this year i took a temperature
pressure and humidity sensor
and used it to build a raspberry pi
weather station that recorded data
in a spreadsheet to my surprise
this turns out to be a very popular
project and so this time i'm going to
take it
further by building a homemade
anemometer
so that our raspberry pi weather station
can also record the speed of
the wind now i want to stress from the
start
that this is not a video about building
a perfect anemometer
rather what i'm doing here is a low-cost
raspberry pi project
which we're going to use to learn about
all kinds of things including
measuring rotation using an optical
sensor and
writing associated python code
so in this project we're going to be
using this
raspberry pi 3 b plus but you can use
any model of raspberry pi
computer right now the bme 280 sensor we
used in the first raspberry pi weather
station video
is connected to the pi but for now we'll
disconnect this but we'll be wiring
things up
in this project so we could add this
sensor back in again if we want to
and the sensor we're going to be using
in this video is
this one which is an infrared
reflectance sensor
which adafruit sell for 1.95
and which i purchased from primeroni for
two pounds
10. so let's open up this little bag
there we are and in here we have two
resistors whose purpose will become
obvious and we've also got the sensor
itself
and if we take a closer look at this
what we have here
is two components in one package we have
got
an infrared led and an infrared photo
transistor
and the idea is that the led will emit
infrared radiation infrared light and if
there's a reflective surface
above the sensor it will be reflected
off the reflective surface
back to the infrared photo transistor
which will trigger its gate
and we'll be able to register that on
the pi
and back in my raspberry pi gpio input
video
i wired up one of these sensors and
showed how it can be used
to turn on an led when it detected a
black mark
on a piece of white cardboard but
you may ask how are we going to use a
reflective sensor
like this to measure the speed of the
wind
well the answer is over on this cutting
mat we've got various other things we'll
be using
in this project if we start with a
couple of ping-pong balls that's always
rather exciting isn't it and we've also
got an old biro gonna have an old biro
we've got some m3 nuts and bolts we've
got a
stanley of a knife to help us out and
we've got also here some
liquid polystyrene adhesive and we're
going to be using that
with this stuff this is a two millimeter
high impact polystyrene sheet hip
sheet sometimes branded as plastic card
and i'll give you more information in
the video description on how you get
hold of
this product anyway what we're going to
do is to take the two ping-pong balls
and to cut them in half to make four
cups which will then mount on
arms sticking out from the biro
we'll then mount this contraption in
some sort of box and in theory when the
wind blows
it will spin around we'll also add a
black disc with a white mark on it
to our biro axle which should allow us
to monitor rotation
using the reflectance sensor and then
finally by taking the distance between
the cups and multiplying by
pi we should be able to work out how far
the wind has traveled
in one anameter revolution which will
allow us to write some code on the pi
to calculate the speed of the wind
so that's the theory let's now see if we
can put it
into practice
right as you can see things have now
progressed standing the knife has been
hard at work helping you make these four
little arms for
the anemometer and i've got a hole
drilled in them as well and i've got the
ping pong balls which you can see either
cut in two and these have got holes in
the top too and the principle is we're
going to use the nuts and bolts to
attach these arms
to the cups and to attach them to our
axle which is the biro
i've no idea if this is going to work so
all we can do is to put it together
and see what happens and so by the magic
of filmmaking
here we are i've now put the veins
together and it seems to have worked
pretty well i thought when i started
this that the
most difficult part of the whole project
would be holding ping-pong balls onto
the end of little arms
onto some sort of axle and that seems to
have worked
it's held together just with the liquid
cement
onto the biro as well which i think is
abs plastic so that's also been
solvent welded quite successfully using
the
the solvent i've been using to do that
and um
hopefully this will work if i just stand
it so you can see it like that
this obviously will be in a proper mount
it's it's standing on the ballpoint pen
obviously ball point which i'm hoping is
me a good axle but i'll just hold it
like that which is not ideal but if i
blow
yes we have something that rotates when
it's windy or artificially windy inside
so we can now move on i think to
building some sort of enclosure for this
where we can put the sensor under here
and we can record the rotation
of our anemometer vein
greetings here i am back again and as
you can see i've now fitted a disk
to our axle which was a easier said than
done
and on the disk there is this piece of
white plastic which came from a piece of
a
buttery spread container and this is
stuck on so that in theory
our sensor will be able to detect that
as this thing spins
around and over here i built a little
plastic card housing
and this will eventually be bolted to
the top of a long wooden
post so we can get the anomer nice and
high up
you want to measure wind speed some
distance from the ground and
inside this box as you can hopefully see
we've got our sensor which is currently
just temporarily mounted with a piece of
blu-tack putty so i can get the position
absolutely right and it's been soldered
to this six meter length of a
telephone flex which is very handy for
core cable to solder to
the sensor with its four connections so
let's take our axle and put it inside it
just goes into a little notch down there
and that down there and there was a top
piece
which drops in if i can get it in
something
like this this does bolt on but i'll
just put it on like that for now
and this thing will therefore stand up
and hopefully
yes it will rotate without any problems
at all it's a bit
uh jittery as you can see it's not the
best uh
spinning thing in the world but we can
partially compensate for this in
software as we will do a bit later in
the video
anyway for now you're probably wondering
what goes on at the end of this cable
and it's terminated in this which is a
small piece of strip board which
contains the resistors which came with
the sensor
plus an extra one i've thrown in for
good measure and it's got jumper leads
here
going out to the raspberry pi and if you
want to know exactly what's going on
here you can see the soldering there
on the back we look at this circuit
diagram we can see the sensors led is
connected to 5 volts
and ground pins on the pi via 470 ohm
current limiting
resistor and the photo transistor is
then fed
3.3 volts from the pi with its emitter
connected to
gpio pin 12 via a 1k current limiting
resistor which will protect the pin
in case of a coding error and finally
there's also a 10k pull down resistor
also wired to the gpio
pin this is all a very standard kind of
setup
and if you want to know more about pull
down resistors and current limiting
resistors and things like that
look in my raspberry pi using gpio
inputs
video anyway let's get this all
connected up
and running and here we are the
andrometer is now
connected up to a functional raspberry
pi and if we go across the pi's desktop
i'm running here the genie editor in
which initially i've written a very
simple piece
of a test code and all this does is to
import the gpio
libraries it sets pin 12 as a gpio input
using board numbering there and it runs
an infinite loop here
because while true is always true which
says if gpro input 12
is equal to one in other words you can
see white it's going to print white
else it's going to print black and this
runs inside a try finally combination so
we always clean up the gpio pins at the
end
even though we're going to crash out of
this code so
if we bring up a shot of the anemometer
and we run
this code there it is it says black
but if i rotate the thing eventually
somewhere
there we go there's there's white black
again and if i
spill it around like that it goes back
and forth between white and black
you can see the creative principle this
thing is working
so let's close that code down and over
here i've written some code which will
actually calculate
wind speed and it starts off exactly the
same way
importing the libraries also importing
the time library here
and setting up gpio pin and then there's
various variables which are defined
the first one is the anameter vane
diameter this is the distance between
the cups
in millimeters on the anemometer which
for me is 106 millimeters
obviously here enter the value here for
anything you built yourself
and then we work out the vein
circumference using a vein circumference
equals obviously vein diameter
over a thousand to move it into meters
and multiplying by pi
3.1415 is perfectly adequate in terms of
accuracy
what we're doing here we also set what's
called an anemometer factor which here
are set to
2.5 and this basically accounts for the
fact that no anenometer
is perfectly efficient there will be a
loss of energy
as wind hits the vein and turns it round
and there'll be friction
in terms of the operation of a system we
know out is a bit jittery
so all adenometers have to have a number
multiplied by that final result
to account for the practicalities of the
real world inefficiencies
this value seems to be anywhere between
about one point two five and three
depending on
different anenometers i've guessed at
2.5 here that might be a bit high but i
think it's not that unreasonable as
you'll see
for various reasons a bit later on we
then measure wind speed we start up by
printing
measuring wind speed that seemed a good
idea then we defined some variables
rotations is going to be a floating
variable there and we set it initially
to zero
and we set trigger to zero which is
going to be whether we triggered or not
our sensor then going to define a
variable called
end time which with the current time
plus 10 seconds
which basically uses time plus time
which returns the current time in
seconds
we add 10 to that and we're also going
to gather the initial state of the
sensor so sensor start is going to be
the current state of the gpio input
which could of course be seeing black or
white we don't know when this thing
starts
we've then got a loop which is actually
going to count rotations
so it's going to say whilst the current
time is less than end time it'll keep
going through and then if g player input
12 is one
and trigger is zero it'll add one to
rotations and set trigger to one so it
won't do it again
if the thing hasn't moved when we come
back next time and here it's also going
to print recorded a trigger just so we
can see
what is going on and then if gpio input
12
is zero we're going to set trigger to
zero and this thing will keep going
around adding to rotations as we go
through
and after various experimentation i
found you did a tiny little delay in
this loop to keep things stable so we've
got a time sleep
.001 of a second very small time sleep
then once the loop is finished we can
work out what's going on
but first of all we want to account for
the fact we'll have got a rotations of
one
even if the thing didn't move and it was
seen right at the start
so here we basically say if rotations is
one and sensor start was one it was
seeing white at the start
we'll put rotations back to zero to try
and get things most
accurate we then work out the actual
wind speed itself
rotations per second is going to be
floating point variable
rotations divided by 10 and wind speed
in meters a second
will be rotations per second times the
vein circumference
times the angerometer factor finally
we're going to print the results
we're going to print out rotations
rotations over 10
wind speed in meters a second and wind
speed in miles per hour
by which you simply multiply by 2.237
get it right and there's that's all
nicely formatted with this code here
and then finally as usual as you should
with gpio stuff you clean up your gpu
pins so let's bring up a shot of the
anemometer
there it is and we'll uh run the code
like this
and it's measuring wind speed and what
i'm going to do is actually nothing
to start out so i'm not going to rotate
the thing at all i'm just going to
blabber on for 10 seconds
and we will get a result at the end
there we are zero rotations
zero rotations a second obviously wind
speed is zero i just wanted to check it
gave you zero when nothing had happened
so we'll press a key on that and we'll
now run it again
and this time
i'm going to do some blowing on it it'll
record triggers and at the end of that
period of time
there we are it did 23 rotations 2.3 a
second
wind speed is 1.19 meters a second or
4.28
miles an hour which which is all very
good things seem to be
working so let's go back to the code
and i think i'm going to get rid of the
bit of prince recorded
a trigger because that's clearly just
there for testing so we'll get rid of
that
like that and we save our code file
and save and if we just go back to the
anendometer
i'm going to bring in this this is a
rather
wacky piece of equipment this is a
computing cleaning device which has a
very high pressure air output if i just
turn it on
that's a very if you can still hear me
that's a very high pressure air output
so let's go back to the code and run
the code and i'm going to use this thing
to
there we are uh we've got that was very
exciting we've got some results here 116
rotations
and it wasn't even forced at it for the
whole period of 10 seconds of course
um and we've got a wind speed of 9.66
meters a second
21.6 miles an hour if you get this
just right and run it for the whole
period of time you get about 30 on that
test and that's why i think my
anemometer factor
is about right but anyway it seems
things are working
we've successfully put together a
raspberry pi
and a monitor
right just before we do an outside test
i've added a bme 280 sensor back onto
the raspberry pi
and i've also written some combined code
which puts together what i've just shown
you for measuring wind speed
with what i showed you for measuring
temperature pressure and humidity in the
last
raspberry pi weather station video so
what this piece of code will do
is to record temperature pressure
humidity and wind speed
every 10 minutes into a spreadsheet and
i won't go through this in detail
because it does combine two things i've
already shown you
it basically imports all the libraries
we need sets up gpio
deals with the variables for measuring
wind speed deals with initializing
the bmw 280 sensor and then loads in a
workbook where we're going to be saving
our results and that has a massive loop
which both reads the temperature
pressure and humidity sensor
and takes the wind speed measurements
and then down here
prints out the results and adds things
to the spreadsheet
so let's just test this out show you
it's working so we'll just bring up a
shot of the
anemometer and run the code and
i'll give it some
artificial wind this will be running for
10 seconds doing its stuff
no output on the screen whilst it's
doing that but hopefully in a second
something will happen there we are it's
adding this data to the spreadsheet
temperature pressure and humidity and
also a wind speed
and this will continue on every 10
minutes so we'll actually go into that
for now and stop it because we'd be here
forever but if i just bring up the
spreadsheet
there we are and you can see the first
row of data has been recorded
with a date and a time and the values
we've just been talking about
so what i'm going to do is to get rid of
this row of data because
we don't want it there when we've just
been doing a test or delete
that row save the spreadsheet again and
everything is now
ready to do an outside test
right here i am again it's now the next
day
there are some little white fluffy
clouds chasing across the sky
and the allenometer has been mounted at
the top of an eight-foot pole
in my garden and it's going around at
least at the moment and it's connected
to the raspberry pi
which is in my garage so it's also
outside but i
am inside here on my laptop where i've
connected to the raspberry pi via
ssh and i'm going to run the combined
code now
over ssh like this it should be taking
the first measurement and hopefully show
us a measurement
in a second oh it's very exciting are we
going to see some measurements
coming across has 10 seconds past we
don't know it always seems a long time
when you're counting out 10 seconds
there we are look 10.4 degrees out there
various pressure humidity readings and
the wind speed of 1.17 liters
a second so what i'm going to do now is
to leave the pi putting data into the
spreadsheet
and we'll come back in a few hours
well here we are back again after an
afternoon
of weather it's been pretty varied it
was sunny initially when it got
rather dull we've had a rain shower but
the anedometer is still spinning around
it survived the weather which is
rather good for something that measures
the weather and if we look
here on the pi's desktop here is the
spreadsheet of the data it has produced
it has worked i'm always pleased to see
when things work and produce data
as they should so as you can see we've
had a variety of well temperatures have
been going down i guess they do in the
afternoon particularly in the
february as it is now pressure's gone a
little bit humidity's gone up
quite a lot it rained in the middle of
that i think it rained around here but
not absolutely certain and the wind
speed has been variable as you can see
it's not been
massively windy except on a few
occasions the thing went round
very very fast but of course it wouldn't
necessarily coincide with when the
measurement
was being taken anyway i'm very pleased
with this
i was pleased when i put the anemometer
on the pole this afternoon
and it started spinning it's great when
you can take some ping pong balls and
albiro
and a sensor and things like that and
actually generate some meaningful
results
so there we are we've managed to add a
functional
if not perfect anemometer to a raspy pie
weather station and we're not finished
yet
not by far not only do i have plans to
continue to add sensors to the raspberry
pi weather station
but are now musing on the idea of taking
a raspberry pi
and using it to control the cultivation
of plants and to monitor the cultivation
of plants
in this somewhat dilapidated greenhouse
there must be
lots of raspberry pi sensor and
associated projects we can do
here but now that's
it for another video if you've enjoyed
it you've seen here please press that
like button
if you haven't subscribed please
subscribe and i hope to talk to you
again
very recent
you
5.0 / 5 (0 votes)