Created
September 20, 2017 12:40
-
-
Save mikebranstein/1d1a97d5c1f0058173056dd92faa64fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char* WeatherService::getWeatherData() { | |
serialPrintln(); | |
// Measure Relative Humidity from the HTU21D or Si7021 | |
float humidity = _sensor.getRH(); | |
// Measure Temperature from the HTU21D or Si7021 | |
float tempf = _sensor.getTempF(); | |
//Measure the Barometer temperature in F from the MPL3115A2 | |
// float baroTemp = _sensor.readBaroTempF(); | |
//Measure Pressure from the MPL3115A2 in Pascals | |
// 1 Pa = 0.000295299830714 inHg (inches of Mercury) | |
float pascals = _sensor.readPressure(); | |
float mmHg = pascals * 0.000295299830714; | |
//If in altitude mode, you can get a reading in feet with this line: | |
//altf = _sensor.readAltitudeFt(); | |
// get fuel guage and bundle with temperature data | |
FuelGauge fuel; | |
// get the avg wind speed and gust speed | |
float gustMPH; | |
float windMPH = getAnemometerMPH(&gustMPH); | |
StaticJsonBuffer<400> jsonBuffer; | |
JsonObject& root = jsonBuffer.createObject(); | |
root["h"] = humidity; | |
root["t"] = tempf; | |
root["p"] = mmHg; | |
root["st"] = getSoilTemp(); // soil temp in degF | |
root["m"] = getSoilMoisture(); // soil moisture level | |
root["a"] = windMPH; // anemometer MPH | |
root["d"] = getWindVaneDegrees(); // wind vane degrees | |
root["r"] = getAndResetRainInches(); // rain gauge count | |
root["v"] = fuel.getVCell(); // voltage | |
root["c"] = fuel.getSoC(); // state of charge in % | |
static char buffer[400]; | |
root.printTo(buffer, sizeof(buffer)); | |
return buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment