Lovelace Lightning Detector Card for AS3935

Hello I jumped on this project again, to get this thing running. The sensor is connected as described in the manual via SPI (recommended by SparkFun). The connection via MQTT to Homeassistant seems to work and the sensor shows up there.
Connection to raspy is as in the table in the manual: GPIO Pin 22 on Raps (Gpio 25)
But I don not get any detections while there is a thunderstorm outside.

[2021-06-20 00:31:51] - * init mqtt_client_connected=[False]
[2021-06-20 00:31:51] * Sensor on SPI bus
[2021-06-20 00:31:51] - log: Sending CONNECT (u1, p1, wr1, wq0, wf1, c1, k60) client_id=b''
[2021-06-20 00:31:51] - log: Sending PUBLISH (d0, q0, r0, m1), 'b'home/nodes/sensor/lightningdetector/status'', ... (6 bytes)
[2021-06-20 00:31:51] - * Wait on mqtt_client_connected=[False]
[2021-06-20 00:31:51] - log: Received CONNACK (0, 0)
[2021-06-20 00:31:51] MQTT connection established
[2021-06-20 00:31:51] 
[2021-06-20 00:31:51] - on_connect() mqtt_client_connected=[True]
[2021-06-20 00:31:52] - - stopped MQTT timer
[2021-06-20 00:31:52] - - started MQTT timer - every 60 seconds
[2021-06-20 00:31:52] - - ip=[192.168.108.35], mac[b8:27:eb:67:5e:9c], interface=[wlan0], uniq-id=[AS3935-b827eb675e9c]
[2021-06-20 00:31:52] Announcing Lightning Detection device to MQTT broker for auto-discovery ...
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m2), 'b'homeassistant/sensor/lightningdetector/last/config'', ... (539 bytes)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m3), 'b'homeassistant/sensor/lightningdetector/energy/config'', ... (301 bytes)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m4), 'b'homeassistant/sensor/lightningdetector/distance/config'', ... (336 bytes)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m5), 'b'homeassistant/sensor/lightningdetector/count/config'', ... (298 bytes)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 2)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m6), 'b'homeassistant/sensor/lightningdetector/settings/config'', ... (418 bytes)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m7), 'b'homeassistant/sensor/lightningdetector/crings/config'', ... (406 bytes)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 3)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 4)
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r1, m8), 'b'homeassistant/sensor/lightningdetector/prings/config'', ... (403 bytes)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 5)
[2021-06-20 00:31:52] - - Testing AS3935 Communications...
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 6)
[2021-06-20 00:31:52] - - TEST write=5, read-back=5
[2021-06-20 00:31:52] - - TEST write=2, read-back=2
[2021-06-20 00:31:52] Publishing to MQTT topic "home/nodes/sensor/lightningdetector/settings, Data:{"settings": {"timestamp": "2021-06-20T00:31:52+02:00", "hardware": {"min_strikes": 5, "afe_inside": true, "disp_lco": false, "noise_floor": 1}, "script": {"period_minutes": 5, "end_minutes": 30, "number_rings": 5, "distance_units": "km"}}}"
[2021-06-20 00:31:52] - log: Sending PUBLISH (d0, q1, r0, m9), 'b'home/nodes/sensor/lightningdetector/settings'', ... (240 bytes)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 7)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 8)
[2021-06-20 00:31:52] - log: Received PUBACK (Mid: 9)
[2021-06-20 00:32:02] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:12] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:22] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:32] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:42] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:52] - - MQTT TIMER INTERRUPT -
[2021-06-20 00:32:52] - - stopped MQTT timer
[2021-06-20 00:32:52] - - SEND: yes, still alive -
[2021-06-20 00:32:52] - log: Sending PUBLISH (d0, q0, r0, m10), 'b'home/nodes/sensor/lightningdetector/status'', ... (6 bytes)
[2021-06-20 00:32:52] - - started MQTT timer - every 60 seconds
[2021-06-20 00:32:52] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:32:53] - log: Sending PINGREQ
[2021-06-20 00:32:53] - log: Received PINGRESP
[2021-06-20 00:33:02] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:12] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:22] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:32] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:42] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:52] - - MQTT TIMER INTERRUPT -
[2021-06-20 00:33:52] - - stopped MQTT timer
[2021-06-20 00:33:52] - - SEND: yes, still alive -
[2021-06-20 00:33:52] - log: Sending PUBLISH (d0, q0, r0, m11), 'b'home/nodes/sensor/lightningdetector/status'', ... (6 bytes)
[2021-06-20 00:33:52] - - started MQTT timer - every 60 seconds
[2021-06-20 00:33:52] << INTR(22) >> Noise level too high - adjusting
[2021-06-20 00:33:54] - log: Sending PINGREQ
[2021-06-20 00:33:54] - log: Received PINGRESP
[2021-06-20 00:34:02] << INTR(22) >> Noise level too high - adjusting
[Sensor]

# decribe how your sensor is hooked up to your RPi
#  use values 'I2C' or 'SPI' - default is 'I2C'
#sensor_attached = I2C
sensor_attached = SPI

# GPIO pin used for interrupts
intr_pin = 22

# The SPI bus and device numbers come from the device file being used.
#   e.g., /dev/spidev0.0  would be bus=0, device=0
# The defaults are 0 and 0 (SPI0 which appears at the GPIO 40pin header)
spi_bus = 0
spi_device = 0

# Rev. 1 Raspberry Pis should leave bus set at 0, while rev. 2 Pis should set
# bus equal to 1. The address should be changed to match the address of the
# sensor.
#i2c_bus = 1
#i2c_address = 0x03

# Value to use for your board
#   Internal Tuning Capacitors (from 0 to 120pF in steps of 8pf) - A value of [0-15]
# run the script with a --tune paramater to determine value for your board
#  NOTE: this runs for 3 minutes so be patient!  Then record your best value here.
tuning_capacitor = 0x0

# Indoors (True) = more sensitive (can miss very strong lightnings)
# Outdoors (False) = less sensitive (can miss far away lightnings)
#detector_afr_gain_indoor = True

#detector_noise_floor = 1

# Prevent single isolated strikes from being logged => interrupts begin after
# this number of strikes (def: 5, value 1,5,9,16), then are fired normally.
#detector_min_strikes = 5
#detector_min_strikes = 1

Can someone help me to get the sensor working?

Hello, I still cannot get this thing to work:

[2021-07-08 19:52:46] - * init mqtt_client_connected=[False]
[2021-07-08 19:52:46] * Sensor on SPI bus
[2021-07-08 19:52:46] - log: Sending CONNECT (u1, p1, wr1, wq0, wf1, c1, k60) client_id=b''
[2021-07-08 19:52:46] - log: Sending PUBLISH (d0, q0, r0, m1), 'b'home/nodes/sensor/lightningdetector/status'', ... (6 bytes)
[2021-07-08 19:52:46] - * Wait on mqtt_client_connected=[False]
[2021-07-08 19:52:46] - log: Received CONNACK (0, 0)
[2021-07-08 19:52:46] MQTT connection established
[2021-07-08 19:52:46] 
[2021-07-08 19:52:46] - on_connect() mqtt_client_connected=[True]
[2021-07-08 19:52:47] - - stopped MQTT timer
[2021-07-08 19:52:47] - - started MQTT timer - every 60 seconds
[2021-07-08 19:52:47] - - ip=[192.168.108.35], mac[b8:27:eb:67:5e:9c], interface=[wlan0], uniq-id=[AS3935-b827eb675e9c]
[2021-07-08 19:52:47] Announcing Lightning Detection device to MQTT broker for auto-discovery ...
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m2), 'b'homeassistant/sensor/lightningdetector/last/config'', ... (539 bytes)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m3), 'b'homeassistant/sensor/lightningdetector/energy/config'', ... (301 bytes)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m4), 'b'homeassistant/sensor/lightningdetector/distance/config'', ... (336 bytes)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m5), 'b'homeassistant/sensor/lightningdetector/count/config'', ... (298 bytes)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m6), 'b'homeassistant/sensor/lightningdetector/settings/config'', ... (418 bytes)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m7), 'b'homeassistant/sensor/lightningdetector/crings/config'', ... (406 bytes)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 2)
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r1, m8), 'b'homeassistant/sensor/lightningdetector/prings/config'', ... (403 bytes)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 3)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 4)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 5)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 6)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 7)
[2021-07-08 19:52:47] - - Testing AS3935 Communications...
[2021-07-08 19:52:47] - - TEST write=5, read-back=5
[2021-07-08 19:52:47] - - TEST write=2, read-back=2
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 8)
[2021-07-08 19:52:47] Publishing to MQTT topic "home/nodes/sensor/lightningdetector/settings, Data:{"settings": {"timestamp": "2021-07-08T19:52:47+02:00", "hardware": {"min_strikes": 5, "afe_inside": true, "disp_lco": false, "noise_floor": 1}, "script": {"period_minutes": 5, "end_minutes": 30, "number_rings": 5, "distance_units": "km"}}}"
[2021-07-08 19:52:47] - log: Sending PUBLISH (d0, q1, r0, m9), 'b'home/nodes/sensor/lightningdetector/settings'', ... (240 bytes)
[2021-07-08 19:52:47] - log: Received PUBACK (Mid: 9)
[2021-07-08 19:52:57] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:07] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:17] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:27] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:37] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:47] - - MQTT TIMER INTERRUPT -
[2021-07-08 19:53:47] - - stopped MQTT timer
[2021-07-08 19:53:47] - - SEND: yes, still alive -
[2021-07-08 19:53:47] - - started MQTT timer - every 60 seconds
[2021-07-08 19:53:47] - log: Sending PUBLISH (d0, q0, r0, m10), 'b'home/nodes/sensor/lightningdetector/status'', ... (6 bytes)
[2021-07-08 19:53:47] << INTR(22) >> Noise level too high - adjusting
[2021-07-08 19:53:48] - log: Sending PINGREQ
[2021-07-08 19:53:48] - log: Received PINGRESP
[2021-07-08 19:53:57] << INTR(22) >> Disturber detected. Masking subsequent disturbers

Can anyone help with this?
Is there a proper connection to the sensor?

Is there any way to test this, if there is no thunderstorm around?

/dev/spidev0.0 exists (also /dev/spidev0.1 but there I do get errors)
Wiring is checked more than 3 times.

This does not look right, does it? The frequency?

* Please allow a long time for this function to stop. It should take a little over 3 minutes to test the 16 values
For tuning 0x0: average frequency of 0.000000 Hz (diff: +31250.0)
For tuning 0x1: average frequency of 0.000000 Hz (diff: +31250.0)

I have a AS3935 connected to a ESP8266 feeding into HA - How can I connect those entities into this card?

Michael,

The project MQTT Lightning Daemon Project contains the full source code which is reading and reporting the lightning sense values to the card.

You would have to implement something similar on your ESP8266 to report the values to the MQTT broker. The full communication details are here: theory of operations

Please share if you decide to do this…