LIGHTNING DETECTOR CODE QUESTIONS

I have the SPARKFUN AS3935 LIGHTNING DETECTOR boards and I have several questions on the example codes and hookup;

The DATASHEET(Figure 11) for the AS3935 chip shows that for i2c a pullup resistor is required on the SCL pin(pin#11) and no pullup on the SDA pin(PIN# 13. The board is shipped with pullup resistors on both pins and the hookup guide says to remove then if there are multiple I2c devices.Please clarify.

The DATASHEET(Figure 10) for the AS3935 chip shows that for SPI no pullup resistors are required. Please clarify.

In the “Example2_More_Lightning_Features”; Could you please explain how to implement/use the “IncreaseWatchdog”, “dullTheSpike”“reduceNoise” functions; it looks like the values will just increase to their maximum and stay there. Please clarify.

The Lightning Energy function does not work, it returns a error; “lightEnergy not declared in this scope” and “mylight not defined in this scope”. Please clarify.

Hello williamlynn!

The pullup resistors on the I-squared-C data line is unnecessary and should not be there (this will be addressed in the next version of the board). The resistance on the clock line is suggested by the datasheet as you mentioned. You can cut the pullup resistor on the data line by cutting the trace on the pullup jumper connecting it to 3.3V.

If you’re using SPI, you should indeed cut the traces, though I did find that it worked with them there.

As to your next question. The functions in the example code are made to increase the values in their respective functions incrementally up to the maximum value. My suspicion is that you’re in an environment with a lot of noise and so it’s consistently calling the function enough to reach the maximum value. My suggestion is to first: try to reduce the noise in your environment but secondly: you can call those library functions “lightning.spikeRejection(spike)”, “lightning.setNoiseLevel(noiseFloor)”, and “lightning.watchdogThreshold(watchDogVal)” and give them a set value (“spike”, “watchDogVal”, and “noiseFloor”) for the lightning register to sit at, rather than incrementing the value every time noise is dedected.

And finally your comment. You are correct, there are some typos in that line. I’ll roll out a fix momentarily but you can update the code with the following:

In front of “lightEnergy”, put “byte”. It should read: “byte lightEnergy = …”

Next: change “myLight” to “lightning”

As I said, I’ll fix those typos momentarily.

Hope that helps!

Typos fixed!