Last active
January 24, 2024 17:13
-
-
Save deosrc/5861d64e8a81fea78dc3e46ed2a12822 to your computer and use it in GitHub Desktop.
ESPHome WIP Config for Adafruit MagTag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Common Sensors | |
binary_sensor: | |
- platform: status | |
name: "${device_name} Status" | |
# System | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
domain: !secret lan_domain | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: $device_name | |
password: !secret wifi_password | |
ota: | |
password: !secret ota_password | |
logger: | |
baud_rate: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
device_id: office-magtag | |
device_name: Office MagTag | |
# Device Details | |
esphome: | |
name: $device_id | |
esp32: | |
board: adafruit_magtag29_esp32s2 | |
framework: | |
type: arduino | |
# Common | |
packages: | |
base: !include base_modified.yaml | |
mqtt: !include mqtt.yaml | |
switch: | |
- platform: gpio | |
pin: | |
number: GPIO21 | |
inverted: yes | |
name: ${device_name} Aux Power # Used for LEDs and Light Sensor | |
restore_mode: ALWAYS_ON | |
internal: true # Don't export this, just leave it always on | |
# Lights | |
light: | |
- id: header_lights | |
platform: neopixelbus | |
type: GRB | |
variant: WS2811 | |
pin: GPIO1 | |
num_leds: 4 | |
name: "NeoPixel" | |
effects: | |
- pulse: | |
- random: | |
- strobe: | |
- addressable_rainbow: | |
- addressable_color_wipe: | |
- addressable_scan: | |
- addressable_twinkle: | |
- addressable_random_twinkle: | |
- addressable_fireworks: | |
- platform: status_led | |
name: ${device_name} Status LED | |
pin: GPIO13 | |
# Light Sensor | |
# FIXME: src/esphome/components/adc/adc_sensor.cpp:65:21: error: 'ADC_WIDTH_BIT_12' was not declared in this scope | |
# sensor: | |
# - platform: adc | |
# pin: A3 | |
# name: ${device_name} Light Sensor | |
# Buttons | |
binary_sensor: | |
- name: Button Left | |
platform: gpio | |
internal: true | |
pin: | |
number: GPIO15 | |
inverted: true | |
mode: | |
input: true | |
pullup: true | |
- name: Button Up | |
platform: gpio | |
internal: true | |
pin: | |
number: GPIO14 | |
inverted: true | |
mode: | |
input: true | |
pullup: true | |
- name: Button for Light | |
platform: gpio | |
pin: | |
number: GPIO12 | |
inverted: true | |
mode: | |
input: true | |
pullup: true | |
- name: Button Right | |
platform: gpio | |
internal: true | |
pin: | |
number: GPIO11 | |
inverted: true | |
mode: | |
input: true | |
pullup: true | |
# Display | |
font: | |
- file: | |
type: gfonts | |
family: Ubuntu | |
id: font_default | |
size: 12 | |
spi: | |
clk_pin: GPIO36 | |
mosi_pin: GPIO35 | |
miso_pin: GPIO37 | |
display: | |
- id: device_display | |
platform: waveshare_epaper | |
cs_pin: GPIO8 | |
dc_pin: GPIO7 | |
busy_pin: GPIO5 | |
reset_pin: GPIO6 | |
model: gdey029t94 | |
update_interval: 60s | |
rotation: 270 | |
lambda: |- | |
it.print(0, 0, id(font_default), "Hello World!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
broker: !secret mqtt_host | |
username: esphome | |
password: !secret mqtt_password | |
client_id: $device_id | |
topic_prefix: | |
esphome/${device_id} |
The speaker also works:
# Based on https://esphome.io/components/output/ledc # and https://esphome.io/components/rtttl.html output: - platform: ledc id: spk_out pin: GPIO17 rtttl: output: spk_out id: speaker on_finished_playback: - switch.turn_off: speaker_powerI am using
deep_sleep
and before entering sleep the power to the LEDs, light sensor, and speakers can be automatically turned off using:esphome: # https://esphome.io/components/esphome # [...] on_shutdown: priority: 700 then: - switch.turn_off: neopixel_power - switch.turn_off: speaker_powerAnother thing that works is to power on/off the LEDs automatically:
light: - platform: fastled_clockless #[...] on_turn_on: - switch.turn_on: neopixel_power on_turn_off: - switch.turn_off: neopixel_power
Can you elaborate on what you are using to define 'speaker_power'?
Can you elaborate on what you are using to define
speaker_power
?
This is the pin that powers the audio amplifier:
switch:
- platform: gpio
name: NeoPixel Power # Used for LEDs and Light Sensor
pin:
number: GPIO21
inverted: yes
id: neopixel_power
internal: true # Don't export this
- platform: gpio
name: Speaker Power # Used for Speaker amplifier
pin:
number: GPIO16
id: speaker_power
internal: true # Don't export this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting. I also got the light sensor and VBAT measurement to work:
The I2C is also correctly scanned:
The speaker also works:
I am using
deep_sleep
and before entering sleep the power to the LEDs, light sensor, and speakers can be automatically turned off using:Another thing that works is to power on/off the LEDs automatically: