Skip to content

Instantly share code, notes, and snippets.

@andrew-codechimp
Created January 26, 2024 15:15
Show Gist options
  • Save andrew-codechimp/e384e351e22925f711bd73676fec66b1 to your computer and use it in GitHub Desktop.
Save andrew-codechimp/e384e351e22925f711bd73676fec66b1 to your computer and use it in GitHub Desktop.
M5 Matrix EspHome example
# M5 Atom Matrix Configuration for m5atom01 which is an M5Stack Atom Matrix
# ESP32 Pico, 8x8 RGB LED Matrix (WS2812C), Infra-red LED,
# MPU6886 Inertial Sensor - 6-axis attitude sensor with 3-axis gravity accelerometer and 3-axis gyroscope
# Pins/GPIO
#
# === M5Stack Atom Matrix Specific ===
# @see https://github.com/m5stack/M5Stack/blob/31be29f3f743768778accb8d5f308583ba4d3d4c/src/utility/Config.h
# @see https://docs.m5stack.com/#/en/core/atom_matrix
# ------ Buttons ------
# BUTTON_PIN | 39 | Under LED's and on side - both are the same button
# ------ RGB LEDs PIN ------
# RGB_PIN | 27 | 8x8 matrix, WS2812C
# ------ Infra-Red LED PIN ------
# INFRA_PIN | 12 |
# -------- I2C ---------
# SDA | 25 |
# SCL | 21 |
#
# MPU6886 Inertial Sensor - I2C Address 0x68
#
# ---- Exposed Ports ----
# -- | 3V3 | 5-pin connector pin 1
# 19 | Tx | 5-pin connector pin 3
# 22 | Rx | 5-pin connector pin 2
# 23 | Neo | 5-pin connector pin 4 (Connected to 34 via 100ohm resistor?)
# 33 | Adc | 5-pin connector pin 5
#
# 21 | SCL | 4-pin connector pin 1
# 25 | SDA | 4-pin connector pin 2
# -- | 5V | 4-pin connector pin 3
# -- | Gnd | 4-pin connector pin 4
#
# -- | Gnd | Grove connector pin 1
# -- | 5V | Grove connector pin 2
# 26 | | Grove connector pin 3
# 32 | | Grove connector pin 4
#
#
substitutions:
devicename: esphm5matrix01
upper_devicename: esphM5Matrix01
esphome:
name: ${devicename}
esp32:
board: m5stack-atom
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${upper_devicename}
password: !secret ap_password
captive_portal:
# Define I2C interface
i2c:
sda: 25
scl: 21
scan: true
binary_sensor:
- platform: gpio # btn
id: button
name: "$upper_devicename Button"
pin:
number: 39
inverted: true
light:
- platform: neopixelbus
name: "$upper_devicename 5x5 Matrix"
id: matrix_light
variant: WS2812
pin: 27
num_leds: 25
type: GRB
color_correct: [50%, 50%, 50%] # The LED's on the Atom Matrix should not be run at full power
effects:
- addressable_rainbow:
name: "Rainbow"
- strobe:
name: "Strobe"
colors:
- state: true
brightness: 50%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 50%
red: 0%
green: 100%
blue: 0%
duration: 500ms
sensor:
- platform: adc
pin:
number: 32
id: battery
name: "$upper_devicename Battery"
update_interval: 5s
attenuation: 11db
device_class: battery
unit_of_measurement: '%'
accuracy_decimals: 0
filters:
- calibrate_linear:
method: least_squares
datapoints:
- 0.14200 -> 0
- 3.14500 -> 100
- lambda: return 100 - x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment