mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Fix HRG-15 serial reception
This commit is contained in:
parent
2abb32e131
commit
f890c2d85a
@ -18,7 +18,7 @@ See [CHANGELOG.md](https://github.com/arendst/Tasmota/blob/development/tasmota/C
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
[](https://github.com/arendst/Tasmota)
|
[](https://github.com/arendst/Tasmota)
|
||||||
[](http://ota.tasmota.com/tasmota/)
|
[](http://ota.tasmota.com/tasmota/)
|
||||||
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22)
|
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22)
|
||||||
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22)
|
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22)
|
||||||
|
@ -23,7 +23,7 @@ Easy initial installation of Tasmota can be performed using the [Tasmota WebInst
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
[](https://github.com/arendst/Tasmota)
|
[](https://github.com/arendst/Tasmota)
|
||||||
[](http://ota.tasmota.com/tasmota/)
|
[](http://ota.tasmota.com/tasmota/)
|
||||||
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22)
|
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22)
|
||||||
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22)
|
[](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22)
|
||||||
|
@ -99,7 +99,7 @@ float Rg15Parse(char* buffer, const char* item) {
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rg15Process(char* buffer) {
|
bool Rg15Process(char* buffer) {
|
||||||
// Process payloads like:
|
// Process payloads like:
|
||||||
// Acc 0.01 mm, EventAcc 2.07 mm, TotalAcc 54.85 mm, RInt 2.89 mmph
|
// Acc 0.01 mm, EventAcc 2.07 mm, TotalAcc 54.85 mm, RInt 2.89 mmph
|
||||||
// Acc 0.001 in, EventAcc 0.002 in, TotalAcc 0.003 in, RInt 0.004 iph
|
// Acc 0.001 in, EventAcc 0.002 in, TotalAcc 0.003 in, RInt 0.004 iph
|
||||||
@ -113,7 +113,9 @@ void Rg15Process(char* buffer) {
|
|||||||
if (Rg15.acc > 0.0f) {
|
if (Rg15.acc > 0.0f) {
|
||||||
Rg15.time = RG15_EVENT_TIMEOUT; // We have some data, so the rain event is on-going
|
Rg15.time = RG15_EVENT_TIMEOUT; // We have some data, so the rain event is on-going
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
@ -133,6 +135,33 @@ void Rg15Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Rg15Poll(void) {
|
void Rg15Poll(void) {
|
||||||
|
bool publish = false;
|
||||||
|
|
||||||
|
if (!HydreonSerial->available()) {
|
||||||
|
// Check if the rain event has timed out, reset rate to 0
|
||||||
|
if (Rg15.time) {
|
||||||
|
Rg15.time--;
|
||||||
|
if (!Rg15.time) {
|
||||||
|
Rg15.acc = 0;
|
||||||
|
Rg15.rate = 0;
|
||||||
|
publish = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Now read what's available
|
||||||
|
char rg15_buffer[RG15_BUFFER_SIZE];
|
||||||
|
while (HydreonSerial->available()) {
|
||||||
|
Rg15ReadLine(rg15_buffer);
|
||||||
|
if (Rg15Process(rg15_buffer)) { // Do NOT use "publish = Rg15Process(rg15_buffer)"
|
||||||
|
publish = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publish && !TasmotaGlobal.global_state.mqtt_down) {
|
||||||
|
MqttPublishSensor();
|
||||||
|
}
|
||||||
|
|
||||||
if (Rg15.init_step) {
|
if (Rg15.init_step) {
|
||||||
Rg15.init_step--;
|
Rg15.init_step--;
|
||||||
if (1 == Rg15.init_step) {
|
if (1 == Rg15.init_step) {
|
||||||
@ -149,26 +178,6 @@ void Rg15Poll(void) {
|
|||||||
HydreonSerial->println('R'); // Read available data once
|
HydreonSerial->println('R'); // Read available data once
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HydreonSerial->available()) {
|
|
||||||
// Check if the rain event has timed out, reset rate to 0
|
|
||||||
if (Rg15.time) {
|
|
||||||
Rg15.time--;
|
|
||||||
if (!Rg15.time) {
|
|
||||||
Rg15.acc = 0;
|
|
||||||
Rg15.rate = 0;
|
|
||||||
MqttPublishSensor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Now read what's available
|
|
||||||
char rg15_buffer[RG15_BUFFER_SIZE];
|
|
||||||
while (HydreonSerial->available()) {
|
|
||||||
Rg15ReadLine(rg15_buffer);
|
|
||||||
Rg15Process(rg15_buffer);
|
|
||||||
}
|
|
||||||
if (!TasmotaGlobal.global_state.mqtt_down) { MqttPublishSensor(); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rg15Show(bool json) {
|
void Rg15Show(bool json) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user