Files
NFC-University-Gate-Access-…/Readme.md
2026-02-20 04:52:40 +01:00

215 lines
8.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🏷️ Terminal Bramy RFID (ESP32 + Home Assistant)
![ESPHome](https://img.shields.io/badge/ESPHome-Compatible-blue)
![Home Assistant](https://img.shields.io/badge/Home%20Assistant-Integrated-41BDF5)
![ESP32](https://img.shields.io/badge/ESP32-DevKit%20V1-red)
![License MIT](https://img.shields.io/badge/License-MIT-green)
![Power Optimized](https://img.shields.io/badge/Optimized-80MHz%20Underclock-orange)
Inteligentny terminal RFID do sterowania bramą z wykorzystaniem **ESP32**, **RC522**, **OLED SSD1306** oraz **Home Assistant**.
---
# 🚀 Szybki start
Konfiguracja
W pliku `secrets.yaml` zdefiniuj:
- `wifi_ssid`
- `wifi_password`
- `api_encryption_key`
- `ota_password`
Pomocnik
Utwórz w Home Assistant encję:
input_text.terminal_status
Instalacja
1. Skompiluj projekt w ESPHome
2. Wgraj na ESP32
3. System automatycznie obniży taktowanie do **80 MHz** (oszczędzanie energii)
Tagi
1. Zeskanuj kartę
2. W Home Assistant → **Tagi**
3. Nazwij tag zaczynając od:
Legitymacja
Np Legitymacja Jan Kowalski
---
# 🏗️ Architektura systemu
System działa w modelu **KlientSerwer**.
### Warstwa sprzętowa
- ESP32
- RFID RC522 (SPI)
- OLED SSD1306 (I2C)
### Warstwa logiczna
- Home Assistant weryfikuje tag
- Komunikacja przez Native API (AES-128)
### Optymalizacja
- Lokalny fallback wyświetlania
- Underclocking 80 MHz
- Light Sleep WiFi
---
# 💻 Wymagania sprzętowe
| Element | Model |
|----------|--------|
| Mikrokontroler | ESP32 DevKit V1 |
| RFID | RC522 13.56 MHz |
| Wyświetlacz | OLED SSD1306 128x64 |
| Zasilanie | 18650 3.7V lub 5V DC |
| Pasywa | 2× Rezystor 220Ω, Przekaźnik 5V |
---
# 🔌 Pinout
| Moduł | Pin | ESP32 GPIO | Opis |
|--------|------|-------------|------|
| RC522 | VCC | 3.3V | ⚠ NIE 5V |
| RC522 | RST | GPIO 4 | Reset |
| RC522 | GND | GND | Masa |
| RC522 | MISO | GPIO 19 | SPI |
| RC522 | MOSI | GPIO 23 | SPI |
| RC522 | SCK | GPIO 18 | SPI |
| RC522 | SDA | GPIO 5 | SPI CS |
| OLED | SDA | GPIO 21 | I2C |
| OLED | SCL | GPIO 22 | I2C |
| Przekaźnik | IN | GPIO 13 | Sterowanie |
| LED Zielona | + | GPIO 12 | 220Ω |
| LED Czerwona | + | GPIO 14 | |
---
---
# 📝 Kod ESPHome (`czytnik-brama.yaml`)
```yaml
esphome:
name: terminal-brama
platformio_options:
board_build.f_cpu: 80000000L
esp32:
board: esp32dev
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: LIGHT
fast_connect: true
api:
reboot_timeout: 0s
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
logger:
level: INFO
i2c:
sda: 21
scl: 22
spi:
clk_pin: 18
mosi_pin: 23
miso_pin: 19
rc522_spi:
cs_pin: 5
reset_pin: 4
update_interval: 500ms
on_tag:
then:
- homeassistant.tag_scanned: !lambda 'return x;'
switch:
- platform: gpio
pin: 13
id: przekaznik_bramy
restore_mode: ALWAYS_OFF
```
---
---
# 🤖Automatyzacja Home Assistant (automations.yaml)
```yaml
alias: "Terminal Bramy - Obsługa"
trigger:
- platform: event
event_type: tag_scanned
action:
- variables:
v_nazwa: "{{ trigger.event.data.name }}"
- choose:
- conditions:
- condition: template
value_template: "{{ v_nazwa is not none and 'Legitymacja' in v_nazwa }}"
sequence:
- action: input_text.set_value
target:
entity_id: input_text.terminal_status
data:
value: "{{ v_nazwa | replace('Legitymacja ', '') | trim }}"
- action: switch.turn_on
target:
entity_id: switch.terminal_brama_przekaznik_bramy
- conditions:
- condition: template
value_template: "{{ v_nazwa is none or 'Legitymacja' not in v_nazwa }}"
sequence:
- action: input_text.set_value
target:
entity_id: input_text.terminal_status
data:
value: "Brak Uprawnień"
mode: restart
```
---
# 🔒 Bezpieczeństwo
🔐 Szyfrowanie AES-128 (Native API)
📴 Fail-safe (brama domyślnie zamknięta)
🌐 Zalecane HTTPS dla zdalnego HA
🔋 Optymalizacja:
Underclocking 80 MHz
WiFi Light Sleep
OLED auto-off po 60 sek
---
# 📄 Licencja
Projekt udostępniony na licencji MIT.
Możesz używać w projektach prywatnych i komercyjnych.