Skip to content

Instantly share code, notes, and snippets.

@NateEaton
Created April 6, 2024 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NateEaton/8055f65af0698c83c18e9c3d4bd4e4a5 to your computer and use it in GitHub Desktop.
Save NateEaton/8055f65af0698c83c18e9c3d4bd4e4a5 to your computer and use it in GitHub Desktop.
Data Collection Components for Total Solar Eclipse using ESPHOME and Home Assistant
esphome:
name: "magnetometer"
friendly_name: "magnetometer"
esp32:
board: seeed_xiao_esp32c3
variant: esp32c3
framework:
type: arduino
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: "[private]"
ota:
password: "[private]"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Magnetometer Fallback Hotspot"
password: "[private]"
captive_portal:
i2c:
sda: GPIO6
scl: GPIO7
scan: true
id: bus_a
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: qmc5883l
id: magnetometer
address: 0x0D
field_strength_x:
name: "X Axis"
id: magnetometer_x
filters:
delta: 1.0
field_strength_y:
name: "Y Axis"
id: magnetometer_y
filters:
delta: 1.0
field_strength_z:
name: "Z Axis"
id: magnetometer_z
filters:
delta: 1.0
heading:
name: "Heading"
range: 800uT # Need to test with 800
oversampling: 512x
update_interval: 60sec
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
- platform: uptime
name: "Uptime"
update_interval: 60s
entity_category: "diagnostic"
binary_sensor:
- platform: template
name: "High Speed Update"
id: high_speed_update
lambda: |-
return id(high_speed_update).state;
- platform: status
name: "Connectivity Status"
id: connectivity_status
device_class: connectivity
switch:
- platform: template
name: "High Speed Update Switch"
restore_mode: ALWAYS_OFF
lambda: |-
return id(high_speed_update).state;
turn_on_action:
- binary_sensor.template.publish:
id: high_speed_update
state: ON
- logger.log: High Speed Update Switched On
turn_off_action:
- binary_sensor.template.publish:
id: high_speed_update
state: OFF
- logger.log: High Speed Update Switched Off
interval:
- interval: 100ms # Need to test with subsecond intervals
then:
- if:
condition:
lambda: 'return id(high_speed_update).state;'
then:
- component.update: magnetometer
text_sensor:
- platform: version
name: "Version"
icon: mdi:cube-outline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment