ESPHome-Konfigs für CC1101-Funksender/-empfänger inkl. Flash-Anleitung
- Sender (ESP32-C3 Super Mini) und Empfänger (ESP32-S3), beide mit CC1101 433 MHz - README dokumentiert USB-TTL-Anschluss, da der interne USB-Serial/JTAG nach Zadig unter Windows 11 nicht mehr nutzbar ist - Verdrahtungsschema CC1101 als SVG
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
esphome:
|
||||
name: tor-empfaenger
|
||||
friendly_name: Tor Empfänger
|
||||
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1 # <- ggf. an dein Board anpassen
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
logger:
|
||||
|
||||
api:
|
||||
encryption:
|
||||
key: !secret api_key
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: !secret ota_password
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# --- SPI zum CC1101 ---
|
||||
# Diese Pins am S3 prüfen und ggf. anpassen!
|
||||
spi:
|
||||
clk_pin: GPIO12
|
||||
mosi_pin: GPIO11
|
||||
miso_pin: GPIO13
|
||||
|
||||
cc1101:
|
||||
cs_pin: GPIO10
|
||||
gdo0_pin: GPIO9
|
||||
frequency: 433.92MHz
|
||||
modulation_type: GFSK
|
||||
symbol_rate: 4800
|
||||
packet_mode: true
|
||||
packet_length: 4
|
||||
crc_enable: true
|
||||
sync0: 0x91
|
||||
sync1: 0xD3
|
||||
on_packet:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Magic-Bytes prüfen
|
||||
if (x.size() < 3 || x[0] != 0xA7 || x[1] != 0x3C) return;
|
||||
|
||||
uint8_t fz = x[2];
|
||||
ESP_LOGI("tor", "Fahrzeug %u, RSSI %.1f dBm, LQI %u", fz, rssi, lqi);
|
||||
|
||||
// Reichweite: nur öffnen wenn Signal stark genug (= Auto nah)
|
||||
if (rssi < id(rssi_schwelle).state) return;
|
||||
|
||||
// erlaubte Fahrzeuge
|
||||
if (fz < 1 || fz > 10) {
|
||||
ESP_LOGW("tor", "Unbekannte Fahrzeug-ID: %u", fz);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sperrzeit, damit das Tor nicht dauernd getriggert wird
|
||||
uint32_t jetzt = millis();
|
||||
if (id(letzte_oeffnung) != 0 && (jetzt - id(letzte_oeffnung)) < 60000) return;
|
||||
id(letzte_oeffnung) = jetzt;
|
||||
|
||||
ESP_LOGI("tor", "Tor öffnen für Fahrzeug %u (RSSI %.1f)", fz, rssi);
|
||||
id(letztes_fahrzeug).publish_state(std::to_string(fz));
|
||||
id(tor_impuls).press();
|
||||
|
||||
globals:
|
||||
- id: letzte_oeffnung
|
||||
type: uint32_t
|
||||
restore_value: false
|
||||
initial_value: '0'
|
||||
|
||||
# --- RSSI-Schwelle, in HA per Schieberegler einstellbar ---
|
||||
# Je näher an 0, desto kürzer die Reichweite.
|
||||
# Startwert -60 entspricht grob 5 m — beim Einrichten im Log ablesen und anpassen.
|
||||
number:
|
||||
- platform: template
|
||||
name: RSSI Schwelle
|
||||
id: rssi_schwelle
|
||||
min_value: -100
|
||||
max_value: -20
|
||||
step: 1
|
||||
initial_value: -60
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
unit_of_measurement: dBm
|
||||
entity_category: config
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: Letztes Fahrzeug
|
||||
id: letztes_fahrzeug
|
||||
|
||||
# --- Torimpuls: Relais 500 ms schließen ---
|
||||
switch:
|
||||
- platform: gpio
|
||||
id: tor_relais
|
||||
pin: GPIO7 # <- an deine Relais-Verdrahtung anpassen
|
||||
restore_mode: ALWAYS_OFF
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: Tor Impuls
|
||||
id: tor_impuls
|
||||
on_press:
|
||||
- switch.turn_on: tor_relais
|
||||
- delay: 500ms
|
||||
- switch.turn_off: tor_relais
|
||||
Reference in New Issue
Block a user