Ok, here is what I got working, the hard part was figuring out the right pins for the SPI bus. Use the wrong pins and it either gives no output, or worse, crashes the wifi and you have to reload via usb cable. You can ignore the i2c part of the code, it’s for the oled display.
I also found, in testing, that having the breadboard near the computer I use threw a lot of spike errors, that almost vanished when I put the breadboard in another room with less computer gear. That 500khz receiver is really sensitive to noise sources.
Here is (most of) the yaml running on the setup.
esphome:
name: esp32-oled
comment: HelTec WiFi OLED Dev Board
name_add_mac_suffix: false
platform: esp32
board: esp32dev
platformio_options:
board_upload.flash_size: 16MB
board_upload.maximum_ram_size: 524288
board_upload.maximum_size: 16777216
board_build.partitions: "../../../esp32-16MB-partitions.csv"
logger:
api:
reboot_timeout: 0s
web_server:
port: 80
ota:
password: ***
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
reboot_timeout: 5min
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Oled Fallback Hotspot"
password: !secret wifi_password
# channel:
domain: ***
captive_portal:
time:
- platform: homeassistant
id: homeassistant_time
mqtt:
broker: ***
username: ***r
password: ***
discovery_prefix: esp32-oled
discovery_retain: true
output:
- platform: gpio
pin: GPIO25
id: gpio_25
i2c:
sda: GPIO04
scl: GPIO15
scan: true
id: i2c_bus
spi:
clk_pin: GPIO18
miso_pin: GPIO19
mosi_pin: GPIO23
id: spi_bus
as3935_spi:
cs_pin: GPIO5
irq_pin: GPIO17
indoor: True
noise_level: 2
spike_rejection: 5 # Default 2
lightning_threshold: 1
mask_disturber: false
div_ratio: 0
capacitance: 0
watchdog_threshold: 2
binary_sensor:
- platform: as3935
name: "Lightning Strike"
id: strike
sensor:
- platform: as3935
lightning_energy:
name: "Strike Energy"
id: energy
distance:
name: "Storm Distance"
id: distance
light:
- platform: binary
output: gpio_25
name: esp32-oled light
***
font:
- file: "Calibri.ttf"
id: calibri_font
size: 12
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: GPIO16
address: 0x3C
lambda: |-
it.strftime(0, 0, id(calibri_font), "%Y-%m-%d %H:%M", id(homeassistant_time).now());
it.line(0, 12, 127, 12);
it.printf(0, 15, id(calibri_font), "Strike: %s", id(strike).state ? "Zot!" : "");
it.printf(0, 27, id(calibri_font), "Distance: %3.1fkm", id(distance).state);
it.printf(0, 39, id(calibri_font), "Energy: %8.0f Vix", id(energy).state);
it.line(0, 53, 127, 53);
it.printf(0, 54, id(calibri_font), "UniKyrn: %s", id(oled_display).state.c_str());