Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BLE_Lightning_sensor
Homepage

include the mbed library with this snippet
#include "mbed.h"
#include "AS3935/AS3935.hpp"
AS3935 Lightning(p28,p27,0x06); //détecteur d'orages relié en I2C, adresse I2C 0x06;
InterruptIn IntLightning(p29); //IRQ AS3935
///////////////////////////////////////////////////////////////////
// Détection d'orages, Fonction d'interruption sur p29
//////////////////////////////////////////////////////////////////
void DetectLightning()
{
char OriginInt;
inter = !inter;
wait_ms(2); //on attend 2ms préconisation constructeur
OriginInt = Lightning.interruptSource();
if (OriginInt == 1) { //le bruit environnant est trop élevé
pc.printf(" Bruit trop élevé\r\n");
}
if (OriginInt == 4) { //détection perturbation électromagnétique
pc.printf(" Perturbation électromagnétique\r\n");
}
if (OriginInt == 8) { //on a détecté un éclair
pc.printf(" Détection d'un éclair\r\n");
}
}
int main() {
//initialisations
Lightning.reset();
Lightning.setTuneCap(5); //réglage capacité d'accord à 500kHz
Lightning.powerUp();
Lightning.setIndoors(); //réglage du gain d'amplification pour l'intérieur
IntLightning.rise(&DetectLightning);
while(1) {
}