npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-anemometer

v3.2.0

Published

Measuring the wind speed with an anemometer

Downloads

41

Readme

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 [email protected]

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