mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 10:44:13 +01:00
Fix PZEM004T v2 (#846)
Fixes https://github.com/esphome/issues/issues/817
This commit is contained in:
parent
a5b49dbfa6
commit
6297395018
1 changed files with 2 additions and 2 deletions
|
@ -8,7 +8,7 @@ static const char *TAG = "pzem004t";
|
||||||
|
|
||||||
void PZEM004T::loop() {
|
void PZEM004T::loop() {
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
if (now - this->last_read_ > 500 && this->available()) {
|
if (now - this->last_read_ > 500 && this->available() < 7) {
|
||||||
while (this->available())
|
while (this->available())
|
||||||
this->read();
|
this->read();
|
||||||
this->last_read_ = now;
|
this->last_read_ = now;
|
||||||
|
@ -78,7 +78,7 @@ void PZEM004T::loop() {
|
||||||
this->last_read_ = now;
|
this->last_read_ = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PZEM004T::update() { this->write_state_(SET_ADDRESS); }
|
void PZEM004T::update() { this->write_state_(READ_VOLTAGE); }
|
||||||
void PZEM004T::write_state_(PZEM004T::PZEM004TReadState state) {
|
void PZEM004T::write_state_(PZEM004T::PZEM004TReadState state) {
|
||||||
if (state == DONE) {
|
if (state == DONE) {
|
||||||
this->read_state_ = state;
|
this->read_state_ = state;
|
||||||
|
|
Loading…
Reference in a new issue