ESPHome 2025.5.0
Loading...
Searching...
No Matches
tmp1075.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace tmp1075 {
9
11 union {
12 struct {
13 uint8_t oneshot : 1; // One-shot conversion mode. Writing 1, starts a single temperature
14 // conversion. Read returns 0.
15
16 uint8_t rate : 2; // Conversion rate setting when device is in continuous conversion mode.
17 // 00: 27.5 ms conversion rate
18 // 01: 55 ms conversion rate
19 // 10: 110 ms conversion rate
20 // 11: 220 ms conversion rate (35 ms TMP1075N)
21
22 uint8_t faults : 2; // Consecutive fault measurements to trigger the alert function.
23 // 00: 1 fault
24 // 01: 2 faults
25 // 10: 3 faults (4 faults TMP1075N)
26 // 11: 4 faults (6 faults TMP1075N)
27
28 uint8_t polarity : 1; // Polarity of the output pin.
29 // 0: Active low ALERT pin
30 // 1: Active high ALERT pin
31
32 uint8_t alert_mode : 1; // Selects the function of the ALERT pin.
33 // 0: ALERT pin functions in comparator mode
34 // 1: ALERT pin functions in interrupt mode
35
36 uint8_t shutdown : 1; // Sets the device in shutdown mode to conserve power.
37 // 0: Device is in continuous conversion
38 // 1: Device is in shutdown mode
40 uint8_t regvalue;
41 };
42};
43
50
55
57 public:
58 void setup() override;
59 void update() override;
60
61 float get_setup_priority() const override { return setup_priority::DATA; }
62
63 void dump_config() override;
64
65 // Call write_config() after calling any of these to send the new config to
66 // the IC. The setup() function also does this.
67 void set_alert_limit_low(const float temp) { this->alert_limit_low_ = temp; }
68 void set_alert_limit_high(const float temp) { this->alert_limit_high_ = temp; }
69 void set_oneshot(const bool oneshot) { config_.fields.oneshot = oneshot; }
70 void set_conversion_rate(const enum EConversionRate rate) { config_.fields.rate = rate; }
71 void set_alert_polarity(const bool polarity) { config_.fields.polarity = polarity; }
72 void set_alert_function(const enum EAlertFunction function) { config_.fields.alert_mode = function; }
73 void set_fault_count(int faults);
74
75 void write_config();
76
77 protected:
79
80 // Disable the alert pin by default.
81 float alert_limit_low_ = -128.0f;
82 float alert_limit_high_ = 127.9375f;
83
86 void send_config_();
87 void log_config_();
88};
89
90} // namespace tmp1075
91} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
Base-class for all sensors.
Definition sensor.h:57
void set_alert_limit_high(const float temp)
Definition tmp1075.h:68
void set_alert_function(const enum EAlertFunction function)
Definition tmp1075.h:72
void set_alert_polarity(const bool polarity)
Definition tmp1075.h:71
float get_setup_priority() const override
Definition tmp1075.h:61
void set_conversion_rate(const enum EConversionRate rate)
Definition tmp1075.h:70
void set_oneshot(const bool oneshot)
Definition tmp1075.h:69
void set_fault_count(int faults)
Definition tmp1075.cpp:60
void set_alert_limit_low(const float temp)
Definition tmp1075.h:67
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
struct esphome::tmp1075::TMP1075Config::@144::@146 fields