Code Monkey home page Code Monkey logo

weathermeters's Introduction

Weather Meters

build Framework Badge Arduino

Arduino library for processing wind speed, wind wane and rain gauge sensors (WH1080, WH1090, Sparkfun)

It's interupt based library with callbacks and ready to use on any board. The only difference accros boards would be in initializing 1 second timer, ie. on STM32 you could use RTC timer, ESP32 has its own timer object, Timer1 could be used Arduino Uno (ATmega328P) etc please see examples/timers

Example

#include "WeatherMeters.h"

const int windvane_pin = A0;
const int anemometer_pin = 2;
const int raingauge_pin = 3;

// filter array = "binary" length only: 2, 4, 8, 16, 32, 64, 128, etc.
WeatherMeters <4> meters(windvane_pin);  // filter last 4 directions

void intAnemometer() {
    meters.intAnemometer();
}

void intRaingauge() {
    meters.intRaingauge();
}

void setup() {
    Serial.begin(115200);

    attachInterrupt(digitalPinToInterrupt(anemometer_pin), intAnemometer, FALLING);
    attachInterrupt(digitalPinToInterrupt(raingauge_pin), intRaingauge, FALLING);
}

void loop() {
    Serial.print(F("Wind degrees: "));
    Serial.print(meters.getDir(), 1);
    Serial.print(F(" Wind speed: "));
    Serial.print(meters.getSpeed(), 1);
    Serial.print(F("km/h, Rain: "));
    Serial.print(meters.getRain(), 4);
    Serial.println(F("mm"));

    delay(8000);
}

weathermeters's People

Contributors

per1234 avatar pilotak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

weathermeters's Issues

ESP32 core panic

Hey, I tried your code, but it kept crashing. After some research it seems that the problem is with _dir.

According to this, you aren't allowed to do float arithmetic in an interupt.
void WeatherMeters::timer() gets called on interrupt. And void WeatherMeters::timer() calls float WeatherMeters::adcToDir(uint16_t value)

Some enhancements

Hi!

First of all I'm appreciate the work you've put into this library! ๐Ÿ˜„

Some more features would be great to have in the library, because most of the metrics are needed for most Weather APIs (e.g.: WeatherUnderground, etc..)

Like:

  • Wind speed 1 minute average
  • Windgust
  • Rainfall intensity (mm/h or in/h)

I've already made an array for collecting Wind speeds for 1min average, also I can get the Windgust by searching for the highest number in the 1 min array ๐Ÿ˜„

The other thing can be useful is calibrating the Wind direction, since ADC values can be off and this can effect the whole wind direction. Currently i'm just simply adding/subtracting a value from the actual (degree) reading. It works for most of the time, but some wind positions are still wrong since its not related to the actual position rather than the ADC values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.