Introduction: Measure Wind Speed With Micro:bit and Snap Circuits
As my daughter and I were working on a weather project anemometer, we decided to extend the fun by engaging programming.
What is an Anemometer?
Probably you're asking what "anemometer" is. Well, it's a device that measures the wind's strength. I have often seen it at the airports, but I've never known how it's called.
We took out our Snap Circuits set and decided to use the motor from the kit. We used 2 craft sticks from our craft supplies for the arms of the propeller. I punched a hole in the middle of each one with an awl. We put the sticks one on top of the other with some glue between them to fixate them forming and "X". Then, we cut a toilet paper roll in four equal pieces and cut a hole in each one with a craft knife. Then, we poked the sticks through the toilet paper pieces and attached the craft sticks propeller to the motor.
Step 1: Watch How the Propeller for the Anemometer Is Build
Our anemometer borrows the idea for the paper roll propeller from the video above.
Step 2: Punch a Hole in the Craft Sticks
- Take the two craft sticks.
- Find the middle of each of the craft sticks.
- Punch carefully a hole with an awl in the middle of each craft stick. Beware not to make the hole too loose for the stick needs to turn the motor.
Step 3: Poke the Snap Circuits Motor in the Craft Sticks
- Poke the motor from the Snap Circuits set into the holes in the craft sticks.
- Place the sticks perpendicular to one another.
Step 4: Cut Out the Four Wings of the Propeller
- Take the paper roll and divide it into two equal pieces with a pencil.
- Cut along the line and then cut each of the two pieces in two as shown in the picture.
Step 5: Put the Paper Roll Wings on the Craft Sticks
- Use a craft knife and cut slots in each paper roll piece just enough to poke a craft stick inside.
- Put a paper roll piece on each of the craft sticks.
Step 6: Build the Scheme
Use this scheme.
Step 7: Put It Together
Snap all elements as shown above.
The motor produces electricity when the shaft rotates towards the positive end of the motor. If the (+) is on the right side, the shaft must rotate clockwise. If the (+) is on the left side, the shaft must rotate counter-clockwise. Test the direction the propeller rotates by blowing some air at it. Make sure it rotates towards the correct direction. Otherwise, adjust the paper roll pieces.
Step 8: Code
The above code reads the signal (the wind speed) received on pin P1 (the pin the motor is connected to) and displays the result on the display of the micro:bit.
You can build the code yourself in the MakeCode Editor. You will find the "analog read pin" block under the Advanced > Pins section.
The "plot bar graph" block is under the Led section. Alternatively, open the ready project here.
Step 9: How It Works
This project takes advantage of the fact that motors can generate electricity.
Usually, we use electricity to power the motor and create rotary motion. This is possible due to something called magnetism.
The electric current that flows in a wire has a magnetic field similar to those of magnets. Inside the motor is a coil of wire with many loops and a shaft with a small magnet attached to it. If a large enough electric current flows through the loops of wire, it would create a large enough magnetic field to move the magnet, which would make the shaft spin.
Interestingly, the electromagnetic process described above also works in reverse. If we spin the shaft of the motor by hand, the rotating magnet attached to it will create an electric current in the wire. The motor is now a generator!
Of course, we cannot turn the shaft very fast, so the generated electric
current is very small. But it is large enough for the micro:bit to detect and measure it.
Now, let's close the Slide Switch (S1). The Battery Holder (B1) powers
the micro:bit through the 3V pin. The "forever" loop in the micro:bit starts executing. On every iteration, it reads the signal from pin P1 and displays it on the LED screen.
If we now blow air on the anemometer, we would turn the Motor (M1) and generate electric current, which will flow to pin P1.
The "analog read pin P1" function on the micro:bit will detect the
generated electric current and, based on the amount of current, will return a value between 0 and 1023. Most probably, the value will be lower than 100.
This value is passed to the "plot bar graph" function which compares it to the max value 100 and lights up as many LEDs on the micro:bit screen as is the proportion between the read and max values. The larger electric current is sent to pin P1, the more LEDs on the screen will light up. And this is how we measure the speed of our anemometer.
Step 10: Have Fun
Now, that you've completed the project blow the propeller and fave fun. Here are my kids trying to score a wind gust record.