I'm stumped. AS3935 doesn't seem to work

I am stumped. I am trying to get a GY-AS3935 lightning sensor board to work on an Arduino Mega 2560. There's a lot of info, a lot of similar but differ3ent libraries... and I get nothing. All registers return zero, whether I try to wire it for I2C or SPI. The code compiles fine, but as said, all registers return zero and I see not sign that it is actually working at all. Any ideas, anyone? I've spent days and am stumped. Probably overlooking something stupid.

the sketch (example).pdf (37.2 KB)

I tried both I2C and SPI, for that reason.

what about this?

/* Note the AS3935 sensor communicates via SPI or I2C the code
below use SPI if
your using SPI rather than i2C remove the library which is the
code library folder*/
1 Like

I don't understand that grammar, so I am not sure what they want me to do...

Iff they mean "if you are using SPI, remove the i2C library", then yes, I did that...

some module have soldering places to choose the interface

here shown SPI connection
https://www.amazon.co.uk/GY-AS3935-Lightning-Detection-Station(Max-40km)DIYmalls/dp/B087358RNT

1 Like

GOT IT!

It was much simpler. I am using an Arduino Mega instead if an Uno, and I did not realize that the i2c pins are different: not A4/A5, but pins 20 and 21. Geez, that took em three days...d'oh.

Now the next questions:

  • How do I test it?
  • Also, the board did not have a calibration value on the package or anything, so how do I know what to set the capacitance to?

Any help appreciated again....

Did the section on Antenna Tuning at the bottom of page 35 of the datasheet offer any help? It seems to me that with that information, it should be fairly straightforward to tune it, no?

1 Like

Somewhere i have seen a table with 15 levels of sensitivity.
to simulate the lightning is piezo lighter helpful.

1 Like

Maybe this post can be useful
https://blog.meteodrenthe.nl/2021/05/14/as3935-lightning-detector-with-wemos-d1-mini/
The library is AS3935MI that you can find in library manager.
The example that works for me is AS3935MI_LightningDetector_I2C
My as3935 board has an SI pin that MUST be connected to 3.3V otherwise I2C communications is not reliable, sometimes works, sometimes not.

1 Like

Tuning is not obvious, but that’s a secondary concern. Main concern is to make sure it works.

My efforts to get any interrupt whatsoever have so far not worked. I have an arcing lighter but that doesn’t do anything. I goes I’ll need to find a normal piezo lighter?

But is there’s no way to set the noise level to zero so it triggers? I’m concerned that it’s never triggered in any way. I guess I can wait for a storm but that may be weeks away… the interrupt code works; the Arduino works (if I disconnect the irq line, it triggers), the chip works (registers return correct values).., but nothing seems to actually set it off. Even if I key up a 5W Radio transmitter right next to it.

As before, any ideas welcomed..!!

The code that I suggested
https://bitbucket.org/christandlg/as3935mi/src/master/examples/AS3935MI_LightningDetector_I2C/AS3935MI_LightningDetector_I2C.ino
has in the loop some instruction to automatically adjust the noise floor level.
At the bottom of the loop you can find

	if (as3935.decreaseSpikeRejection())
					Serial.println("decreased spike rejection ratio");
				else
					Serial.println("spike rejection ratio already at minimum");

and

				if (as3935.decreaseWatchdogThreshold())
					Serial.println("decreased watchdog threshold");
				else
					Serial.println("watchdog threshold already at minimum");

Then you can use an artificial noise like a piezo. I don't know if arc lighter works too. I have one somwhere.

That's extremely useful! And getting closer now.

But still, I cannot set it off using even a piezo lighter. Been trying!! The code looks fine, it seems to run ok: it ens up here...:

I2C connection check passed.
IRQ pin connection check passed.
Resonance Frequency Calibration passed.
Resonance Frequency is 500480 Hz
RCP Calibration passed.
Initialization complete, waiting for events...
INTERRUPT DETECTED: 0
INTERRUPT DETECTED: 1
Noise floor too high. attempting to increase noise floor threshold.
increased noise floor threshold
No disturber detected, attempting to decrease noise floor threshold.
decreased watchdog threshold
No disturber detected, attempting to decrease noise floor threshold.
decreased spike rejection ratio
No disturber detected, attempting to decrease noise floor threshold.
decreased watchdog threshold
No disturber detected, attempting to decrease noise floor threshold.
decreased spike rejection ratio
No disturber detected, attempting to decrease noise floor threshold.
No disturber detected, attempting to decrease noise floor threshold.
...

...and it repeats that last line ad infinitum...

Any idea? Could it just be faulty?

OMG - if I connect it to 3.3V instead of 5V, and I pull SI up myself to 3.3V, it works!

Now it works too well, constantly seeing disturbers, but I will happily look into that now...

It does make me wonder how reliable this chip is - or this board, for that matter. But testing continues. Thanks SO much for your help so far.

Spoke too soon.
It does raise interrupts, but they are self-generated, not generated by me. It constantly raises a "4", unless I set "Mask disturbers" to TRUE. And in that case it raises a few "1" values and then nothing. In any case, whatever I do makes no difference.,

Geez, this is the most difficult sensor I have worked with to date... :wink:

Geez. OK, it is becoming clearer, several days in. Thank God I like this kind of debugging, or I'd be very frustrated by now. So in the hope this may help others in the future:

  • The board (a GY-AS3935 that reportedly meets all the specs) works on 3.3V but does not detect anything on 5V (even though it passes all tests). And SI needs to be tied to Vcc.

  • If I connect directly to the Arduino with short jumpers, all fine; but if I use a 15cm ribbon cable between my breadboard and the AS3935 board, then the board intermittently fails all tests: I2C, Resonance Frequency, and RCO. This one bothers me - any ideas welcome.

  • If I flash on and off an LED on the same breadboard, this causes a Disturber Interrupt. Even with a 10 uF cap across power and ground at the breadboard.

  • In general, it signals a lot of Disturber events. Like a LOT.

  • I can now pretty reliably set off a disturber alert, either with the piezo lighter or with the battery-powered arc lighter. But I have not yet seen it signal noise or lightning. (Which is probably a good thing).

Comments, suggestions, etc welcome!

BTW, the breadboard looks like this:

I written this before!

Anyway I use it with an ESP8266 because it is a 3.3V MCU. Never used with a 5V MCU like Arduino UNO.
Withouth any storm around I got the same result, an endless noise floor adjustement. But I didn't test with a piezo lighter.
I have two AS3935 based sensor made by Fine Offset, a weather stations maker, named WH57 and they works very well when storms are around. But they are on battery.
So the chip works but have to be tuned. I have the same board.
I don't know if the USB power from a PC can have some effect since usually it is noisy.

1 Like

Makes sense.

Well, it's kind of working but there are twi things that worry me.

  1. If I move the project to an entirely different board, it works differently (or not at all), even though it is wired and connected exactly the same. It's as though some part of the comms is super critical, and changing anything, even the length of one wire, upsets it.

  2. When I raise an LED, or especially when I activate a buzzer, this immediately raises a disturber alert... leading to a vicious circle where it never stops (because I use LEDs to indicate disturber, lightning, etc). Whatever I do, whenever I activate a buzzer, immediately a disturber alert follows.

Any suggestions?

Maybe the board is noisy, Arduino UNO have radio emission when generating PWM that can be modulated.
So, avoid buzzer.
Led is turned on or you use PWM?

Buzzer is the type that just needs +5V, but of course oscillates internally, and has electromagnet in it, so that makes sense. And LEDs are just turned on, no pwm.