Skip to content

Instantly share code, notes, and snippets.

@maaad
Created October 12, 2022 20:01
Show Gist options
  • Save maaad/7135ded40c08b3e9e45755b6fa771a1b to your computer and use it in GitHub Desktop.
Save maaad/7135ded40c08b3e9e45755b6fa771a1b to your computer and use it in GitHub Desktop.
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
#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