Add esp-espnow_test_transmitter1.yaml
This commit is contained in:
@@ -0,0 +1,114 @@
|
|||||||
|
#:########################################################################################:#
|
||||||
|
# ESP-NOW Test Transmitter
|
||||||
|
#:########################################################################################:#
|
||||||
|
#
|
||||||
|
# Hardware:
|
||||||
|
# - ESP32-S3-Zero / ESP32-S3 Super Mini style board
|
||||||
|
#
|
||||||
|
# Wiring:
|
||||||
|
# - Button between GPIO4 and GND.
|
||||||
|
#
|
||||||
|
# Behaviour:
|
||||||
|
# - Sleeps most of the time.
|
||||||
|
# - Button press wakes the ESP32-S3.
|
||||||
|
# - Sends ESP-NOW broadcast 3 times.
|
||||||
|
# - Goes back to deep sleep.
|
||||||
|
#
|
||||||
|
# IMPORTANT:
|
||||||
|
# - Set espnow.channel to the same 2.4 GHz Wi-Fi channel used by the receiver.
|
||||||
|
#
|
||||||
|
#:########################################################################################:#
|
||||||
|
|
||||||
|
substitutions:
|
||||||
|
device_name: espnow-test-transmitter
|
||||||
|
friendly_name: "ESPNow Test Transmitter"
|
||||||
|
|
||||||
|
esphome:
|
||||||
|
name: ${device_name}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
|
||||||
|
on_boot:
|
||||||
|
priority: -100
|
||||||
|
then:
|
||||||
|
- logger.log: "Booted. Sending ESP-NOW test packet..."
|
||||||
|
- script.execute: send_espnow_press
|
||||||
|
- delay: 500ms
|
||||||
|
- logger.log: "Going back to deep sleep."
|
||||||
|
- deep_sleep.enter: deep_sleep_control
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
board: esp32-s3-devkitc-1
|
||||||
|
framework:
|
||||||
|
type: arduino
|
||||||
|
|
||||||
|
logger:
|
||||||
|
level: DEBUG
|
||||||
|
|
||||||
|
#:########################################################################################:#
|
||||||
|
# No Wi-Fi on transmitter
|
||||||
|
#:########################################################################################:#
|
||||||
|
#
|
||||||
|
# This keeps the transmitter fast and battery-friendly.
|
||||||
|
# Upload over USB for this test.
|
||||||
|
#
|
||||||
|
|
||||||
|
#:########################################################################################:#
|
||||||
|
# ESP-NOW Transmit
|
||||||
|
#:########################################################################################:#
|
||||||
|
|
||||||
|
espnow:
|
||||||
|
channel: 6
|
||||||
|
|
||||||
|
script:
|
||||||
|
- id: send_espnow_press
|
||||||
|
mode: single
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(press_count) += 1;
|
||||||
|
|
||||||
|
- espnow.broadcast:
|
||||||
|
data: !lambda |-
|
||||||
|
std::string msg = "REMOTE_A:BUTTON_1:" + to_string(id(press_count));
|
||||||
|
return std::vector<uint8_t>(msg.begin(), msg.end());
|
||||||
|
|
||||||
|
- delay: 50ms
|
||||||
|
|
||||||
|
- espnow.broadcast:
|
||||||
|
data: !lambda |-
|
||||||
|
std::string msg = "REMOTE_A:BUTTON_1:" + to_string(id(press_count));
|
||||||
|
return std::vector<uint8_t>(msg.begin(), msg.end());
|
||||||
|
|
||||||
|
- delay: 50ms
|
||||||
|
|
||||||
|
- espnow.broadcast:
|
||||||
|
data: !lambda |-
|
||||||
|
std::string msg = "REMOTE_A:BUTTON_1:" + to_string(id(press_count));
|
||||||
|
return std::vector<uint8_t>(msg.begin(), msg.end());
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: press_count
|
||||||
|
type: int
|
||||||
|
restore_value: true
|
||||||
|
initial_value: '0'
|
||||||
|
|
||||||
|
#:########################################################################################:#
|
||||||
|
# Wake Button and Deep Sleep
|
||||||
|
#:########################################################################################:#
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
id: wake_button
|
||||||
|
name: "Wake Button"
|
||||||
|
internal: true
|
||||||
|
pin:
|
||||||
|
number: GPIO4
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
|
||||||
|
deep_sleep:
|
||||||
|
id: deep_sleep_control
|
||||||
|
wakeup_pin:
|
||||||
|
number: GPIO4
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
sleep_duration: 365d
|
||||||
Reference in New Issue
Block a user