Raspberry Pi Anemometer: Measuring Wind Speed!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[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
Info
Channel: ExplainingComputers
Views: 65,253
Rating: undefined out of 5
Keywords: Raspberry Pi, DIY anemometer, Raspberry Pi measuring wind speed, home made anemometer, anemometer Python code, Python anemometer code, Christopher Barnatt, Barnatt, Raspberry Pi weather station
Id: 1LPEPZ02-t8
Channel Id: undefined
Length: 20min 50sec (1250 seconds)
Published: Sun Mar 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.