Initial version

This commit is contained in:
Airy André
2020-02-09 10:01:19 +01:00
commit 6da6845416
2 changed files with 153 additions and 0 deletions

9
README.md Normal file
View File

@@ -0,0 +1,9 @@
Additional components to use esphome with a M5StickC
Mostly a work in progress - this compoe
- axp192 : power management - configuration hard coded for the M5StickC - should be made more generic
Must be present to initialize the screen power
Can be also used to read some of the power info - most sensors aren't published yet
Mostly the AXP192 from M5Stack sample code adapted for esphome
- st7735 : TFT screen - configuration hard coded for the M5StickC - should be made more generic
Adapted from https://github.com/musk95/esphome-1/tree/dev/esphome/components/st7789v + M5StickC sample code for the init

144
m5stickc.yaml Normal file
View File

@@ -0,0 +1,144 @@
substitutions:
devicename: m5stick
upper_devicename: M5StickC
esphome:
name: $devicename
platform: ESP32
board: m5stick-c
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: $devicename Fallback Hotspot
password: !secret wifi_password
captive_portal:
logger:
api:
ota:
web_server:
binary_sensor:
- platform: gpio
pin:
number: GPIO37
inverted: true
name: ${upper_devicename} Button A
on_press:
then:
- light.turn_on: led1
on_release:
then:
- light.turn_off: led1
- platform: gpio
pin:
number: GPIO39
inverted: true
name: ${upper_devicename} Button B
on_press:
then:
- light.turn_on: led1
on_release:
then:
- light.turn_off: led1
# AXP192 power management - must be present to initialize TFT power on
sensor:
- platform: axp192
address: 0x34
i2c_id: bus_a
update_interval: 30s
battery_level:
name: "M5Stick Battery Level"
id: "m5stick_batterylevel"
- platform: wifi_signal
name: ${upper_devicename} WiFi Signal
id: wifi_dbm
- platform: uptime
name: ${upper_devicename} Uptime
# internal LED
light:
- platform: monochromatic
output: builtin_led
name: ${upper_devicename} Led
id: led1
output:
- platform: ledc
pin: 10
inverted: true
id: builtin_led
# internal IR Transmitter
remote_transmitter:
- pin:
number: GPIO9
carrier_duty_percent: 50%
id: internal
spi:
clk_pin: GPIO13
mosi_pin: GPIO15
i2c:
- id: bus_a
sda: GPIO21
scl: GPIO22
scan: True
- id: bus_b
sda: GPIO34
scl: GPIO0
scan: True
font:
- file: 'aria.ttf'
id: font1
size: 8
- file: 'aria.ttf'
id: font2
size: 36
- file: 'arial.ttf'
id: font3
size: 14
# builtin 80x160 TFT
display:
- platform: st7735
cs_pin: GPIO5
dc_pin: GPIO23
reset_pin: GPIO18
rotation: 270
lambda: |-
it.print(80, 0, id(font1), ST77XX_WHITE, TextAlign::TOP_CENTER, "M5Stick Test");
if (id(wifi_dbm).has_state()) {
char str[128];
sprintf(str, "%.0f dBm", id(wifi_dbm).state);
it.print(80, 40, id(font2), ST77XX_RED, TextAlign::CENTER, str);
//it.print(80, 40, id(font2), ST77XX_RED, TextAlign::CENTER, "%.0f dBm", id(wifi_dbm).state);
} else {
it.print(80, 40, id(font2), ST77XX_RED, TextAlign::CENTER, "No Wifi");
}
// Print time in HH:MM format
it.strftime(80, 60, id(font3), ST77XX_BLUE, TextAlign::TOP_CENTER, "%H:%M", id(sntp_time).now());
time:
- platform: homeassistant
id: homeassistant_time
- platform: sntp
id: sntp_time