Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: lora-1
- friendly_name: lora-1
- esp32:
- board: esp32dev
- framework:
- type: arduino
- # Enable logging
- logger:
- level: VERY_VERBOSE
- # Enable Home Assistant API
- api:
- encryption:
- key: ""
- ota:
- - platform: esphome
- password: ""
- - platform: web_server
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- use_address: 192.168.68.75
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: ""
- password: ""
- web_server:
- port: 80
- version: 3
- include_internal: true
- local: true
- spi:
- clk_pin: GPIO5
- mosi_pin: GPIO27
- miso_pin: GPIO19
- # CONFIGURAZIONE LORA COMPONENTE SX 1276
- sx127x:
- dio0_pin: GPIO26
- cs_pin: GPIO18
- rst_pin: GPIO23 # verificare versione scheda
- pa_pin: BOOST
- pa_power: 17
- bandwidth: 125_0kHz
- crc_enable: true
- frequency: 433920000
- modulation: LORA
- rx_start: true
- sync_value: 0x12
- spreading_factor: 7
- coding_rate: CR_4_5
- preamble_size: 6
- on_packet:
- then:
- - lambda: |-
- ESP_LOGD("lambda", "packet %s", format_hex(x).c_str());
- ESP_LOGD("lambda", "rssi %.2f", rssi);
- ESP_LOGD("lambda", "snr %.2f", snr);
- id(last_rssi) = rssi;
- id(lora_packet_count) += 1;
- ESP_LOGI("lora", "Pacchetto ricevuto. Totale: %d", id(lora_packet_count));
- id(lora_sent_count) += 1;
- ESP_LOGI("lora", "Pacchetto inviato. Totale: %d", id(lora_sent_count));
- globals:
- - id: last_rssi
- type: float
- restore_value: no
- initial_value: '0.0'
- - id: lora_packet_count
- type: int
- restore_value: no # se vuoi mantenere il conteggio dopo il riavvio
- initial_value: '0'
- - id: lora_sent_count
- type: int
- restore_value: no # mantiene il conteggio al riavvio
- initial_value: '0'
- packet_transport:
- platform: sx127x
- update_interval: 1s
- encryption: "fabrizio"
- binary_sensors:
- - rele_lora1
- providers:
- - name: lora-2
- encryption: "fabrizio"
- sensor:
- #WIFI
- - platform: wifi_signal
- name: "WiFi Signal lora 1"
- update_interval: 15s
- filters:
- - sliding_window_moving_average:
- window_size: 15
- send_every: 15
- send_first_at: 15
- icon: mdi:wifi
- - platform: template
- name: "LoRa RSSI"
- unit_of_measurement: "dBm"
- accuracy_decimals: 1
- update_interval: 5s
- lambda: |-
- return id(last_rssi);
- - platform: template
- name: "LoRa Pacchetti Ricevuti"
- lambda: |-
- return id(lora_packet_count);
- update_interval: 5s
- unit_of_measurement: "pkt"
- accuracy_decimals: 0
- - platform: template
- name: "LoRa Pacchetti Inviati"
- lambda: |-
- return id(lora_sent_count);
- update_interval: 10s
- unit_of_measurement: "pkt"
- accuracy_decimals: 0
- button:
- - platform: template
- name: "Transmit Packet"
- on_press:
- then:
- - sx127x.send_packet:
- data: [0xC5, 0x51, 0x78, 0x82, 0xB7, 0xF9, 0x9C, 0x5C]
- - platform: template
- name: "Apri cancello box"
- id: apri_cancello_box
- icon: "mdi:gate"
- on_press:
- - switch.turn_on: rele
- - delay: 3s
- - switch.turn_off: rele
- - platform: restart
- name: "Restart"
- switch:
- - platform: template
- name: Relè
- id: rele
- optimistic: True
- binary_sensor:
- - platform: template
- id: rele_lora1
- lambda: return id(rele).state;
- - platform: packet_transport
- id: rele_lora2
- provider: lora-2
- on_press:
- switch.turn_on: rele
- on_release:
- then:
- - delay: 2s
- - switch.turn_off: rele
Advertisement
Add Comment
Please, Sign In to add comment