AS3935 with NodeMCU ESP8266 I2C

I have a problem getting my AS3935 to work with I2C… I think my wiring is wrong since it says that it can’t find any devices and I couldn’t find a clear guide with the NodeMCU ESP8266…

Mine is not picking up the i2c it seems:

[16:31:31][C][i2c:028]: I2C Bus:
[16:31:31][C][i2c:029]:   SDA Pin: GPIO4
[16:31:31][C][i2c:030]:   SCL Pin: GPIO5
[16:31:31][C][i2c:031]:   Frequency: 50000 Hz
[16:31:31][I][i2c:033]: Scanning i2c bus for active devices...
[16:31:31][I][i2c:049]: Found no i2c devices!
[16:31:31][C][logger:175]: Logger:
[16:31:31][C][logger:176]:   Level: DEBUG
[16:31:31][C][logger:177]:   Log Baud Rate: 115200
[16:31:31][C][logger:178]:   Hardware UART: UART0
[16:31:31][C][as3935:027]: AS3935:
[16:31:31][C][as3935:028]:   Interrupt Pin: GPIO12 (Mode: INPUT)
[16:31:31][C][as3935_i2c:036]:   Address: 0x03

So what do I have wrong here, I’ve got mine connected as follows:

| AS3935 |  ESP8266  |
|--------|-----------|
|  IRQ   |D6 (GPIO12)|
|  MOSI  | D2 (GPIO4)|
|  SCL   | D1 (GPIO5)|
|  GND   |    GND    |
|  VCC   | 3V3 (3.3V)|

Config:

esphome:
  name: lightning_detector
  platform: ESP8266
  board: nodemcuv2

i2c:

as3935_i2c:
  irq_pin: GPIO12

sensor:
  - platform: as3935
    lightning_energy:
      name: "Lightning Energy"
    distance:
      name: "Distance Storm"
binary_sensor:
  - platform: as3935
    name: "Storm Alert"

I’ve tried modifying it as below, but same result:

| AS3935 |  ESP8266  |
|--------|-----------|
|  IRQ   |D6 (GPIO12)|
|  MOSI  | D2 (GPIO4)|
|  SCL   | D1 (GPIO5)|
|  GND   |    GND    |
|  VCC   | 3V3 (3.3V)|
|   A0   | 3V3 (3.3V)|
|   A1   | 3V3 (3.3V)|
|  EN_V  | 3V3 (3.3V)|
|   SI   | 3V3 (3.3V)|

I have one of these too but I haven’t seen it actually do anything yet. Unlike your ‘Found no i2c devices!’ message, I can see it detected in my ESPHome logs on address 0x03.

[22:48:47][I][i2c:033]: Scanning i2c bus for active devices...
[22:48:47][I][i2c:040]: Found i2c device at address 0x03
[22:48:47][I][i2c:040]: Found i2c device at address 0x48
[22:48:47][I][i2c:040]: Found i2c device at address 0x76

You may want to explicitly define your i2c bus with scan: true, like this:

i2c:
  scl: D1
  sda: D2
  scan: True

On the AS3935 definition I included indoor: false because I was getting a bunch of Disturber was detected alerts on the device for seemingly no reason:

as3935_i2c:
  irq_pin: D7
  indoor: false

I’m nit picking about this but your 3.3V supply is hooked to the negative bus. You need to send SI to VDD to tell it that you want i2c mode. but it looks like you figured that out.

I didn’t tie EN_V, A0, nor A1 to VDD like you did. I let them all float. I’m pretty sure that 0x3 is the default unless you start tying A0 and/or A1 to VDD. And you shouldn’t need the voltage regulator if your running 3.3V supply.

If you’re new to this (like I am), you might want to read the datasheet – page 14 has some juicy details.

I still don’t know if mine is working because we don’t get thunderstorms that much around here. So far the HA display has always looked like this:
image

good luck!

Try clicking a piezo BBQ lighter near it.

gas-lighter-500x500

Well I did have some progress, I soldered the stupid pins on, and now it picks it up in the lgos :smiley:
I was under the impression that I could just push the pins in, but apparently that’s not enough.

Logs:

[10:45:51][C][i2c:028]: I2C Bus:
[10:45:51][C][i2c:029]:   SDA Pin: GPIO4
[10:45:51][C][i2c:030]:   SCL Pin: GPIO5
[10:45:51][C][i2c:031]:   Frequency: 50000 Hz
[10:45:51][I][i2c:033]: Scanning i2c bus for active devices...
[10:45:51][I][i2c:040]: Found i2c device at address 0x02
[10:45:52][C][as3935:027]: AS3935:
[10:45:52][C][as3935:028]:   Interrupt Pin: GPIO13 (Mode: INPUT)
[10:45:52][C][as3935_i2c:036]:   Address: 0x03

Config:

i2c:
  scl: D1
  sda: D2
  scan: true
  
as3935_i2c:
  irq_pin: D7
  indoor: true

sensor:
  - platform: as3935
    lightning_energy:
      name: "Lightning Energy"
    distance:
      name: "Distance Storm"
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s
binary_sensor:
  - platform: as3935
    name: "Storm Alert"

Pins:

| AS3935 |  ESP8266  |
|--------|-----------|
|  IRQ   |D7 (GPIO13)|
|  MOSI  | D2 (GPIO4)|
|  SCL   | D1 (GPIO5)|
|  GND   |    GND    |
|  VCC   | 3V3 (3.3V)|
|   A0   | 3V3 (3.3V)|
|   A1   | 3V3 (3.3V)|
|  EN_V  | 3V3 (3.3V)|
|   SI   | 3V3 (3.3V)|

Now that it actually picks the thing up, I’ll try the clicker thing.

We don’t get many thunderstorms either, maybe like once a year. I just thought it was something cool to try out :smiley:

1 Like

I don’t actually know if it will work. It was just an idea.

Nope, clicker doesn’t work :confused:
I’ve seen that too, but also that it doesn’t work always.

So… I guess I’ll just have to wait for some lighting and see what happens…

Yeah, I tried the clicker lighter things (multiple and at the same time) and randomly my electric toothbrush and I wasn’t able to make it register. I’m just waiting for a storm so I can see if it does anything. :unamused:

Interesting - and disappointing - to see that this sensor doesn’t work for others either.

Initially I connected mine via I2C, but didn’t get any values reported even during heavy thunderstorms. Then I connected it via SPI, and got some results, but primarily log messages telling me to change either the noise_level or spike_rejection parameters. Distance or storm alert never reported any values, and lightning energy occasionally reports a value during a thunderstorm.

Just in case you never get it working, as an alternative, I’m sponging off others nearby for Lightning data with this:

Map web page http://en.blitzortung.org/live_lightning_maps.php

You can see if there are any detectors nearby by going to the project area / station list menu at the top of the page and sorting your region by the country column.

2 Likes

This sensor is used in the Weatherflow weather stations, and the discussions around Lightning are frequent on their forums - mostly false detections.

For my part, I have two of their devices in my garden, one mounted horizontally, and one vertically right next to each other.

The horizontal one only detects a few strikes, usually legitimate ones. The vertical one detects many, many more on a daily basis, all false, just electrical interference from other sources (lights, compressors etc), so siting etc is pretty important.

The energy value is also questionable, as it doesn’t appear to really be energy, just an arbitrary number. There is an interesting post from the folks at Weatherflow about it here if you are interested: Weatherflow and meteobridge - #9 by dsj - Developers - The Tempest Weather Community

Having had mine in operation for several years (and we by no means get a lot of storms), it does seem fairly usable to detect a storm and indicate it is moving towards us or away, once you have it well sited.

Don’t mean to detract from what you guys are doing, but thought you might be interested in some other perspectives from a commercial product using it. Its still good fun to watch and play around with - even though I have two (3 if I include the one indoors), I’m still tempted to have a play with these components and do a DIY one for fun too :slight_smile:

3 Likes