esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
294 stars 37 forks source link

AS3935 sensor issue #6407

Open smaj100 opened 3 weeks ago

smaj100 commented 3 weeks ago

The problem

using the as3935 sensor component, when trying to set the div ratio values, or capacitance values, neither with change when setting in the code. When you enable tune_antenna: true it shows div ration of 16, capacitance of 0. even if you set the values with tune_antenna: false, they don't show as changing?

Which version of ESPHome has the issue?

2024.9.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.10.1

What platform are you using?

ESP32

Board

AS3935

Component causing the issue

spi

Example YAML snippet

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

as3935_spi:
  cs_pin: GPIO16
  irq_pin: GPIO17
  indoor: true
  div_ratio: 128
  capacitance: 08
  noise_level: 2
  spike_rejection: 2
  lightning_threshold: 5
  mask_disturber: true
  tune_antenna: true
  calibration: false
  watchdog_threshold: 2

binary_sensor:
  - platform: as3935
    name: ${device_name}_Storm Alert

sensor:
  - platform: as3935
    lightning_energy:
      name: ${device_name}_Lightning Energy
    distance:
      name: ${device_name}_Distance Storm

Anything in the logs that might be useful for us?

[15:42:50][I][app:029]: Running through setup()...
[15:42:50][D][spi:035]: Setting up SPI bus...
[15:42:50][I][i2c.arduino:218]: Performing I2C bus recovery
[15:42:50][I][as3935_spi:010]: SPIAS3935Component setup started!
[15:42:50][D][spi_device:362]: mode 0, data_rate 2000kHz
[15:42:50][I][as3935_spi:012]: SPI setup finished!
[15:42:50][C][as3935:010]: Setting up AS3935...
[15:42:50][C][as3935:013]:   IRQ Pin: GPIO17
[15:42:50][C][as3935:027]:   Antenna tuning: ENABLED - lightning detection will not function in this mode
[15:42:50][I][as3935:310]: Starting antenna tuning...
[15:42:50][I][as3935:313]: Division Ratio is set to: 16
[15:42:50][I][as3935:314]: Internal Capacitor is set to: 0
[15:42:50][I][as3935:315]: Displaying oscillator on INT pin. Measure its frequency - multiply value by Division Ratio

Additional information

No response

billmaterial commented 1 week ago

@smaj100

I know this is not the issue you are reporting but I thought I would mention it anyway as this would be a show stopper if you were using this type of board.

There is a problem with the wrong tuning capacitors on some boards which prevents it from working correctly, have a look at this site https://tasmota.github.io/docs/AS3935/#breakout-boards-issues and if your board is the same one as the board shown, then you may have to change the cap's to get it to work.

I had a problem with it not working or tuning correctly and it took me weeks to find the issue and test it as we don't often get thunder storms, so I made a lightning simulator out of a Raspberry Pi Pico, a few components and a cheap Amazon AM antenna that works surprisingly well.

I rember using the Arduino code examples and library, not ESPHOME to try and tune it before I realised the problem was with the cap's so maybe its a problem with the ESPHOME AS3935 code module that's causing the issue.

My Setup code for reference: I found that setting the "Indoor: True" caused many false triggers and made it unusable for me although the module is actually indoors. This setup works well and I can detect lightning for 30km+ verified using Blitzortung, allthough it can be a bit sensitive at times.

as3935_spi:
  cs_pin: GPIO27
  irq_pin: GPIO19
  id: lightning_detector

  div_ratio: 0
  capacitance: 0
  mask_disturber: False
  calibration: True
  tune_antenna: False

  spike_rejection: 1 # Default 2, Max 11
  noise_level: 1 # Default 2, Max 7
  watchdog_threshold: 1 # Default 2
  lightning_threshold: 1
  indoor: False