mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
XIAO STM32C5 nodes: IMU levelling (offsets on the node), 200 ms inclinometer; node 0x20 = keypad prototype: ByteButton as PKP 2400SI (node 0x14), 8Encoder entities with remote LED colours, position bar and switch LED
This commit is contained in:
1 parent
0da0cd1544
commit
8aee65e697
2 files changed
+326
-5
No files matched your search
@@ -28,6 +28,8 @@ logger:
|
||||
logs:
|
||||
# canbus logs every frame at DEBUG; over USB CDC that stalls the loop and the RX queue overflows
|
||||
canbus: INFO
|
||||
# the same for pitch/roll every 200 ms
|
||||
sensor: INFO
|
||||
|
||||
i2c:
|
||||
# pins come from the board DTS (i2c2: PB3/PB4), STM32C5 takes no sda:/scl:
|
||||
@@ -39,22 +41,69 @@ motion:
|
||||
id: imu
|
||||
i2c_id: i2c_imu
|
||||
address: 0x6A
|
||||
update_interval: 5s
|
||||
# a live inclinometer (maptool's dashboard / Terrain view) needs 100-200 ms
|
||||
update_interval: 200ms
|
||||
|
||||
sensor:
|
||||
- platform: lsm6ds
|
||||
id: imu_temp
|
||||
name: IMU Temperature
|
||||
# Levelled by the node itself (the mounting error belongs to the sensor, every reader of the bus gets it
|
||||
# corrected): raw = state + offset, so levelling again adds to the offsets
|
||||
- platform: motion
|
||||
motion_id: imu
|
||||
id: pitch
|
||||
type: pitch
|
||||
name: Pitch
|
||||
filters:
|
||||
- lambda: return x - id(pitch_offset).state;
|
||||
- platform: motion
|
||||
motion_id: imu
|
||||
id: roll
|
||||
type: roll
|
||||
name: Roll
|
||||
filters:
|
||||
- lambda: return x - id(roll_offset).state;
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
id: pitch_offset
|
||||
name: Pitch Offset
|
||||
entity_category: config
|
||||
unit_of_measurement: "°"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: 0
|
||||
min_value: -45
|
||||
max_value: 45
|
||||
step: 0.01
|
||||
- platform: template
|
||||
id: roll_offset
|
||||
name: Roll Offset
|
||||
entity_category: config
|
||||
unit_of_measurement: "°"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: 0
|
||||
min_value: -45
|
||||
max_value: 45
|
||||
step: 0.01
|
||||
|
||||
# canopen_entities has no button: a switch that turns itself back off. On uneven ground: level, turn the car
|
||||
# 180° on the same spot, level again and take the mean (maptool writes the offsets for that)
|
||||
switch:
|
||||
- platform: template
|
||||
id: level_imu
|
||||
name: Level IMU
|
||||
entity_category: config
|
||||
lambda: return false;
|
||||
turn_on_action:
|
||||
- lambda: |-
|
||||
if (std::isnan(id(pitch).state) || std::isnan(id(roll).state))
|
||||
return;
|
||||
id(pitch_offset).make_call().set_value(id(pitch_offset).state + id(pitch).state).perform();
|
||||
id(roll_offset).make_call().set_value(id(roll_offset).state + id(roll).state).perform();
|
||||
ESP_LOGI("level", "levelled: pitch offset %.2f, roll offset %.2f", id(pitch_offset).state, id(roll_offset).state);
|
||||
|
||||
output:
|
||||
- platform: gpio
|
||||
@@ -80,11 +129,12 @@ canbus:
|
||||
# an SDO block (16 frames) arrives back to back and must fit the RX queue (default 8)
|
||||
rx_buffer_size: 32
|
||||
|
||||
# a list, so a node file can add a second local node (e.g. a PKP keypad emulation)
|
||||
canopen:
|
||||
id: can_gate
|
||||
canbus_id: can_bus
|
||||
node_id: ${node_id}
|
||||
heartbeat_interval: 5s
|
||||
- id: can_gate
|
||||
canbus_id: can_bus
|
||||
node_id: ${node_id}
|
||||
heartbeat_interval: 5s
|
||||
|
||||
canopen_entities:
|
||||
canopen_id: can_gate
|
||||
@@ -111,11 +161,20 @@ canopen_entities:
|
||||
size: 2
|
||||
min_value: -40
|
||||
max_value: 125
|
||||
# levelling (maptool /can.html): Level IMU = SDO 0x2022:1 <- 1; offsets REAL32, state 0x2101 / 0x2111,
|
||||
# command 0x2102:1 / 0x2112:1. 16/17: the nodes' own entities are 6..15
|
||||
- id: level_imu
|
||||
index: 2
|
||||
- id: pitch_offset
|
||||
index: 16
|
||||
- id: roll_offset
|
||||
index: 17
|
||||
remote_logs:
|
||||
level: INFO
|
||||
|
||||
ota:
|
||||
- platform: canopen_entities
|
||||
canopen_id: can_gate
|
||||
# the XIAO's board layout has slot0 one sector larger than slot1 (swap-move); with the fork's default
|
||||
# (offset) MCUboot finds the slots incompatible and never installs the update
|
||||
swap_method: move
|
||||
|
||||
Reference in new issue
Block a user