You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
742 B
27 lines
742 B
#include "esphome.h"
|
|
#include "Adafruit_VEML6075.h"
|
|
|
|
class VEML6075CustomSensor : public PollingComponent, public Sensor {
|
|
public:
|
|
Adafruit_VEML6075 uv = Adafruit_VEML6075();
|
|
|
|
Sensor *uva_sensor = new Sensor();
|
|
Sensor *uvb_sensor = new Sensor();
|
|
|
|
VEML6075CustomSensor() : PollingComponent(15000) {}
|
|
void setup() override {
|
|
Wire.begin(21, 22);
|
|
uv.begin();
|
|
uv.setIntegrationTime(VEML6075_100MS);
|
|
}
|
|
|
|
void update() override {
|
|
float uva = uv.readUVA();
|
|
float uvb = uv.readUVB();
|
|
ESP_LOGD("custom", "The value of sensor uva is: %.0f", uva);
|
|
ESP_LOGD("custom", "The value of sensor uvb is: %.0f", uvb);
|
|
publish_state(uva);
|
|
uva_sensor->publish_state(uva);
|
|
uvb_sensor->publish_state(uvb);
|
|
}
|
|
};
|
|
|