- C++ 90%
- C 10%
| .vscode | ||
| include | ||
| lib | ||
| src | ||
| test | ||
| .gitignore | ||
| platformio.ini | ||
| README.md | ||
BresserWeatherSensorReceiver
Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on RadioLib using CC1101, SX1276/RFM95W, SX1262 or LR1121
See the Wiki for additional information.
To allow automatic handling of all Bresser weather station variants, the decoders are tried in the following order until decoding succeeded:
- 7-in-1-Decoder
- 6-in-1-Decoder
- 5-in-1 Decoder
- Lightning Sensor Decoder
- Water Leakage Sensor Decoder
(The Bresser 5-in-1 Weather Stations seem to use two different protocols - 5-in-1 and 6-in-1.)
| Model | Type | Decoder Function |
|---|---|---|
| 7002510..12, 9602510 | Weather Station | decodeBresser5In1Payload() |
| 7902510..12 | Weather Station (Base) | decodeBresser5In1Payload() |
| 7002530 | Professional Rain Gauge | decodeBresser7In1Payload() |
| 7002531 | 3-in-1 Professional Wind Gauge / Anemometer | decodeBresser6In1Payload() 1) |
| 7002585 | Weather Station | decodeBresser6In1Payload() |
| 7009999 | Thermo-/Hygrometer Sensor | decodeBresser6in1Payload() |
| 7009970 | Air Quality Sensor PM 2.5 / PM 10 | decodeBresser7In1Payload() |
| 7009971 | High Precision Thermo Hygro Sensor | decodeBresser6In1Payload() |
| 7009972 | Soil Moisture/Temperature Sensor | decodeBresser6In1Payload() |
| 7009973 | Pool / Spa Thermometer | decodeBresser6In1Payload() |
| 7009975 | Water Leakage Sensor | decodeBresserLeakagePayload() |
| 7009976 | Lightning Sensor | decodeBresserLightningPayload() |
| 7009977 | CO2 Sensor | decodeBresser7In1Payload() 2) |
| 7009978 | Air Quality Sensor HCHO / VOC | decodeBresser7In1Payload() 3) |
| 7003600 and WSX3001 | Weather Station | decodeBresser7In1Payload() 4) |
| 7003210 | Weather Station | decodeBresser7In1Payload() |
| 7803200 | Weather Sensor | decodeBresser7In1Payload() |
| 7003300 | Weather Station | decodeBresser7In1Payload() |
| 7803300 | Weather Sensor | decodeBresser7In1Payload() |
| 7003150 | 8-in-1 Weather Station | decodeBresser7In1Payload() 5) |
Some guesswork:
| Numbering Scheme | Type |
|---|---|
| 700[25|31|32|33|36]* | Weather Station, Base + Sensor |
| 780[25|31|32|33]* | Weather Station Sensor (Replacement) |
| 790* | Weather Station Base (Replacement) |
| 700[99]* | Accessory Sensor |
1) The flag DATA_COMPLETE must not be set in getData(), otherwise the return value would always indicate a timeout. (I.e. use #define RX_STRATEGY 0 in some of the example sketches.)
2) Request for testing, see https://github.com/matthias-bs/BresserWeatherSensorReceiver/issues/138
3) Request for testing, see https://github.com/matthias-bs/BresserWeatherSensorReceiver/issues/139
4) The part number is specific to the actual variant, i.e. some more characters are appended
5) The value tglobe_c is preliminary, see https://github.com/matthias-bs/BresserWeatherSensorReceiver/issues/220
Note
Weather sensors which are using the 6-in-1 protocol are actually transmitting two different kind of messages alternately:
- Temperature, Humidity, Wind and Battery status
- Wind and Rain
All other sensors/protocols are transmitting a single type of message which contains a complete set of data.
The behavior described above can be observed with BresserWeatherSensorBasic, which just shows each message as it is received by using the function
getMessage().The other examples are using the function
getData(), which buffers and combines messages from the 6-in-1 protocol until a complete set of data — with some configuration options regarding completeness, see BresserWeatherSensorOptions — is available.
Configuration
Predefined Board Configurations
By selecting a Board and a Board Revision in the Arduino IDE, a define is passed to the preprocessor/compiler. For the boards in the table below, the default configuration is assumed based on this define. I.e. you could could use an Adafruit Feather ESP32-S2 with a CC1101 connected to the pins of your choice of course, but the code assumes you are using it with a LoRa Radio Featherwing with the wiring given below. In some cases (bold entries in the table below) an additional define has to be enabled manually in WeatherSensorCfg.h.
If you are not using the Arduino IDE, you can use the defines in the table below with your specific tool chain to get the same result.
If this is not what you need, you have to switch to Manual Configuration
| Setup | Board | Board Revision | Defines bold: to be enabled manually in WeatherSensorCfg.h |
Radio Module | Notes |
|---|---|---|---|---|---|
| LILYGO®TTGO-LORA32 V1 | "TTGO LoRa32-OLED" | "TTGO LoRa32 V1 (No TFCard)" | ARDUINO_TTGO_LORA32_V1 | SX1276 (HPD13A) | - |
| LILYGO®TTGO-LORA32 V2 | "TTGO LoRa32-OLED" | "TTGO LoRa32 V2" | ARDUINO_TTGO_LoRa32_V2 | SX1276 (HPD13A) | Only needed for LMIC: Wire DIO1 to GPIO33 |
| LILYGO®TTGO-LORA32 V2.1 | "TTGO LoRa32-OLED" | "TTGO LoRa32 V2.1 (1.6.1)" | ARDUINO_TTGO_LoRa32_v21new | SX1276 (HPD13A) | - |
| LILYGO®T3 S3 SX1262 | "LilyGo T3-S3" | "Radio-SX1262" | ARDUINO_LILYGO_T3S3_SX1262 | SX1262 | - |
| LILYGO®T3 S3 LR1121 | "LilyGo T3-S3" | "Radio-LR1121" | ARDUINO_LILYGO_T3S3_LR1121 | LR1121 | - |
| Heltec Wireless Stick | "Heltec Wireless Stick" | n.a. | ARDUINO_HELTEC_WIRELESS_STICK | SX1276 | - |
| Heltec Wireless Stick V3 | "Heltec Wireless Stick" | n.a. | ARDUINO_HELTEC_WIRELESS_STICK_V3 | SX1262 | - |
| Heltec WiFi LoRa 32 V2 | "Heltec WiFi LoRa 32(V2)" | n.a. | ARDUINO_HELTEC_WIFI_LORA_32_V2 | SX1276 | - |
| Heltec WiFi LoRa 32 V3 | "Heltec WiFi LoRa 32(V3)" | n.a. | ARDUINO_HELTEC_WIFI_LORA_32_V3 | SX1262 | - |
| Adafruit Feather ESP32S2 with Adafruit LoRa Radio FeatherWing | "Adafruit Feather ESP32-S2" | n.a. | ARDUINO_ADAFRUIT_FEATHER_ESP32S2 | SX1276 (RFM95W) | Wiring on the Featherwing: E to IRQ D to CS C to RST A to DI01 |
| Adafruit Feather ESP32 or Adafruit Feather ESP32 V2 with Adafruit LoRa Radio FeatherWing | "Adafruit ESP32 Feather" "Adafruit Feather ESP32 V2" |
n.a. | ARDUINO_FEATHER_ESP32 | SX1276 (RFM95W) | Wiring on the Featherwing: A to RST B to DIO1 D to IRQ E to CS |
| ThingPulse ePulse Feather with Adafruit LoRa Radio FeatherWing | "Thingpulse ePulse Feather" | n.a. | ARDUINO_THINGPULSE_EPULSE_FEATHER | SX1276 (RFM95W) | Wiring on the Featherwing: A to RST B to DIO1 D to IRQ E to CS |
| DFRobot FireBeetle with FireBeetle Cover LoRa Radio 868MHz | "FireBeetle-ESP32" | n.a. | ARDUINO_DFROBOT_FIREBEETLE_ESP32 & DFROBOT_COVER_LORA | SX1276 (LoRa1276) | Wiring on the cover: D2 to RESET D3 to DIO0 D4 to CS D5 to DIO1 Additional connections required for battery voltage measurement. |
| M5Stack Core2 with M5Stack Module LoRa868 | "M5Core2" | n.a. | ARDUINO_M5STACK_CORE2 | SX1276 (RA-01H) |
Only needed for LMIC - wiring on the LoRa868 Module: DIO1 to GPIO35 "M5Unified" must be installed M5.begin()is called to control power management |
| ESP32-S3 PowerFeather with Adafruit LoRa Radio FeatherWing | "ESP32-S3 PowerFeather" | n.a. | ARDUINO_ESP32S3_POWERFEATHER | SX1276 (RFM95W) | Wiring on the Featherwing: A to RST B to DIO1 D to IRQ E to CS "PowerFeather-SDK" must be installed Board.init(); is called to control power management |
| Seeed Studio XIAO ESP32S3 & Wio-SX1262 Kit | "XIAO_ESP32S3" | n.a. | ARDUINO_XIAO_ESP32S3 | SX1262 | (B2B connector) |
| Adafruit Feather RP2040 with Adafruit LoRa Radio FeatherWing | "Adafruit Feather RP2040" | n.a. | ARDUINO_ADAFRUIT_FEATHER_RP2040 | SX1276 (RFM95W) | Wiring on the Featherwing: A to RST B to DIO1 D to IRQ E to CS External voltage divider required for battery voltage measurement. |
The preprocessor will provide some output regarding the selected configuration if enabled in the Arduino IDE's Preferences ("Verbose Output"), e.g.
ARDUINO_ADAFRUIT_FEATHER_ESP32S2 defined; assuming RFM95W FeatherWing will be used
[...]
Receiver chip: [SX1276]
Pin config: RST->0 , CS->6 , GD0/G0/IRQ->5 , GDO2/G1/GPIO->11
Note
The AVR architecture — including Adafruit Feather 32u4 RFM95 LoRa Radio — is no longer supported due to code size.
User-Defined Configuration
See WeatherSensorCfg.h for configuration options.
-
Set the desired radio module by (un-)commenting
USE_CC1101,USE_SX1262,USE_SX1276orLR1121.RFM95W, HPD13A and RA-01H are compatible with SX1276.
-
Set the I/O pinning according to your hardware
Define Radio Module Configuration ESP32 user-defined generic, used for ESP32 boards if none of the above is defined ESP8266 user-defined generic, used for ESP8266 boards if none of the above is defined -
Data from multiple sensors can be received by setting
MAX_SENSORS_DEFAULTto an appropriate value inWeatherSensorCfg.h.e.g.
#define MAX_SENSORS_DEFAULT 1 -
The sensors to be handled can be configured by two ways:
-
Add any unwanted sensor IDs to the exclude list
SENSOR_IDS_EXCe.g.
#define SENSOR_IDS_EXC { 0x39582376 } -
Specify the wanted sensors explicitly in the include list
SENSOR_IDS_EXC- if empty, all sensors will be usede.g.
#define SENSOR_IDS_INC { 0x83750871 }
-
-
Unused decoders can be disabled to save computation time/power by commenting out:
e.g.
//#define BRESSER_LEAKAGE
See How Sensor Reception works for a detailed description.
Rain Statistics
The weather sensors transmit the accumulated rainfall since the last battery change or reset. This raw value is provided as rain_mm. To provide the same functionality as the original weather stations, the class RainGauge (see
RainGauge.h)
is used to calculate
- hourly (past 60 minutes) rainfall,
- daily rainfall,
- weekly rainfall,
- and monthly rainfall.
These values are named rain_h, rain_d, rain_w and rain_m in the MQTT software examples.
Note
Time and date must be set correctly in order to reset the daily, weekly and monthly rain values correctly. This is achieved by setting the real time clock (RTC) from an available time source, e.g. via SNTP from a network time server if the device has internet connection via WiFi. The user must set the appropriate time zone (
TZ_INFO) in the sketch.
See Implementing Rain Gauge Statistics for more details.
Lightning Sensor Post-Processing
The lightning sensor transmits the accumulated number of strikes and the estimated distance from the storm front (at the time of the last strike) at an interval. The post-processing algorithm implemented in the class Lightning (see
Lightning.h) calculates the number of events during the past 60 minutes — using the same algorithm as the rain statistics — and stores information of the last event:
- Timestamp (UTC),
- Estimated distance and
- Number of strikes since the previous event.
Note
Time and date must be set correctly in order to store the timestamp. This is achieved by setting the real time clock (RTC) from an available time source, e.g. via SNTP from a network time server if the device has internet connection via WiFi.
BresserWeatherSensorMQTT
Uses default configuration src/WeatherSensorCfg.h
This is finally a useful application.
At startup, first a WiFi connection and then a connection to the MQTT broker is established. (Edit secrets.h accordingly!) Then receiving data of all sensors (as defined in NUM_SENSORS, see WeatherSensorCfg.h) is tried periodically. If successful, sensor data is published as MQTT messages, one message per sensor.
If the sensor ID can be mapped to a name (edit sensor_map[]), this name is used as the MQTT topic, otherwise the ID is used. From the sensor data, some additional data is calculated and published with the extra topic.
The data topics are published at an interval of >DATA_INTERVAL. The status and the radio topics are published at an interval of STATUS_INTERVAL.
Furthermore, Home Assistant MQTT discovery messages are published at an interval of DISCOVERY_INTERVAL. See section Home Assistant for more details.
If sleep mode is enabled (SLEEP_EN), the device goes into deep sleep mode after data has been published. If AWAKE_TIMEOUT is reached before data has been published, deep sleep is entered, too. After SLEEP_INTERVAL, the controller is restarted.
MQTT publications:
<base_topic>/data/<ID|name> sensor data as JSON string - see publishWeatherdata()
<base_topic>/extra calculated data
<base_topic>/radio radio transceiver info as JSON string - see publishRadio()
<base_topic>/status "online"|"offline"|"dead"$
homeassistant/sensor/<sensor_id>_<json_ele>/config Home Assistand auto discovery for sensor data
homeassistant/sensor/<hostname>_<json_ele>/config Home Assistand auto discovery for receiver control/status
MQTT subscriptions:
<base_topic>/reset <flags> reset rain counters (see RainGauge.h for <flags>) and lightning post-processing (flags & 0x10)
<base_topic>/get_sensors_inc get sensors include list
<base_topic>/get_sensors_exc get sensors exclude list
<base_topic>/set_sensors_inc {"ids": [<id0>, ... ]} set sensors include list, e.g. {"ids": ["0x89ABCDEF"]}
<base_topic>/set_sensors_exc {"ids": [<id0>, ... ]} set sensors exclude list, e.g. {"ids": ["0x89ABCDEF"]}
$ via LWT
<base_topic> is set by #define HOSTNAME ...
<base_topic>/data JSON Example:
{"sensor_id":12345678,"ch":0,"battery_ok":true,"humidity":44,"wind_gust":1.2,"wind_avg":1.2,"wind_dir":150,"rain":146}
Dashboard with IoT MQTT Panel (Example)
Notes
- Set your WiFi credentials in secrets.h
- Upload the contents of examples/BresserWeatherSensorCanvasGauges/data/ to the board's Flash memory using earlephilhower/arduino-littlefs-upload
- Enable WiFi Access Point mode by uncommenting WIFI_AP_MODE if desired
github.com/matthias-bs/BresserWeatherSensorReceiver@60028b5788/examples/BresserWeatherSensorCanvasGauges/BresserWeatherSensorCanvasGauges.ino (L91) - Open http://weatherdashboard.local (or the IP address shown in the serial monitor) in your web browser to access the web page
- Press the on-board button during power-up to reset rain gauge data
- Rain values are limited to prevent overflow of the linear gauges
MQTT Integrations
Home Assistant
MQTT Discovery
Home Assistant MQTT Discovery is available.
MQTT topic schemes:
homeassistant/sensor/<hostname>_<json_ele>/config– weather sensor receiver configuration statushomeassistant/button/<hostname>_<json_ele>/config– weather sensor receiver commandhomeassistant/sensor/<sensor_id>_<json_ele>/config– sensor data<sensor_id>: Sensor ID as hex number<json_ele>: JSON element as indatamessage, e.g.temp_c.
Note
The sensors transmit the battery status as binary value (
battery_ok), but Home Assistant expects a percentage. Therefore the battery status is converted to 0% or 100%.
Customization of MQTT discovery messages can be done in haAutoDiscovery() in the sketches' mqtt_comm.cpp if desired.
weather_sensor_receiver_config.yml allows to configure sensor include/exclude lists.
Manual Configuration
Manual configuration of Home Assistant can be done using a file template provided by Shadowpost:
Bresser_HA_MQTT_custom_config.yaml
Debug Output Configuration
See Debug Output Configuration in Arduino IDE