node-anemometer

node-anemometer

NPM

Install

npm install node-anemometer
yarn add node-anemometer

Required hardware

At the moment this library can only be used with an extra counter module PCF8583

The circuit board

There are several ways to count the revolutions of the anemometer. The best result I got with the KY-003 board (a magnetic field sensor) and a magnet. The magnet is placed so that it triggers the sensor with each complete rotation. If you use mechanical components like reed switches, you need a debounce filter and additional hardware to avoid count many noise values. There are many designs of such PCBs. Here is one example: circuit board from Horter

System settings

Configuring I2C on the Raspberry Pi

Creating Multiple I2C Ports (for advanced people)

Usage

Example in TypeScript (with ES Modules):

Examples in the calculation not adjusted to your anemometer

import { Anemometer, calcFactor, WindSpeed, WindSpeedUnits } from '../../dist';

const calc = (pulses: number, time: number): WindSpeed => {
// You cannot divide by 0
if (time <= 0) {
return new WindSpeed(0, WindSpeedUnits.kilometersPerHour);
}

// More about the calculation can you find in the readme file
const windSpeed = (pulses / 2 / time) * calcFactor(9, 1.18);

// You must always return a class of the type WindSpeed
return new WindSpeed(windSpeed, WindSpeedUnits.kilometersPerHour);
};

// Initialize the class for your anemometer.
// Never initialize two classes for the same address on the same bus!
// For more options on initializing the class, read the documentation
const myAnemometer = new Anemometer(calc);

async function start() {
// Establish an i2c connection to the PCF8583 and start the reading process
await myAnemometer.open();

// Wait 15 seconds to have a usable average value
setTimeout(() => {
// '.getData()' calculates the average wind speed of the past x seconds
const data = myAnemometer.getData(10);

console.log(`Wind speed: ${data.rounded(2)} ${data.unit}`);

// Herewith you can stop the reading process and close the i2c connection
myAnemometer.close();
}, 15000);
}

start();

You can find more information in the full documentation 📖.

Calculation

The wind speed is always calculated with the signals and the time. Often you can find information about this in the data sheet. If you can't find any, I will now describe how the calculation works.

The following basic equation applies:

calculation

pulses: Signals emitted by the anemometer. The are similar when you press a button

pulses per rotation: Is the number of signals that are output for a complete rotation

time: Is the duration (in seconds) in which the measurement was performed

anemometer factor: Mostly to find in the datasheet, but can also be calculated by yourself. More information below

Calculate anemometor factor

The .calcFactor() function computes the multiplier for the calculation of the wind speed in km/h. The radius (measured distance from the center to the edge of one of the cups) in cm and the anemometer factor. The anemometer factor is a value to compensate for the lost wind energy when turning the arms. In my case this value is 1.18.


Useful information and references

👉 Special thanks to @DasMelone who helped me to work out this project

🌟 - I recommend to read this

🇩🇪 - Content that is only available in German


Author

👤 KillerJulian info@killerjulian.de

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check the issues page. You can also take a look at the contributing guide.

Generated using TypeDoc