ESPHome with AS3935 Franklin Lightning Sensor - try increasing the spike rejection value!

Welcome to the club. We have matching jackets.

I recommended using the HACS Blitzortung integration instead.

I will give that a try. I got my station all designed and put together and thought maybe I just missed something or was doing something wrong until I came across this post. I plan on keeping the sensor in place on the circuit board and maybe somewhere in the future someone will figure it out.


7 Likes

hoping to get the station put up on the tower today. It is going up on a 55ft armature radio tower that sits next to my house

Hi!

I also have the topic with disturbers. Since the datasheet talks about tuning the antenna, I looked at the Sparkfun AS3935 library example 3 to figure out at which frequency my board is tuned. Originally I had – as you can see from the screenshot


around 550kHz (1/29,1µs * 16 (divider)) which is much too high given that the datasheet talks about 500kHz ±3.5%.

So I tried the maximum compensation value (120pF)


which results in 522kHz which is still outside the maximum of 517.5kHz. With a bit of soldering I could get it to 512kHz but unfortunately the problem persists.
I then changed the i2c bus frequency to 200kHz (no harmonics for 500kHz) which made it a bit better, meaning that I do not permanently get these “disturber detected” messages.

Long story short, the circuit was badly designed/tuned, but fixing it did not bring the expected result.

1 Like

Hi, is there anyone for whom this module works?

I gave up for the moment.
I bought this one here:

But I did not assemble it yet (“Bausatz” means you have to solder it on your own).
I read that it shall work, but I won’t get the distance (if it works at all).

Not sure it’s working correctly, but I finally got the SPI bus config sorted out for an ESP32 Dev board and I’m getting values from it now and displaying them on the local OLED display. Trying to figure out how to build a current/previous bucket that holds 5min of samples now.

Can you please send the wiring diagram. I tried all the options and nothing worked properly.

I’ll see what I can do to show the wiring I used.


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());
1 Like

Yeah, I think I got to that point too while reading SPI but the piece of junk still didn’t detect lightning strikes.

I always had mine connected over SPI when I tested this last summer. It never detected a strike, ever. Only noise. It was on a post in the middle of our horse pasture, like almost a kilometer away from any computer or electronics. I ended up trashing the thing.

Maybe the one @UniKyrn has is better, it’s the Sparkfun one. I had a cheap (well relatively speaking, it was still something like 15€ iirc) chinese clone.

I’m still waiting for the first thunderstorm of the spring here and tinkering with the code. I get the occasional hit on the INT pin which signals a strike, but they’ve been false hits so far. I think I’m going to add a Time of Strike sensor to the config so that the history will correspond to actual storms that might happen. The board only asserts INT for a second, so If I’m not staring at it when it happens, I don’t see the strike.

Looking at the docs, I’m not even sure that’s a strike sensor. It reads like it’s a storm sensor that the chip will assert when it sees enough strikes during a sample period.

I tested both of them. Neither works. Waste of ~$30.

Same here. I had lightnings right above my house but the detector did not do anything. The efforts to tune the 500kHz and playing around with the settings did not lead to anything.

My last idea was to keep a fair distance between the sensor and any microcontroller, since I saw that every access to the SPI caused some spikes but this comment also ruined my hopes.

I guess I agree with the others: waste of money, unfortunately.

Yeah well it still had an MCU connected to it, about a meter away connected with shielded cable. I used a low noise Arduino in a metal case, power supply from a battery. No RF, the results of the noiselightning detector where just stored on the Arduino onboard memory in a histogram. I let it sit there for the day, had a thunderstorm pass over it (including a lightning strike on a tree that was almost cut in half) and then got it back in to read out the results. And those were only noise.

I’m using the blitzortung.org website now, it’s really nice and precise. You can see where the thunderstorm forms and how the front progresses. Obviously it’s cloud based, but sometimes a collaborative project using hundreds of receivers is just the better option. And their receivers are much more sophisticated anyway (they’re open source).

Thanks for that report @HeyImAlex , that test is bullet lightning proof.
Interestingly the device that was mentioned by @der-optimist also contains the same IC and is claimed to work. Anyhow, I’ll also go for websites or a rain detector, not worth any further tries. :wink:

So it’s lost? Nobody started it? Has anyone tried projects for Arduino?

In my (and it seems also others) opinion, yes.

Yes, see this post: ESPHome with AS3935 Franklin Lightning Sensor - try increasing the spike rejection value! - #16 by HeyImAlex

I tried this project earlier

It also worked with a lighter.
But I can’t implement it in a home assistant.

Now I have connected the esphome spi bus and see what will be during the storm) connected via the battery.