Skip to content

Commit

Permalink
Merge pull request #5 from BlackSmith/fix
Browse files Browse the repository at this point in the history
Fix of temperature & humidity
  • Loading branch information
Zwer2k authored Feb 9, 2020
2 parents 3f978e1 + 3d1b305 commit b2106a5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/Zwer2k/WeatherStationDataRx.git"
},
"version": "0.3.0",
"version": "0.3.1",
"frameworks": "arduino",
"platforms": [
"atmelavr",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Weather Station Data Receiver
version=0.3.0
version=0.3.1
author=Zwer2k
maintainer=Zwer2k
sentence=
Expand Down
9 changes: 9 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@

[platformio]
test_dir = examples/WeatherStationDemo
extra_configs = *_env.ini
;default_envs = esp12e
;default_envs = esp32doit-devkit-v1

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
test_build_project_src = yes
monitor_speed = 115200

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
4 changes: 2 additions & 2 deletions src/WeatherStationDataRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ char WeatherStationDataRx::readData()
{
bState ? batteryState |= 1 : batteryState &= 0; // wenn die Batterien schwach sind, Bit 0 von batteryState auf 1 setzen

temperature = ((unsigned long)(rxBuffer >> 12) & 0xfff); // die Bits 12-23 enthalten den Temperaturwert (in 0.1 °C)
humidity = ((unsigned long)((rxBuffer >> 24) & 0xf) * 10) + ((rxBuffer >> 28) & 0xf); // die Bits 24-27 (einzer) und 28-31 (zehner) enthalten den Luftfeuchtigkeitsert (in %)
temperature = (long)(-2048 * ((rxBuffer >> 23) & 0x1)) + (unsigned long)((rxBuffer >> 12) & 0x7ff); // die Bits 12-23 enthalten den Temperaturwert (in 0.1 °C)
humidity = (unsigned long)((rxBuffer >> 24) & 0xf) + ((rxBuffer >> 28) & 0xf) * 10; // die Bits 24-27 (einzer) und 28-31 (zehner) enthalten den Luftfeuchtigkeitsert (in %)

DEBUG_PRINTF("Temperatur: %d.%d", (int)(temperature / 10), (int)(temperature % 10));
DEBUG_PRINT("°C")
Expand Down
4 changes: 3 additions & 1 deletion src/WeatherStationDataRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class WeatherStationDataRx
float readTemperature(bool inF = false);
uint8_t readHumidity();
float readWindSpeed(bool inKMH = false);
// 0 - N, 45 - NE, 90 - E, 135 - SE, 180 - S, 225 - SW, 270 - W, 315 - NW
uint16_t readWindDirection();
float readWindGust(bool inKMH = false);
float readRainVolume();
Expand All @@ -70,7 +71,8 @@ class WeatherStationDataRx
bool pairingRequeredMessageSent = false;
#endif
bool buttonState;
uint16_t temperature, humidity, windSpeed, windDirection, windGust, rainVolume; // Variablen zum speichern der Daten
int16_t temperature;
uint16_t humidity, windSpeed, windDirection, windGust, rainVolume; // Variablen zum speichern der Daten
byte batteryState = 0; // der Batterie-Status von beiden Sensoren (Bit 0 = Windsensor und Bit 1 = Regensensor)
byte randomID = 0; // At power up (when the batteries are inserted) the sensor selects a random number.

Expand Down

0 comments on commit b2106a5

Please sign in to comment.