meshtastic / Meshtastic-Apple

Apple iOS, iPadOS & macOS Clients For Meshtastic
https://meshtastic.org
GNU General Public License v3.0
205 stars 59 forks source link

[Feature Request]: Client Side Weather Station Conditions Values #308

Open garthvh opened 1 year ago

garthvh commented 1 year ago

OS

iOS, iPadOS, macOS

Description

I want to extrapolate a few weather station glance values from locally available sensors if weather telemetry modules are available on a device.

To start with I want to have a conditions symbol, current temperature, and AQI with color dot if there is a connected Air Quality sensor. These values will replace the weather kit forecast on node details if sensor data is available for that node.

Display Helpers

Potential Conditions Calculations

.clear .cloudy (humidity is > 70% and temp < 70) .frigid (temp < freezing) .hot (temp > 80F) .rain (temp > freezing and humidity is > 98%) .snow (temp < freezing and humidity is > 98%)

Apple Weather Conditon Symbol Name BME680
.clear sun.max *
.cloudy cloud *
.foggy cloud.fog
.haze sun.haze
.mostlyClear sun.min
.partlyCloudy cloud.sun
.smoky smoke *
.breezy wind
.windy wind
.drizzle cloud.drizzle
.heavyRain cloud.heavyrain
.isolatedThunderstorms cloud.bolt
.rain cloud.rain *
.sunShower cloud.sun.rain
.scatteredThunderstorms cloud.sun.bolt
.strongStorms cloud.bolt.rain
.thunderstorms cloud.bolt.rain
.frigid thermometer.snowflake *
.hail cloud.hail
.hot thermometer.sun.fill *
.flurries cloud.snow
.sleet cloud.hail
.snow cloud.snow *
.sunFlurries cloud.sun.rain
.wintryMix cloud.snow
.blizzard cloud.snow.fill
.blowingSnow wind.snow
.freezingDrizzle cloud.hail
.freezingRain cloud.hail
.heavySnow cloud.snow
.hurricane hurricane
.tropicalStorm tropicalstorm

Links

Weather Kit Weather Conditions Values https://www.airnow.gov/aqi/aqi-calculator-concentration/ https://github.com/blueskyanalytics/aqi-calculator https://www.kaggle.com/code/rohanrao/calculating-aqi-air-quality-index-tutorial https://github.com/BoschSensortec/BSEC-Arduino-library https://www.circuitschools.com/interfacing-bme680-with-arduino-also-measure-indoor-air-quality-index/ https://developer.apple.com/documentation/foundation/unitpressure

Potential Advanced Calculations

Zambretti Weather Forcasting Heat Index

rcarteraz commented 1 year ago

This looks awesome! Looking forward to seeing what you come up with.

asjmcguire commented 6 months ago

dew point = Tc - ((100 - RH)/5.) Dew point = Temp in celcius - (( 100 - humidity) /5)

Dew point is a better calculation for snow, because the dew point needs to be close to freezing. The humidity does not need to be anywhere close to 98% for snow.

garthvh commented 2 months ago

dew point = Tc - ((100 - RH)/5.) Dew point = Temp in celcius - (( 100 - humidity) /5)

Dew point is a better calculation for snow, because the dew point needs to be close to freezing. The humidity does not need to be anywhere close to 98% for snow.

Wound up using the Magnus formula as it seems to get me a little closer to what I was seeing in weather kit, seems to be pretty good

/// Magnus Formula
func calculateDewPoint(temp: Float, relativeHumidity: Float) -> Double {
    let a: Float = 17.27
    let b: Float = 237.7
    let alpha = ((a * temp) / (b + temp)) + log(relativeHumidity / 100.0)
    let dewPoint = (b * alpha) / (a - alpha)
    let dewPointUnit = Measurement<UnitTemperature>(value: Double(dewPoint), unit: .celsius)
    let locale = NSLocale.current as NSLocale
    let localeUnit = locale.object(forKey: NSLocale.Key(rawValue: "kCFLocaleTemperatureUnitKey"))
    var format: UnitTemperature = .celsius

    if localeUnit! as? String == "Fahrenheit" {
        format = .fahrenheit
    }
    return dewPointUnit.converted(to: format).value
}