This commit is contained in:
Erik 2024-05-02 07:31:21 +02:00
parent 9ddf1efe57
commit e1d576afec
2 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,5 @@
#include "ain4_20ma.h" #include "ain4_20ma.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/components/i2c/i2c_bus.h"
namespace esphome { namespace esphome {
namespace ain4_20ma { namespace ain4_20ma {
@ -17,8 +16,8 @@ void Ain4_20maComponent::dump_config() {
void Ain4_20maComponent::update() { void Ain4_20maComponent::update() {
uint8_t data[2]; uint8_t data[2];
i2c::I2CDevice::ErrorCode err = this->read_register(0x20, &current, 2, true); i2c::ErrorCode err = this->read_register(0x20, &current, 2, true);
if (err != i2c::I2CDevice::ERROR_OK) { if (err != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Error reading data from AIN4-20mA"); ESP_LOGE(TAG, "Error reading data from AIN4-20mA");
this->publish_state(NAN); this->publish_state(NAN);
} else { } else {

View File

@ -16,5 +16,5 @@ class Ain4_20maComponent : public i2c::I2CDevice, public PollingComponent, publi
void update() override; void update() override;
}; };
} // namespace ain4_20ma } // namespace ain4_20ma
} // namespace esphome } // namespace esphome