Created
October 12, 2022 20:01
-
-
Save maaad/7135ded40c08b3e9e45755b6fa771a1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
... | |
libraries: | |
- Wire | |
- "climateguard/ClimateGuard RadSens" | |
includes: | |
- RadSens1v2/_CG_RadSens.h | |
i2c: | |
... | |
sensor: | |
- platform: custom | |
lambda: |- | |
auto rad_sens = new MyRadSens(); | |
App.register_component(rad_sens); | |
return {rad_sens->IntensityDynamic_Sensor, rad_sens->IntensityStatic_Sensor}; | |
sensors: | |
- name: "Dynamic intensity" | |
id: dynamic_intensity | |
accuracy_decimals: 1 | |
unit_of_measurement: μR/h | |
- name: "Static intensity" | |
accuracy_decimals: 1 | |
unit_of_measurement: μR/h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "esphome.h" | |
#include "CG_RadSens.h" | |
using namespace esphome; | |
class MyRadSens: public PollingComponent { | |
public: | |
Sensor *IntensityDynamic_Sensor = new Sensor(); | |
Sensor *IntensityStatic_Sensor = new Sensor(); | |
CG_RadSens myself{RS_DEFAULT_I2C_ADDRESS}; | |
MyRadSens(): PollingComponent(5000) {} | |
void setup() override { | |
myself.init(); | |
myself.setLedState(true); | |
myself.setSensitivity(105); | |
} | |
void update() override { | |
float IntensityDynamic = myself.getRadIntensyDynamic(); | |
float IntensityStatic = myself.getRadIntensyStatic(); | |
IntensityDynamic_Sensor->publish_state(IntensityDynamic); | |
IntensityStatic_Sensor->publish_state(IntensityStatic); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment