ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
ads1xxx.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace esphome::ads1xxx {
6
7// Config register fields shared by the ADS101x, ADS111x and ADS1118
8static constexpr uint16_t CONFIG_START = 1 << 15; // reads back as 1 once the conversion is done
9static constexpr uint16_t CONFIG_DATA_RATE = 0x00E0; // all bits set is the fastest rate
10static constexpr uint16_t CONFIG_SINGLE_SHOT = 1 << 8;
11
13inline 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
uint8_t raw[35]
Definition bl0939.h:0
AlsGain501 gain
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