Compare commits
No commits in common. "e7735eb27889a18295474aa0fde9b92d623f7eae" and "fe7bf189890a8bc199f0331371b1dd54187cfbfe" have entirely different histories.
e7735eb278
...
fe7bf18989
9 changed files with 1 additions and 300 deletions
137
.clang-format
137
.clang-format
|
@ -1,137 +0,0 @@
|
||||||
Language: Cpp
|
|
||||||
AccessModifierOffset: -1
|
|
||||||
AlignAfterOpenBracket: Align
|
|
||||||
AlignConsecutiveAssignments: false
|
|
||||||
AlignConsecutiveDeclarations: false
|
|
||||||
AlignEscapedNewlines: DontAlign
|
|
||||||
AlignOperands: true
|
|
||||||
AlignTrailingComments: true
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
|
||||||
AllowShortBlocksOnASingleLine: false
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: All
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AllowShortLoopsOnASingleLine: false
|
|
||||||
AlwaysBreakAfterReturnType: None
|
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
|
||||||
AlwaysBreakTemplateDeclarations: MultiLine
|
|
||||||
BinPackArguments: true
|
|
||||||
BinPackParameters: true
|
|
||||||
BraceWrapping:
|
|
||||||
AfterClass: false
|
|
||||||
AfterControlStatement: false
|
|
||||||
AfterEnum: false
|
|
||||||
AfterFunction: false
|
|
||||||
AfterNamespace: false
|
|
||||||
AfterObjCDeclaration: false
|
|
||||||
AfterStruct: false
|
|
||||||
AfterUnion: false
|
|
||||||
AfterExternBlock: false
|
|
||||||
BeforeCatch: false
|
|
||||||
BeforeElse: false
|
|
||||||
IndentBraces: false
|
|
||||||
SplitEmptyFunction: true
|
|
||||||
SplitEmptyRecord: true
|
|
||||||
SplitEmptyNamespace: true
|
|
||||||
BreakBeforeBinaryOperators: None
|
|
||||||
BreakBeforeBraces: Attach
|
|
||||||
BreakBeforeInheritanceComma: false
|
|
||||||
BreakInheritanceList: BeforeColon
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakConstructorInitializersBeforeComma: false
|
|
||||||
BreakConstructorInitializers: BeforeColon
|
|
||||||
BreakAfterJavaFieldAnnotations: false
|
|
||||||
BreakStringLiterals: true
|
|
||||||
ColumnLimit: 120
|
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
|
||||||
CompactNamespaces: false
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
DisableFormat: false
|
|
||||||
ExperimentalAutoDetectBinPacking: false
|
|
||||||
FixNamespaceComments: true
|
|
||||||
ForEachMacros:
|
|
||||||
- foreach
|
|
||||||
- Q_FOREACH
|
|
||||||
- BOOST_FOREACH
|
|
||||||
IncludeBlocks: Preserve
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^<ext/.*\.h>'
|
|
||||||
Priority: 2
|
|
||||||
- Regex: '^<.*\.h>'
|
|
||||||
Priority: 1
|
|
||||||
- Regex: '^<.*'
|
|
||||||
Priority: 2
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 3
|
|
||||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
|
||||||
IndentCaseLabels: true
|
|
||||||
IndentPPDirectives: None
|
|
||||||
IndentWidth: 2
|
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
||||||
MacroBlockBegin: ''
|
|
||||||
MacroBlockEnd: ''
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: None
|
|
||||||
PenaltyBreakAssignment: 2
|
|
||||||
PenaltyBreakBeforeFirstCallParameter: 1
|
|
||||||
PenaltyBreakComment: 300
|
|
||||||
PenaltyBreakFirstLessLess: 120
|
|
||||||
PenaltyBreakString: 1000
|
|
||||||
PenaltyBreakTemplateDeclaration: 10
|
|
||||||
PenaltyExcessCharacter: 1000000
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 2000
|
|
||||||
PointerAlignment: Right
|
|
||||||
RawStringFormats:
|
|
||||||
- Language: Cpp
|
|
||||||
Delimiters:
|
|
||||||
- cc
|
|
||||||
- CC
|
|
||||||
- cpp
|
|
||||||
- Cpp
|
|
||||||
- CPP
|
|
||||||
- 'c++'
|
|
||||||
- 'C++'
|
|
||||||
CanonicalDelimiter: ''
|
|
||||||
BasedOnStyle: google
|
|
||||||
- Language: TextProto
|
|
||||||
Delimiters:
|
|
||||||
- pb
|
|
||||||
- PB
|
|
||||||
- proto
|
|
||||||
- PROTO
|
|
||||||
EnclosingFunctions:
|
|
||||||
- EqualsProto
|
|
||||||
- EquivToProto
|
|
||||||
- PARSE_PARTIAL_TEXT_PROTO
|
|
||||||
- PARSE_TEST_PROTO
|
|
||||||
- PARSE_TEXT_PROTO
|
|
||||||
- ParseTextOrDie
|
|
||||||
- ParseTextProtoOrDie
|
|
||||||
CanonicalDelimiter: ''
|
|
||||||
BasedOnStyle: google
|
|
||||||
ReflowComments: true
|
|
||||||
SortIncludes: false
|
|
||||||
SortUsingDeclarations: false
|
|
||||||
SpaceAfterCStyleCast: true
|
|
||||||
SpaceAfterTemplateKeyword: false
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
|
||||||
SpaceBeforeCpp11BracedList: false
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
|
||||||
SpaceBeforeInheritanceColon: true
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
|
||||||
SpaceInEmptyParentheses: false
|
|
||||||
SpacesBeforeTrailingComments: 2
|
|
||||||
SpacesInAngles: false
|
|
||||||
SpacesInContainerLiterals: false
|
|
||||||
SpacesInCStyleCastParentheses: false
|
|
||||||
SpacesInParentheses: false
|
|
||||||
SpacesInSquareBrackets: false
|
|
||||||
Standard: Auto
|
|
||||||
TabWidth: 2
|
|
||||||
UseTab: Never
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,3 @@ secrets.yaml
|
||||||
.cache/
|
.cache/
|
||||||
.esphome/
|
.esphome/
|
||||||
dist/
|
dist/
|
||||||
__pycache__/
|
|
||||||
|
|
13
NOTES.md
13
NOTES.md
|
@ -1,6 +1,6 @@
|
||||||
# autohuttli nodes
|
# autohuttli nodes
|
||||||
|
|
||||||
## AtomS3 Lite
|
# AtomS3 Lite
|
||||||
|
|
||||||
<https://shop.m5stack.com/products/atoms3-lite-esp32s3-dev-kit>
|
<https://shop.m5stack.com/products/atoms3-lite-esp32s3-dev-kit>
|
||||||
|
|
||||||
|
@ -16,14 +16,3 @@ I/O:
|
||||||
- IR LED on G4
|
- IR LED on G4
|
||||||
- WS2812 LED on G35
|
- WS2812 LED on G35
|
||||||
- Port A on G1 and G2
|
- Port A on G1 and G2
|
||||||
|
|
||||||
## ADC I2C Unit v1.1 (ADS1110)
|
|
||||||
|
|
||||||
[Schematic](https://docs.m5stack.com/en/unit/Unit-ADC_V1.1)
|
|
||||||
|
|
||||||
[Datasheet](https://www.ti.com/lit/ds/symlink/ads1110.pdf)
|
|
||||||
|
|
||||||
Reference is 2.048V with a PGA of 1 to 8. Has a 510 k / 100 k voltage divider
|
|
||||||
giving a 6.1 divisor or a FSD of 12.5 V.
|
|
||||||
|
|
||||||
Changed to a 75 / 39 k divider giving 2.92 divisor or FSD of 5.99 V.
|
|
||||||
|
|
|
@ -16,11 +16,6 @@ esp32:
|
||||||
framework:
|
framework:
|
||||||
type: arduino
|
type: arduino
|
||||||
|
|
||||||
external_components:
|
|
||||||
- source:
|
|
||||||
type: local
|
|
||||||
path: components
|
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
|
|
||||||
http_request:
|
http_request:
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
#include "ads1110.h"
|
|
||||||
#include "esphome/core/log.h"
|
|
||||||
#include "esphome/core/hal.h"
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace ads1110 {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const char *const TAG = "ads1110";
|
|
||||||
|
|
||||||
constexpr uint8_t ST = 0x80;
|
|
||||||
constexpr uint8_t SC = 0x10;
|
|
||||||
constexpr uint8_t DR_240SPS = 0 << 2;
|
|
||||||
constexpr uint8_t DR_60SPS = 1 << 2;
|
|
||||||
constexpr uint8_t DR_30SPS = 2 << 2;
|
|
||||||
constexpr uint8_t DR_15SPS = 3 << 2;
|
|
||||||
constexpr uint8_t PGA_1 = 0 << 0;
|
|
||||||
constexpr uint8_t PGA_2 = 1 << 0;
|
|
||||||
constexpr uint8_t PGA_4 = 2 << 0;
|
|
||||||
constexpr uint8_t PGA_8 = 3 << 0;
|
|
||||||
constexpr uint8_t PGA_MASK = 3 << 0;
|
|
||||||
|
|
||||||
constexpr double kVref = 2.048;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void ADS1110Sensor::setup() {
|
|
||||||
uint8_t config = DR_15SPS | PGA_2;
|
|
||||||
write(&config, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ADS1110Sensor::dump_config() {
|
|
||||||
LOG_SENSOR("", "ADS1110", this);
|
|
||||||
LOG_I2C_DEVICE(this);
|
|
||||||
LOG_UPDATE_INTERVAL(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ADS1110Sensor::update() {
|
|
||||||
uint8_t data[3];
|
|
||||||
if (read(data, sizeof(data)) == i2c::NO_ERROR && (data[2] & ST) == 0) {
|
|
||||||
int16_t code = static_cast<int16_t>((data[0] << 8) | data[1]);
|
|
||||||
double scale = kVref / 32768;
|
|
||||||
scale /= 1 << (data[2] & PGA_MASK);
|
|
||||||
this->publish_state(code * scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ads1110
|
|
||||||
} // namespace esphome
|
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "esphome/components/i2c/i2c.h"
|
|
||||||
#include "esphome/components/sensor/sensor.h"
|
|
||||||
#include "esphome/core/automation.h"
|
|
||||||
#include "esphome/core/component.h"
|
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace ads1110 {
|
|
||||||
|
|
||||||
class ADS1110Sensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
|
||||||
public:
|
|
||||||
void setup() override;
|
|
||||||
void update() override;
|
|
||||||
void dump_config() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ads1110
|
|
||||||
} // namespace esphome
|
|
|
@ -1,31 +0,0 @@
|
||||||
from esphome import automation
|
|
||||||
from esphome.automation import maybe_simple_id
|
|
||||||
import esphome.codegen as cg
|
|
||||||
from esphome.components import i2c, sensor
|
|
||||||
import esphome.config_validation as cv
|
|
||||||
from esphome.const import CONF_GAIN, CONF_ID, ICON_SCALE, STATE_CLASS_MEASUREMENT
|
|
||||||
|
|
||||||
CODEOWNERS = ["michaelh@juju.nz"]
|
|
||||||
DEPENDENCIES = ["i2c"]
|
|
||||||
|
|
||||||
ads1110_ns = cg.esphome_ns.namespace("ads1110")
|
|
||||||
ADS1110Sensor = ads1110_ns.class_(
|
|
||||||
"ADS1110Sensor", sensor.Sensor, cg.PollingComponent, i2c.I2CDevice
|
|
||||||
)
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = (
|
|
||||||
sensor.sensor_schema(
|
|
||||||
ADS1110Sensor,
|
|
||||||
accuracy_decimals=3,
|
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
|
||||||
)
|
|
||||||
.extend(cv.polling_component_schema("60s"))
|
|
||||||
.extend(i2c.i2c_device_schema(0x48))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
|
||||||
await cg.register_component(var, config)
|
|
||||||
await i2c.register_i2c_device(var, config)
|
|
||||||
await sensor.register_sensor(var, config)
|
|
44
pumper.yaml
44
pumper.yaml
|
@ -1,44 +0,0 @@
|
||||||
substitutions:
|
|
||||||
device_name: Pump monitor
|
|
||||||
device_id: pumper
|
|
||||||
project_name: juju.pumper
|
|
||||||
project_version: "0.1"
|
|
||||||
|
|
||||||
packages:
|
|
||||||
pumper:
|
|
||||||
i2c:
|
|
||||||
sda: 2
|
|
||||||
scl: 1
|
|
||||||
scan: true
|
|
||||||
frequency: 400kHz
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
- platform: ads1110
|
|
||||||
id: pressure_v
|
|
||||||
name: "Raw sensor"
|
|
||||||
unit_of_measurement: V
|
|
||||||
device_class: voltage
|
|
||||||
update_interval: 4s
|
|
||||||
filters:
|
|
||||||
- multiply: 2.92 # (75 + 39) / 39
|
|
||||||
- exponential_moving_average:
|
|
||||||
alpha: 0.1
|
|
||||||
send_every: 5
|
|
||||||
on_value:
|
|
||||||
- sensor.template.publish:
|
|
||||||
id: head
|
|
||||||
state: !lambda 'return id(pressure_v).state;'
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
id: head
|
|
||||||
name: "Head"
|
|
||||||
unit_of_measurement: m
|
|
||||||
device_class: distance
|
|
||||||
icon: mdi:water
|
|
||||||
accuracy_decimals: 3
|
|
||||||
filters:
|
|
||||||
- calibrate_linear:
|
|
||||||
- 0.5 -> 0
|
|
||||||
- 4.5 -> 10.55 # 15 PSI
|
|
||||||
|
|
||||||
<<: !include atoms3_lite.yaml
|
|
Loading…
Reference in a new issue