Interconnect STM32F1xx and Lihtening Sensor AS3935 using HAL and I2C
Basically its a port from Arduiono. I was using PCB made by PlayingWithFusion.com
http://www.playingwithfusion.com/productview.php?pdid=22
Its very high quality board and works very well for me.
Description Breakout board for the AS3935 digital lightning sensor based on the AMS reference design. Includes specially tuned antenna, SPI or I2C interfacing, and a wide 2.4V to 5.5V standard operating range. This innovative sensor is designed to interface with most current development systems and boards, including all current Arduino modules. The breakout board features an inductor (antenna) specially designed for this application, and the board ships fully calibrated. This ensures that you don’t have to write a massive back-end to support low-level IC calibration, just focus on your final application!
PlayingWithFusion provide the source code to work with AS3935. But that was for Arduino. I tsuccessfully port it to STM32F1xx. Also I add few other subroutines, like auto tuning to get the right capacity value for the board.
Here is how output looks like:
The question remaining unsolved - for some uncertain reson the AS3935 doesn't accept the values for some capacitance. Like its calculate it as 40, but even I wrote it directly, it show it as 56 (which is best value as well).