Accueil / Posts in English / IoT : a connected Anemometer and Wind Vane with ESP8266

IoT : a connected Anemometer and Wind Vane with ESP8266

In this tutorial we will make a connected anemometer with a wind vane based on a ESP8266 WiFi module. If you have a 3D printer, you just need to print mechanical components of this projects with your printer. You can find all STL files on github.

For the anemometer, we will use a hall effect sensor. The hall effect sensor allow to count the turn of the anemometer propeller. To find to wind direction, we will make an optical encoder based on led and phototransistors. For the Arduino part, i used an ESP8266 module. I like the Wemos d1 mini because it is really small and cheap (about 5€).

BOM : what do you need for the project

For this project, you will need :

The cost of this project (with 3D printed parts) is about 30€.


The circuit is composed by two functions:

  • The first function is the angular encoder. We need 5 led and 5 phototransistors. The phototransistor is like a switch. Each time a phototransistor detect the light of the led, the state of the bit associated change (LOW or HIGH). We need a 10 kΩ  resistor for each phototransistor between +5V and the smallest pin. Connect the longest pin to GND.
  • The second function is the turn counter. The us1881 hall effect sensor is composed by 3 pins (angled corners in front of you).
    • Left pin <=> +5V
    • Middle pin <=> GND
    • Right pin <=> signal
    • Connect a 10 kΩ between right and left pins

Do not sold directly the Wemos d1 mini on the circuit to be able to remove it. Some time, it’s not possible to upload the Arduino program. You need to remove the Wemos before.

Follow the wiring diagram for making the circuit.

circuit anemometre girouette esp8266 wemos phototransistor us1881_bb

3D parts

I use Autodesk Fusion 360 to design this project. Fusion 360 is free for students and teachers (3 years). You will find Fusion 360 and STEP files into the github project here.

Part Design
Anemometer propeller 1. anemometre connecte helices
Anemometer housing 2. boitier anemometre esp8266 axe avec support aimant
Support of the us1881 hall effect sensor 5. anemometre support capteur effet hall us1881
Connecting plate (anemometer and wind vane housing)

Connect the wind vane and anemometer housing

Hall for phototransistors

6. liaison anemometre girouette
Central ball bearing housing 6.1 Support central roulements
Wind vane housing 7. Boitier girouette
Led support 8. support encodeur optique position girouette
Encoding disk (gray code) 9. disque encodeur
Wind vane 10 girouette

You will need about 62 meters of PLA and about 11 hours to produce all 3D parts.

ESP8266 / Arduino code

Download and open the Arduino code into your IDE. Modify the following variables before downloading the program. If you don’t publish data on a MQTT broker, comment all pubsub lines. Modify the pins adresses of the phototransistors if needed.

#define wifi_ssid “SSID”
#define wifi_password “MOTDEPASSE”
#define mqtt_server “IPSERVEURMQTT”
#define mqtt_user “guest”
#define mqtt_password “guest”


Step Picture
Assembling subsets

  1. Wind vane
  2. Anemometer propeller
  3. Magnets
  4. Ball bearing
Hélice + capot anémomètre
Wind vane assembly Girouette assemblée
Wind vane encoder assembly 2. Girouette assemblée
Insert the us1881 sensor support us1881
ESP8266 assembly into anemometer housing
Anémomètre - vue du dessus
Top vue
All finish objet connecte projet diy anemometre girouette esp8266 wemos d1 mini

Anemometer calibration

If like me you don’t have a laboratory wind tunnel, you need to use your care to make the calibration of the anemometer. Make several records at different speeds to find the relation between car speed and number of turns of the propeller.

If you don’t modify 3D parts of the propeller, you don’t need to calibrate the anemometer. be careful if you use your car for calibration like me !

Courbe étalonnage anémomètre

This anemometer can :

  • Measure wind speed from 8km/h (about 2m/s)
  • Up to 100 km/h
  • Use this relation to calculate wind speed. WindSpeed = (NumberOfTurns + 6,174 ) / 8,367

Wind vane calibration

In this version, i don’t develop any calibration code for the wind vane. Simply use your smartphone to find the index of the wind direction and update the program.


iot connected object anemometer wind vane esp8266 wemos d1 mini mqtt broker

I hope you enjoyed this tutorial. This is the first version we can improve :

  • Firstly, the design to make it weather resistant.
  • Replace the optical encoder by a magnetic sensor uses less power than LED and easier to program and possible to use with a battery.

Feel free to leave me your comments or questions in the comments.

Soon for a new project!

  • José Carlos Marques

    Hi. My name is José Carlos from Portugal. I’ve started working with harduino a few months ago and have already a weather station dumping data to ThingSpeak.
    i’m trying to do what you have here in this project to complement my weather station, but it’s not easy.
    Can you provide a few more photos with the assembly of your project?
    If you wan’t to send to my emai here it is

    • Hi José? I thank you very much. Of course i can send you more photos by mail. Just tell me what part you need. I’m thinking about an upgrade. I’ll replace phototransistors by reed switchs…but at the moment i work hard on ESPEasy, RFLink and MySensors. I think it will be easier to build and more reliable to determine the position of the wind. Regards

      • José Carlos Marques

        Hello. Thanks for your reply. If you would. Send please photos of a full assembly step by step. I receved today all peaces printed in 3d. They cost my 15.00 €. I already build a anemometer with a hard disk motor and I’m going to try to insert it in your project. As with the wind vane I I’m testing a project with 4 leds and 4 LDR’s. And I’m going to test a project with a HMC5883L. But I’ve seen projects with reed switchs too. Well. Send me the photos and I’ll send photos of my weather station too. It as a DHT22, BMP280 and a LDR witch I’m going to replace by a TSL2561. I have all connected with a ESP8266 sendding data to Thingspeak.
        Send the photos please.