DIY Anemometer
After diving into RC flying last year, I had the idea to create an anemometer to give updates on current wind conditions. With the smaller planes I like to fly, an abundance of wind is always unwelcome, so I wanted to be able to tell at a glance if it's a good time to fly or not. I found a really great 3D print file with instructions on Thingiverse. After printing it and trying it out with the ceramic bearing, I was really happy with how it worked, so got to work on the electroncs. I wanted to be able to put it in the backyard without needing to run any power wires to it, so decided to build something that used a WiFi board that was powered by a battery and charged daily with a solar charger. I decided to try to use an ESP8266-01 (ESP-01), since I had a few modules sitting in the project box and never actually used one. I figured it would work well in this case since I didn't need many GPIO pins (just one actually).
I decided to use a breadboard first to test out the hall sensor and the 5v/3v conversion on the breadboard using resistors. I used a multimeter to test out the sensor with a magnet, reading the output signal voltage. I would need a few resistors as a votage divider that would change the 5 volt output from the hall effect sensor to the lower 3.3 voltage necessary as input for the ESP-01's GPIO input pins. I was able to figure out to use a 10K ohm resistor going from 5v to the output signal pin, as well as a 22K resistor going from Ground to the output signal pin would output the necessary 3.3 volts.
From there I connected the ESP-01 board via FTDI cable. Mine has both 3.3v and 5v, so I was able to use both on the breadboard: 5v for the Hall Effect sensor, and 3.3v for the ESP-01. In the actual circuit, however, I'd need to use a 5v to 3.3v DC-to-DC buck converter board. These are extremely small and cheap now, I use them quite a lot, since they have a wide range of input/output voltages, so can be used in many applications, you just need to adjust a screw to dial in the desired output voltage. Detail the circuit, include the diagram from the notebook, showing the 5v to 3v converter board, necessary since the ESP-01 uses 3.3v, but the solar charger module outputs 5v. As well, the Hall Effect sensor uses 5v, so a few resistors are necessary to create a voltage divider to convert the 5v coming off the Hall Effect sensor output pin that goes into the ESP-01 digital input GPIO pin, which requires 3.3v input, not 5v.
Since there are severe limitations on the GPIO, I decided to add an extra one so that I wouldn't have to worry about pins being high/low at boot, since you do if you use any as an input. See this site for reference as to why. As you can see, GPIO0, 1, and 2 can't be used as an input, only GPIO3 could, however, that's used for RX. I was planning on doing this incrementally, doing serial output along the way, so wouldn't be able to use the RX/TX tied GPIO pins for that phase. However, apparently I could have just used the RX pin (GPIO3), since only TX is used to send data and RX would just be if you were sending terminal commands back to the ESP8266, RX could have been used as an input. I thought both RX and TX would have been required to work for any serial communication. See this article.
To get around this now apparently erroneous limitation, I hacked it to use GPIO14, see this post.
With that worked out, it was time to start work on the post which held the anemometer, electronics enclosure, and the solar panel. Wood post: Look for 2x2 lumber, I figured out looking up "2 inch furring strip" would be your best bet to find what you need locally. The Thingiverse file for the printed part accomodates a one inch by one inch post. I took the 2x2 (actally something like 1 and 5/8, lumber is weird) and used a radial arm saw to cut two sides down.
I wanted to put everything in a nice project box, and could have just either bought one online or printed one out. However, I was lazy and wanted something immediately since this was the last thing I needed and so I just went by the local hardware store and bought an electrical outlet enclosure. The plastic ones they had were for indoors so had a bunch of holes, and the plastic enclosed ones were a bit pricey, so I decided to get a metal enclosure that was weatherproof with a cover and some plugs for the non-existent electrical conduit. At home when putting it together it dawned on me: this was going to shield the already weak ESP-01 antenna from working. I ended up soldering a wire antenna that could hang down from the bottom hole for the wires, to which I added silicone sealant afterwards when it was all put together.
Ironed out some bugs in the code loops after letting it run for a few days. Also, had to re-adjust and increase the fudge factor a few times to where it seems to match up with current commercial weather site values. The issue is that I had to create the code that counts the revolutions without using interrupts. Why? Because the ESP-01 only allows the use of one interrupt at a time, and the WiFi library uses it, so it will clash when trying to use another one for the hall sensor. So even though I thought I calibrated it pretty well, I think the issue is that I had to do it with the WiFi code commented out, otherwise it would just hang, and when I calibrated it, all the cycles used for WiFi connectivity weren't in use. With it connected to WiFi and running, the counts were done with the WiFi connection loops thrown in, causing the speed to report as much slower that it actually was.
Also, I'm taking a measurement of a full 30 seconds of revolutions, which means it's actually measuring the sustained wind speed average for a half minute, which could have a very high burst of speed for a few seconds, but then way more calm for the rest. If getting the actual high speed burst measurements are important to you, then you'd have to modify the code to make the measurements shorter, like five or ten seconds (or better yet, just use an ESP32 so you can measure more accurately using interrupts).
I could have just used an ESP32 that would allow muliple interrupts, but I felt this was overkill, and I really liked just how small this ESP-01 board is, as well as the low amount of power it was going to draw from the solar charged battery.
A note on the code: as stated above, I added GPIO14 because I thought I would need the extra one since no other pins could have been used as inputs, however, you can still use the RX pin, GPIO3, since that would only be used to receieve serial commands - TX is used to send the output back to the PC (I thought both were required for either to work). I've changed the code accordingly to work with GPIO3.
Another note: modify the "fudge" variable to what works for you, it will probably be different based on what you use, but will get you close if you don't. I calibrated it by connecting it up to my laptop running the Arduino IDE and using the serial monitor, and then driving at 25 mph down a road that didn't have any stops for awhile. I then took an average of the times it was displaying, and used it to adjust the fudge factor I was using previously, which was 10.0, to come up with 2.72. However, once connected up to WiFi, the readings appeared to low, I think because in the testing from the car, I had to comment out all the WiFi code, which eats up cycles, and therefore throws the revolutions per seconds off. It's just based on feel and what weather reports, but for me, it doesn't need to be exact, I just want to know if it's a good day to fly or not.
Get the Arduino code here.
While purchasing items on AliExpress, I came across a small 3.5 inch "smart screen" for under $10. It plugs into a USB-C cable attached to your computer, and can display stuff like CPU usage, temps, etc. Interesting, but I don't care about that kind of thing so much, but was interested if it could show any kind of information you wanted on the screen. Officially you can't. However, hackers to the rescue, as they've created a repository for a bunch of these types of screens where you can not only change the templates, but can display custom images and text, which is exactly what I wanted. These are called "Turing Smart Screens", and you can find the repository here, along with how to display custom information here. When I bought it, I had it in my head that it could be something to display information from JARVIS (my custom home automation software), as well as just this sort of sensor information for the wind speed. It was actually pretty straightforward and easy to do, as the programming is done in Python. Software runs on Windows, Linux, and MacOS. The program I wrote uses Windows (Powershell using Python), but I may change it to use my Raspberry Pi server instead at some point so it's always on and data available on the screen.
For the Turing Smart Screen code below, change the "host" var from "127.0.0.1" to whatever your MQTT server IP is, change the MQTT topics to whatever you need, and change the font, size, background, etc., to what works for you or use what's in the orginal example code from the repo. This is just a customized version of the that code, with the MQTT functionality added.
I utilize MQTT by having my Raspberry Pi server running Mosquitto. I had already done a little bit of MQTT via PHP, but was curious if the same could be done with Websockets instead. Indeed there is, quite easily, using a JavaScipt library, as well as setting up the MQTT server to use Websockets, since Mosquitto supports it right out of the box. I was able to create a web page on my local server that would display all the MQTT wind data topics in real time. I've included links below to get started if you're curious how to do the same.
Parts and Links
- A3144 Hall Effect Sensor
- 5W Solar Panel
- Solar Power Manager Module
- 3.7V 3000mAh Lithium Battery
- Ceramic bearing
- Resistors
- DC-DC Buck Converter Board
- 3D file on Thingiverse
- Good video explaining Hall Effect sensor types and functionality
- Instructable on ESP3266 pins and programming
- Using a solar panel, battery, and charger board
- 3.5 inch USB Smart Screen
- Python Turing Smart Screen - Display custom information
- Python MQTT
- PowerShell and MQTT
- PHP MQTT
- Connect to MQTT with Websockets