esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

as3935 values not written to the registry at all #6012

Open illigtr opened 3 weeks ago

illigtr commented 3 weeks ago

The problem

Attempting to determine why parameters like div_ratio: and capacitance: have no apparent effect while tuning the as3935. Finally determined that reading the registers for these values ALWAYS RETURNS the SAME VALUE regardless of settings.

Which version of ESPHome has the issue?

2024.6.6.

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.7.0

What platform are you using?

ESP32

Board

ESP32-WROOM-32

Component causing the issue

ass3935

Example YAML snippet

#lightning sensor
as3935_i2c:
  #setup_priority: -100
  address: 0x03
  i2c_id: i2c_1
  irq_pin: GPIO02
  indoor: true            # default value is true
  noise_level: 1          # default value is 2
  spike_rejection: 2      # default value is 2
  lightning_threshold: 1  # default is 1
  mask_disturber: false    # default is false
  watchdog_threshold: 2   # default value is 2

  # use these 2 values to  tune initially to 500kHz +/- 
  tune_antenna: false     # defaults to false
  calibration: true     # defaults to true
  div_ratio: 128       # default is 0
  capacitance: 15     # default is 0

Anything in the logs that might be useful for us?

Log file

[C][as3935:010]: Setting up AS3935...
[C][as3935:013]:   IRQ Pin: GPIO2
[V][as3935:089]: Setting indoor to 1
[VV][i2c.arduino:176]: 0x03 TX 00
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0024
[V][as3935:112]: Setting noise level to 1
[VV][i2c.arduino:176]: 0x03 TX 01
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0114
[V][as3935:100]: Setting watchdog sensitivity to 2
[VV][i2c.arduino:176]: 0x03 TX 01
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0122
[V][as3935:124]: Setting spike rejection to 2
[VV][i2c.arduino:176]: 0x03 TX 02
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0222
[V][as3935:135]: Setting lightning threshold to 1
[VV][i2c.arduino:176]: 0x03 TX 02
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0204
[V][as3935:156]: Setting mask disturber to 0
[VV][i2c.arduino:176]: 0x03 TX 03
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0304
[V][as3935:168]: Setting div ratio to 128  << ---- note set to 128
[VV][i2c.arduino:176]: 0x03 TX 03
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 03E4
[V][as3935:193]: Setting tune cap to 120 pF << ---- note set to 120pF
[VV][i2c.arduino:176]: 0x03 TX 08
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 080F
[V][as3935:259]: Calling read_div_ratio  < --- read back values
[VV][i2c.arduino:148]: 0x03 RX 24
[V][as3935:277]: Calling read_capacitance - modified.<  --- read back values
[VV][i2c.arduino:148]: 0x03 RX 24
[I][as3935:027]: Division Ratio is set to: 16   <--- NOTHING CHANGED!!
[I][as3935:028]: Internal Capacitor is set to: 32 <--- NOTHING CHANGED!!
[I][as3935:306]: Starting oscillators calibration...
[VV][i2c.arduino:176]: 0x03 TX 3D
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 3DB6
[VV][i2c.arduino:176]: 0x03 TX 08
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0844
[VV][i2c.arduino:176]: 0x03 TX 08
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:176]: 0x03 TX 0804
[VV][i2c.arduino:148]: 0x03 RX 24
[VV][i2c.arduino:148]: 0x03 RX 24
[I][as3935:322]: Calibration was succesful
[V][as3935:259]: Calling read_div_ratio
[VV][i2c.arduino:148]: 0x03 RX 24
[V][as3935:277]: Calling read_capacitance - modified.
[VV][i2c.arduino:148]: 0x03 RX 24
[I][as3935:040]: Division Ratio is set to: 16  <--- STILL NOTHING CHANGED!!
[I][as3935:041]: Internal Capacitor is set to: 32  <--- STILL NOTHING CHANGED!!

Additional information

I have tried release and dev branch. Placed a dev copy of ic2, as3935 components locally so I could add additional logging. Problem persists on both dev and release. Also noted that values for many masks are very different than standard libraires from SparkFun, DFRobot and AdaFruit... not sure why this is. Also noted syntax errors (already reported) and found one more when setting div_ratio to 64.... but first either the writing or the reading of the registers seems wonky.

illigtr commented 3 weeks ago

I have tested two boards, esp32-cam and esp-wroom-32, as well as 2 different as3935, one from DFrobot, the other from CFMCU. Same problems... however, if I test these boards under Arduino IDE using either SparkFun, DFRobot or Adafruit libraires for the as3935, they all work fine. writing settings for capacitance, multiplier, etc. work and can be read back with the correct values.