Anemometer and wind vane connected based ESP8266 [Full Guide]

In this tutorial I propose a project to achieve a connected anemometer equipped with a weather vane. If you are equipped with a 3D printer, you only have to print files of mechanical components found on github or STL file exchange platforms.

To achieve the anemometer, we use a magnetic field sensor Hall that will allow to count the number of rotation produced by the propeller anemometer.

to determine the wind direction, we will manufacture an optical encoder position using LEDs and photoresists.

for Arduino part, I opted for the mini ESP8266 Wemos D1 module. This module is very compact and very economical (about € 5). To find out, I return you to this previous article .

You can read this tutorial in English here

for this project you will need the following materials:

the realization of the project budget is approximately € 30

There are two basic principles to achieve an anemometer.. The easiest and count the number of lap set by a propeller driven by the wind. This is the principle adopted for this project. The second great principle is the measurement by ultrasound retained by Netatmo for his anemometer connected NWA01 . This will be for a next project …

To achieve the anemometer, so I propose to make a turn account using a magnetic field sensor that will change state in the presence of magnet ( to learn more about the Hall ). As part of a DIY project, we always try to minimize the cost of components (and buy them easily), so I opted for a us1881. You can buy by Lot 2 on Amazon for about € 3.70. The us1881 is a sensor that switches to low (LOW) in the presence of a South pole. In its operating principle the us1881 needs to be “rebooted” by the North pole of the magnet to power again be used to detect the next round. We will need two permanent magnets. We find for less than € 7 Lot 20 on Amazon (diameter 3 x 6 mm).

The determination of the wind direction is a little more complicated to achieve. Some projects offered on the Internet using a free angular potentiometer 360 degrees ( read the article on Keyes KY-040 ). The problem is that it is impossible to determine the absolute position of the sensor. Each restart the Arduino, we must re-establish the initial position (zero) from which there are one way or the other the number of increments which moved the arrow of the weather vane.

for this project, I propose to determine the angular position using an optical encoder made using photo-transistors and LEDs. Like the Hall sensor, a photo transistor acts as a switch and changes state (goes to the LOW state) in the presence of light.

There are many other solutions (magnetic, gyroscope …) … and therefore still full of plans to offer!

the easiest to find on retail sites is the Vishay TEPT4400. for example it is found to minus € 4.50 on eBay . This phototransistor can be supplied with 5 volts. It is sensitive to 440 to 800nm ​​with a maximum at 570nm, which corresponds to the yellow color. However, its detection spectrum is quite wide which allows to choose another color (red, green, blue), it will work just as well. The technical documentation is available here .

Sensibilité spectrale du phototransistor Vishay TETP4400. Max. à 570nm
Spectral sensitivity of the phototransistor Vishay TEPT4400. maximum sensitivity at 570nm.

By placing the LED on a circle and by cutting in a rotary three lights disc. The lights are cut so that one can have a single change of state of a phototransistor at each change position. This is the principle of the Gray code ( detailed here ), but without the need to code anything. With this method, you lose a little precision (30 possible positions, ie a resolution of 12 °) instead of 32 theoretical positions (2 5 ), but it’s still more than enough to determine wind direction (4 cardinal directions and 4 intermediate positions).

in this first version, I have not developed an algorithm to determine the orientation from a known orientation of the wind vane. It will go through a calibration “by hand” and the code “hard” in the Arduino program. It’s pretty simple, just locate the decimal position corresponding to the orientation of the wind vane in helping you compass a smartphone.

If you have developed a generic algorithm, please to offer commits to the github project or share in the comments section.

for more information on the operation, see article more detailed .

Side connection, the circuit is quite simple and has only resistors. The circuit consists of two blocks:

  • The first block is the angular position encoder . It feeds the 5 LEDs directly on the spindle + 3V to Wemos (allowing at the same time save and earn 5 resistors in place). The phototransistor functions as a switch. It goes to the Low state (LOW) when enough light is captured. The largest pin is connected to GND. A resistance of 10 kW is provided between the 5V power supply and smaller pin on which also will retrieve the signal on a digital input WEMOS.

  • The second circuit enables measure the speed wind using a us1881. The us1881 has 3 pins, here the connection (inclined faces facing you):
    * The spindle left to + 5V
    * The center pin must be connected to GND
    * The right pin. retrieves the status of the sensor on a digital input of ESP
    * the two outer pins (+ 5V / signal) must be connected by a resistance of 10 kW
    * Insulate the external pins with shrinktube

Follow the wiring diagram to make the circuit on a previously cut perforated plate (width 46mm x height 42mm). I suggest you do not weld the Wemos directly on the perforated plate so as to easily disconnect the circuit in case of problems. Uploading is sometimes capricious and must remove the circuit card to do so.

circuit anemometre girouette esp8266 wemos phototransistor us1881_bb

anemometre connecte circuit esp8266 wemos d1 mini face
Face Wemos circuit
anemometre girouette connecte esp8266 face arriere
back side of the circuit (us1881 visible)

I apologize for the quality of welds (I will shock most of you pros!) . I did some further testing: battery operation, control the lighting of the LEDs, my broken welds by developing the assembly process … in short, everything it takes to get it

! I opted for Autodesk Fusion 360 which is free for students and teachers (for 3 years). There are still a few months (when I started to take it in hand), Fusion 360 was also free for Makers and small businesses. It’s a shame, hopefully Autodesk will reconsider its trade policy.

projets diy objet connecte anemometre girouette esp8266 arduino wemos d1 mini tetp4400 us1881
Overview of the anemometer, wind vane and the wall mounting bracket.

You can find the Fusion 360 and an export file format in the STEP CAD file github project of .

the anemometer has 17 rooms in print 3D. Here the presentation :


Hélice anemometer

Each propeller (3 in total) is housed between two half shells (the top is not shown). Each propeller is secured by M3x20 screw. The lower shell comprises a housing for a nut against M5. The axis of the anemometer must be performed with a threaded rod M5 x 105mm

1. anemometre connecte helices

Boitier anemometer

The case can accommodate

  • The Wemos d1 mini

  • The electronic card is received in the groove

  • on the axis of rotation of the anemometer one will screw the support magnets 2

  • lateral reinforcing ribs to rigidify the housing and guiding the threaded rods l’assemblage

2. boitier anemometre esp8266 axe avec support aimant

Support Hall effect sensor us1881

This support includes a housing for the Hall effect sensor. It will slide over the threaded rod and maintains the electronic card position.

5. anemometre support capteur effet hall us1881

Plaque Link

The plate can perform the following functions:

  • Position 5 photo transistors

  • Linking the two boxes (anemometer and wind vane )

  • Attach the box to mur

6. liaison anemometre girouette

Axe center support bearings

We will insert (by force) a bearing on each side and then insert it into the central housing of the connecting plate.

Turnover superior to the axis of the anemometer. The lower bearing for the axis of the girouette.

6.1 Support central roulements

Boitier weathercock

The shoulder can position the base plate of the LED optical encoder.

Downstairs is the receptacle for the second bearing the axis of the girouette.

7. Boitier girouette

Support Led

This support allows positioning the 5 LEDs opposite phototransistors. The holder is positioned vertically in the housing by the shoulder. Threaded rods realize positioning angulaire.

8. support encodeur optique position girouette

Disque encoding

This disc allows you to encode the position of the vane (reason below). It will be screwed on the axis of the vane. Put glue point for fixer.

9. disque encodeur


La vane is composed of 3 parts. Two half-shells and arrow. 4 M3 screws to assemble everything.

10 girouette

All STL files are in the STL file of project github . Here is a summary of the printing time and the length of wire (theoretical) necessary. To make my anemometer, I used my Dagoma # discovery200. If you need, I wrote recently article explains how to export the objects in STL format for Fusion 360 and how to configure and use the original version of Cura instead of by Cura Dagoma.

I used PLA for achievement. The PLA remains biodegradable, but long term. It will put your anemometer connected to the shelter from the weather as it is not waterproof in this version.


PièceLongueur PLA (m) PLA mass (g) Print time (min)
Axe central0,4215
Blocage circuit0,6726
Boitier anémomètre11,1533120
3 hélices8,212492
Support aimants0,2513
Support propeller inférieur2,89927
Support propeller supérieur2,88928
Support us18810,8328
Totaux30,4 m 90g 322 min (5:30 env.)


PièceLongueur PLA (m) PLA mass (g) Print time (min)
Case girouette8,892783
Flèche girouette6,041866
Disque encoder position1,15313
Support Leds3,13933
Totaux19,2m57g195 minutes (approximately 3:15)

More pièces

PièceLongueur PLA (m) PLA mass (g) Print time (min)
Plate liaison7,032167
Support mural4,71442
Totaux11,73m35g109 minutes (1:49 about)

You will need approximately 62m of PLA (or about 180g). The total time 3D printing is to about 10:30

the project code is available on github here the github project contains the following elements:..

  • CAD files formats STEP and F3D (Autodesk Fusion 360)

  • Files STL printing 3D

  • program ESP8266 (ESP-12) or Arduino (changing addresses)

the program allows in this version of the following functions:

  • log in to your WiFi network

  • connect to a Broker mosquitto If you discover, here an overview article

  • .

  • Measuring wind speed for 5 seconds

  • Measure the wind direction

  • Post MQTT with the Protocol on the broker mosquitto wind speed in km / h, m / s and the wind direction

All necessary pins are at the beginning of the program in separate variables. I used the locating pin NodeMCU. Before you upload the program, remember to change the following variables:
#define wifi_ssid “SSID”
#define wifi_password “PASSWORD”
#define mqtt_server “IPSERVEURMQTT”
#define mqtt_user ” guest “
#define mqtt_password” guest “

you may need to add the ESP8266WiFi bookstores and pubsubclient your Arduino IDE.

If you do not have to Broker MQTT , put the comment lines in the program to avoid unnecessary seek your WiFi network

Here the assembly steps.

Apart from working in a laboratory or aero car, I imagine you do not have access to a wind tunnel to calibrate your anemometer. So we have to go through the car. Be extremely careful when you experiment. I was up to 100km / h without the slightest mechanical problem.

If you make no changes to the propeller, this step is unnecessary.

If not, here is how we should proceed. By measuring several times the number of rotation of the impeller at different speeds, it can be inferred wind speed to the other. Place dots on Excel and trace linear regression line for the relationship between speed and the number of revolutions of the propeller. I agreed, it is not very accurate sandstone but we remain in the field of DIY after all.

Courbe étalonnage anémomètre
The calibration curve anemometer

the characteristics of this instrument:

  • minimum wind speed: 2m / s or about 8km / h

  • Relationship between speed and wind speed (km / h): V = (nbrTour + 6,174) / 8,367 (with a margin of error of about 3%)

  • calibrated speed up to 100 km / h

To calibrate the wind vane, I have not yet equated the encoder. For this first version, I propose to locate the position of the encoder in relation to the actual orientation of the wind vane. Use the compass of your smartphone. The advantage of this method is that it is only a test to do, so it is easy to program.

After each measurement, the program published on the broker MQTT speed (in m / s and km / h) and wind direction (in the form of a letter). If you discover MQTT and its use in Jeedom , I return you to this previous article that detail step by step how to proceed.

As usual, detects Jeedom automatically new topics published on the broker MQTT and added as a great new device it only remains to configure.

jeedom configuration anemometre esp8266 wemos d1 mini mqtt

and here is the update on the dashboard . jeedom anémometre dashboard

objet connecte projet diy anemometre girouette esp8266 wemos d1 mini

I hope you enjoyed this tutorial. This first version still has some teething problems. In the next version, I would like to improve the following:

  • First the design to make the anemometer watertight and weatherproof

  • Replace the encoder. optical by a magnetic sensor uses less power than LED and easier to program. I came across a bone to control the supply of the LED with a transistor IRF520. The supply voltage for the LEDs is too low (2.3V), making detection by random phototransistor. This solution would also operate the anemometer battery (9V battery or) managing the sleep mode of the ESP8266.

  • And why not embark on an anemometer ultrasound

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

soon for a new project !



Anémomètre and vane connected based ESP8266


A DIY project to make an anemometer and wind vane connected to WiFi base ESP8266 Wemos D1 mini module. All STL files of the components manufactured by 3D printing are available on github. Integration into Jeedom home automation server with server MQTT mosquitto.




Projects DIY



  1. 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

  2. You should find a popular wind cup anemometer which mounts to anything metal with its dual powerful magnet mounts on its base. If you don't have any idea how to choose the best one, check out


Powered by Blogger.