Przepraszam mogłem napisać od razu którą wersję płytki mam.
Moja to v2 dokłądnie ta https://resource.heltec.cn/download/WiFi_LoRa_32/WIFI_LoRa_32_V2.pdf
Nosiłem ją w plecaku do pracy i po kilku próbach sprawdzonych kodów pod oled obejrzałem ją dokładnie. Niestety mam uszczerbiony oled przy taśmie. Pewnie coś w plecaku mi to zrobiło bo płytke wrzuciłem luzem i dalej już na moto do roboty. Przynajmniej wiem dlaczego nie działa mi oled
Ten kod poniżej jak jeszcze działał oled ładnie mi wyświetlał to co chciałem ale bez odczytów bo miałem problem z pinem od wmbusa.
Ten kod odczytuje ramki ale tylko prądu, wody nie widać i jeszcze nie wiem dlaczego.
Obecnie będę wyrzycał z niego opcję oleda bo niepotrzeba mi będzie jak i tak nie działa.
esphome:
name: lora
friendly_name: lora
on_boot:
priority: -100
then:
- output.turn_on: vext_output
- delay: 2s
- display.page.show: page_main
esp32:
board: heltec_wifi_lora_32_V2
framework:
type: esp-idf
logger:
id: component_logger
level: DEBUG
baud_rate: 115200
api:
encryption:
key: "P0n0kdfptFQ3xxxxxxxxxxxxxxxkC9J+9YeGwIj92E/E="
ota:
platform: esphome
password: "f734c2f1bd6e2xxxxxxxxxxxxx2580d9ee"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "Lora Fallback Hotspot"
password: "R6xxxxxxxxxOUjp"
fast_connect: true
captive_portal:
web_server:
version: 3
external_components:
- source: github://SzczepanLeon/esphome-components@version_5
spi:
clk_pin:
number: GPIO5
ignore_strapping_warning: true
mosi_pin: GPIO27
miso_pin: GPIO19
i2c:
sda: GPIO4
scl: GPIO15
scan: true
id: bus_a
light:
- platform: binary
output: led_output
id: led_light
restore_mode: ALWAYS_OFF
output:
- platform: gpio
id: vext_output
pin: GPIO21
- platform: gpio
id: led_output
pin: GPIO25
font:
- file: "fonts/arial.ttf"
id: font_main
size: 12
glyphs: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:°%.-³ĄĆĘŁŃÓŚŹŻąćęłńóśźż"
globals:
- id: current_page
type: int
restore_value: false
initial_value: '0'
- id: page_count
type: int
restore_value: false
initial_value: '4'
- id: auto_page_change
type: bool
restore_value: true
initial_value: 'true'
- id: wmbus_frames_received
type: int
restore_value: false
initial_value: '0'
- id: last_frame_time
type: uint32_t
restore_value: false
initial_value: '0'
interval:
- interval: 10s
then:
- if:
condition:
and:
- lambda: 'return id(auto_page_change);'
- switch.is_on: oled_switch
then:
- lambda: |
id(current_page) = (id(current_page) + 1) % id(page_count);
- display.page.show: !lambda |
switch (id(current_page)) {
case 0: return id(page_main);
case 1: return id(page_system);
case 2: return id(page_counters);
case 3: return id(page_stats);
default: return id(page_main);
}
switch:
- platform: template
name: "OLED Display"
id: oled_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- output.turn_on: vext_output
turn_off_action:
- output.turn_off: vext_output
- platform: template
name: "Auto Page Change"
id: auto_page_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- globals.set:
id: auto_page_change
value: 'true'
turn_off_action:
- globals.set:
id: auto_page_change
value: 'false'
wmbus_radio:
radio_type: SX1276
cs_pin: GPIO18
reset_pin: GPIO14
irq_pin: GPIO35
on_frame:
then:
- logger.log:
format: "RSSI: %ddBm T: %s (%d)"
args: [ frame->rssi(), frame->as_hex().c_str(), frame->data().size() ]
# Mruganie diodą przy odbiorze telegramu
- light.turn_on: led_light
- delay: 100ms
- light.turn_off: led_light
wmbus_meter:
- id: lazienka_zimna_meter
meter_id: 0x02569089
type: apator162
key: "00000000000000000000000000000000"
- id: lazienka_ciepla_meter
meter_id: 0x02589378
type: apator162
key: "00000000000000000000000000000000"
- id: kuchnia_zimna_meter
meter_id: 0x02567827
type: apator162
key: "00000000000000000000000000000000"
- id: kuchnia_ciepla_meter
meter_id: 0x02587182
type: apator162
key: "00000000000000000000000000000000"
- id: gamma150_meter
meter_id: 0x13829063
type: amiplus
key: "36703778426xxxxxxxxxxxxxx2636776"
sensor:
- platform: wmbus_meter
parent_id: lazienka_zimna_meter
field: total
name: "Łazienka zimna"
id: lazienka_zimna
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: water
state_class: total_increasing
- platform: wmbus_meter
parent_id: lazienka_ciepla_meter
field: total
name: "Łazienka ciepła"
id: lazienka_ciepla
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: water
state_class: total_increasing
- platform: wmbus_meter
parent_id: kuchnia_zimna_meter
field: total
name: "Kuchnia zimna"
id: kuchnia_zimna
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: water
state_class: total_increasing
- platform: wmbus_meter
parent_id: kuchnia_ciepla_meter
field: total
name: "Kuchnia ciepła"
id: kuchnia_ciepla
accuracy_decimals: 3
unit_of_measurement: "m³"
device_class: water
state_class: total_increasing
- platform: wmbus_meter
parent_id: gamma150_meter
field: total_energy_consumption_kwh
name: "Gamma 150"
id: gamma150_energy
accuracy_decimals: 3
device_class: energy
unit_of_measurement: "kWh"
state_class: total_increasing
- platform: wmbus_meter
parent_id: gamma150_meter
field: current_power_consumption_kw
name: "Chwilowy pobór"
id: chwilowy_pobor
accuracy_decimals: 0
device_class: power
unit_of_measurement: "W"
state_class: measurement
filters:
- multiply: 1000
on_value:
then:
- globals.set:
id: wmbus_frames_received
value: !lambda 'return id(wmbus_frames_received) + 1;'
- globals.set:
id: last_frame_time
value: !lambda 'return millis();'
- platform: wmbus_meter
parent_id: gamma150_meter
field: voltage_at_phase_1
name: "Napięcie L1"
id: voltage_l1
accuracy_decimals: 1
device_class: voltage
unit_of_measurement: "V"
state_class: measurement
- platform: wmbus_meter
parent_id: gamma150_meter
field: rssi_dbm
name: "Gamma 150 RSSI"
id: gamma150_rssi
accuracy_decimals: 0
device_class: signal_strength
unit_of_measurement: "dBm"
state_class: measurement
- platform: uptime
name: "Uptime"
id: uptime_sensor
- platform: wifi_signal
name: "WiFi Signal dBm"
id: wifi_signal_db
update_interval: 60s
- platform: copy
source_id: wifi_signal_db
name: "WiFi Signal %"
id: wifi_signal_percent
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
- platform: internal_temperature
name: "CPU Temperature"
id: cpu_temp
- platform: template
name: "Free Heap"
id: free_heap
lambda: 'return heap_caps_get_free_size(MALLOC_CAP_INTERNAL);'
unit_of_measurement: "B"
update_interval: 30s
filters:
- lambda: return x / 1024.0;
accuracy_decimals: 1
- platform: template
name: "WMBus Frames"
id: wmbus_frame_count
lambda: 'return id(wmbus_frames_received);'
update_interval: 60s
- platform: template
name: "Last Frame Age"
id: last_frame_age
lambda: |
if (id(last_frame_time) == 0) return NAN;
return (millis() - id(last_frame_time)) / 1000.0;
unit_of_measurement: "s"
update_interval: 10s
text_sensor:
- platform: wifi_info
ip_address:
name: "IP"
ssid:
name: "SSID"
mac_address:
name: "MAC"
- platform: template
name: "WMBus Status"
id: wmbus_status
lambda: |
if (id(last_frame_age).state < 60) return {"OK"};
else if (id(last_frame_age).state < 300) return {"Warning"};
else return {"Error"};
update_interval: 30s
time:
- platform: sntp
id: time_sntp
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
reset_pin: GPIO16
update_interval: 1s
rotation: 0°
pages:
- id: page_main
lambda: |-
if (!id(oled_switch).state) return;
it.print(0, 0, id(font_main), "ENERGIA");
if (id(chwilowy_pobor).has_state()) {
it.printf(0, 16, id(font_main), "%.0f W", id(chwilowy_pobor).state);
} else {
it.print(0, 16, id(font_main), "--- W");
}
if (id(time_sntp).now().is_valid()) {
it.strftime(64, 52, id(font_main), TextAlign::CENTER, "%H:%M:%S", id(time_sntp).now());
} else {
it.print(64, 52, id(font_main), TextAlign::CENTER, "--:--:--");
}
- id: page_system
lambda: |-
if (!id(oled_switch).state) return;
it.print(0, 0, id(font_main), "SYSTEM");
it.printf(0, 12, id(font_main), "WiFi: %.0f%%", id(wifi_signal_percent).state);
it.printf(0, 24, id(font_main), "CPU: %.1f°", id(cpu_temp).state);
it.printf(0, 36, id(font_main), "RAM: %.1fKB", id(free_heap).state);
int h = (int)(id(uptime_sensor).state / 3600);
int m = ((int)id(uptime_sensor).state % 3600) / 60;
it.printf(0, 48, id(font_main), "Up: %d:%02d", h, m);
- id: page_counters
lambda: |-
if (!id(oled_switch).state) return;
it.print(0, 0, id(font_main), "WODA");
it.printf(0, 12, id(font_main), "LZ: %.3fm³", id(lazienka_zimna).state);
it.printf(0, 24, id(font_main), "LC: %.3fm³", id(lazienka_ciepla).state);
it.printf(0, 36, id(font_main), "kZ: %.3fm³", id(kuchnia_zimna).state);
it.printf(0, 48, id(font_main), "kC: %.3fm³", id(kuchnia_ciepla).state);
- id: page_stats
lambda: |-
if (!id(oled_switch).state) return;
it.print(0, 0, id(font_main), "WM-BUS");
it.printf(0, 12, id(font_main), "Status: %s", id(wmbus_status).state.c_str());
it.printf(0, 24, id(font_main), "Frames: %d", id(wmbus_frames_received));
it.printf(0, 36, id(font_main), "Last: %.0fs", id(last_frame_age).state);
it.printf(0, 48, id(font_main), "RSSI: %.0fdBm", id(gamma150_rssi).state);