mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 20:53:26 +02:00
24 lines
620 B
C++
24 lines
620 B
C++
#include "esp32_hall.h"
|
|
#include "esphome/core/log.h"
|
|
#include "esphome/core/esphal.h"
|
|
|
|
#ifdef ARDUINO_ARCH_ESP32
|
|
|
|
namespace esphome {
|
|
namespace esp32_hall {
|
|
|
|
static const char *const TAG = "esp32_hall";
|
|
|
|
void ESP32HallSensor::update() {
|
|
float value = (hallRead() / 4095.0f) * 10000.0f;
|
|
ESP_LOGD(TAG, "'%s': Got reading %.0f µT", this->name_.c_str(), value);
|
|
this->publish_state(value);
|
|
}
|
|
std::string ESP32HallSensor::unique_id() { return get_mac_address() + "-hall"; }
|
|
void ESP32HallSensor::dump_config() { LOG_SENSOR("", "ESP32 Hall Sensor", this); }
|
|
|
|
} // namespace esp32_hall
|
|
} // namespace esphome
|
|
|
|
#endif
|