Coder Social home page Coder Social logo

meteofunctions's Introduction

MeteoFunctions

build Framework Badge Arduino Framework Badge mbed

Do you have your own meteo station based on Arduino or Mbed? and ever wondered how meteorologists get values like:

  • Humidex
  • Dew point
  • Beaufort wind scale
  • Wind chill
  • Heat index
  • Apparent temperature
  • Cloud height base
  • Relative pressure
  • Absolute humidity

Let's add them to your project. You don't need any special sensors, it's just a math. Here is a class that do that for you. Supports both Celsius and Fahrenheit, please navigate to full example.

Arduino example

Please see examples folder

Mbed example

#include "mbed.h"
#include "MeteoFunctions.h"

MeteoFunctions calc;

float wind_speed = 2.0;   // m/s
float temp = 21.0;        // °C
float humidity = 60.0;    // %
float pressure = 975.8;   // hPa
float above_sea = 408.0;  // m

int main() {
    printf("Wind speed: %f km/h\n", calc.msToKmh(wind_speed));

    printf("Wind speed: %f m/h\n", calc.msToMph(wind_speed));

    printf("Wind speed: %f knots\n", calc.msToKn(wind_speed));

    printf("Beaufort wind scale: %u\n", calc.beaufort(wind_speed));

    printf("Humidex: %f *C\n", calc.humidex_c(temp, humidity));

    printf("Dew point: %f *C\n", calc.dewPoint_c(temp, humidity));

    printf("Wind chill: %f *C\n", calc.windChill_c(temp, wind_speed));

    printf("Heat index: %f *C\n", calc.heatIndex_c(temp, humidity));

    printf("Apparent temperature: %f *C\n", calc.apparentTemp_c(temp, humidity, wind_speed));

    printf("Could base: %f metres\n", calc.cloudBase_m(temp, humidity));

    printf("Relative pressure: %f hPa\n", calc.relativePressure_c(pressure, above_sea, temp));

    printf("Absolute humidity: %f g/m3\n", calc.absoluteHumidity_c(temp, humidity));

    return 0;
}

meteofunctions's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

veamchile ut2uh

meteofunctions's Issues

Problem with humidex_f()

Thank you for taking the time to create and share MeteoFunctions.

I believe I've found one minor defect. In calls to humidex_f(), incorrect values are returned which are notably close to humidex_c() values. I believe converting the function result from celsius to fahrenheit yields the correct value as shown below.

/**

  • Calculates humidex in Fahrenheit
    */
    float MeteoFunctions::humidex_f(float temp_f, float humidity) {
    return humidex_c(f_c(temp_f), humidity);
    }

/**

  • REVISED to include addition of c_f()
    */
    float MeteoFunctions::humidex_f(float temp_f, float humidity) {
    return c_f(humidex_c(f_c(temp_f), humidity));
    }

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.