ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
am2315c.h
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023-2024 Rob Tillaart
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22#pragma once
23
27
28namespace esphome::am2315c {
29
30class AM2315C final : public PollingComponent, public i2c::I2CDevice {
31 SUB_SENSOR(temperature)
32 SUB_SENSOR(humidity)
33
34 public:
35 void dump_config() override;
36 void update() override;
37 void setup() override;
38
39 protected:
40 bool convert_(uint8_t *data, float &humidity, float &temperature);
41 bool reset_register_(uint8_t reg);
42};
43
44} // namespace esphome::am2315c
virtual void dump_config()
This class simplifies creating components that periodically check a state.
Definition component.h:532
bool convert_(uint8_t *data, float &humidity, float &temperature)
Definition am2315c.cpp:63
bool reset_register_(uint8_t reg)
Definition am2315c.cpp:31
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
uint16_t temperature
Definition sun_gtil2.cpp:12