ESPHome
2026.12.0-dev
Loading...
Searching...
No Matches
esphome
components
ads1xxx
ads1xxx.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
esphome::ads1xxx
{
6
7
// Config register fields shared by the ADS101x, ADS111x and ADS1118
8
static
constexpr
uint16_t CONFIG_START = 1 << 15;
// reads back as 1 once the conversion is done
9
static
constexpr
uint16_t CONFIG_DATA_RATE = 0x00E0;
// all bits set is the fastest rate
10
static
constexpr
uint16_t CONFIG_SINGLE_SHOT = 1 << 8;
11
13
inline
float
to_volts
(int16_t
raw
, uint16_t config) {
14
const
uint8_t
gain
= (config >> 9) & 0b111;
15
// Volts per count: 6.144 V full scale for gain 0, else 8.192 V >> gain
16
return
raw
* (
gain
? 0.00025f : 0.0001875f) / (1 <<
gain
);
17
}
18
19
}
// namespace esphome::ads1xxx
raw
uint8_t raw[35]
Definition
bl0939.h:0
gain
AlsGain501 gain
Definition
ltr_definitions_501.h:3
esphome::ads1xxx
Definition
ads1xxx.h:5
esphome::ads1xxx::to_volts
float to_volts(int16_t raw, uint16_t config)
Volts for a conversion result taken with the gain field of config; 12-bit results are left-justified.
Definition
ads1xxx.h:13
Generated by
1.12.0