stevemarple / as3935 Goto Github PK
View Code? Open in Web Editor NEWArduino library to support Austrian Microsystems AS3935 lightning sensor.
License: GNU Lesser General Public License v2.1
Arduino library to support Austrian Microsystems AS3935 lightning sensor.
License: GNU Lesser General Public License v2.1
I modified the as3935_demo.ino as follow:
/*
-------------------------------
AS3935 | ESP8266 (ModeMCU)
---------+---------------------
MISO/SDA | D3
MISO | GND
SCK/SCL | D4
IRQ | D5
SI | +3,3V
CS | GND
GND | GND
Vdd | +3,3V
------------------------------
Pin mapping:
https://github.com/esp8266/Arduino/issues/584
*/
#include <AsyncDelay.h>
#include <SoftWire.h>
#include <AS3935.h>
#define SDA_PIN D3
#define SCL_PIN D4
#define IRQ_PIN D5
AS3935 as3935;
bool ledState = true;
AsyncDelay d;
void int2Handler(void)
{
as3935.interruptHandler();
}
void readRegs(uint8_t start, uint8_t end)
{
for (uint8_t reg = start; reg < end; ++reg) {
delay(50);
uint8_t val;
as3935.readRegister(reg, val);
Serial.print("Reg: 0x");
Serial.print(reg, HEX);
Serial.print(": 0x");
Serial.println(val, HEX);
Serial.flush();
}
Serial.print("State: ");
Serial.println(as3935.getState(), DEC);
Serial.println("-------------");
}
void setup(void)
{
Serial.begin(115200);
as3935.initialise(SDA_PIN, SCL_PIN, 0x03, 3, true, NULL);
as3935.start();
d.start(1000, AsyncDelay::MILLIS);
while (!d.isExpired())
as3935.process();
readRegs(0, 0x09);
as3935.setNoiseFloor(0);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, ledState);
pinMode(IRQ_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(IRQ_PIN), int2Handler, RISING);
d.start(1000, AsyncDelay::MILLIS);
Serial.println("setup() done");
}
uint8_t count = 0;
void loop(void)
{
if (as3935.process()) {
uint8_t flags = as3935.getInterruptFlags();
uint8_t dist = as3935.getDistance();
Serial.println("-------------------");
Serial.print("Interrupt flags: ");
Serial.println(flags, HEX);
Serial.print("Distance: ");
Serial.println(dist, DEC);
}
if (as3935.getBusError())
Serial.println("Bus error!");
if (as3935.getTriggered())
Serial.println("Triggered!");
if (d.isExpired()) {
ledState = !ledState;
digitalWrite(LED_BUILTIN, ledState);
if (++count > 5) {
count = 0;
readRegs(0, 0x09);
}
d.start(1000, AsyncDelay::MILLIS);
}
}
But the issue is allways "Triggered!"
PORT OPEN 115200
Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...
Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
$
Reg: 0x1: 0x22
Reg: 0x2: 0xC2
Reg: 0x3: 0x0
Reg: 0x4: 0x0
Reg: 0x5: 0x0
Reg: 0x6: 0x0
Reg: 0x7: 0x3F
Reg: 0x8: 0x3
State: 4
-------------
setup() done
Reg: 0x0: 0x24
Reg: 0x1: 0x2
Reg: 0x2: 0xC2
Reg: 0x3: 0x0
Reg: 0x4: 0x0
Reg: 0x5: 0x0
Reg: 0x6: 0x0
Reg: 0x7: 0x3F
Reg: 0x8: 0x3
State: 5
-------------
-------------------
Interrupt flags: 1
Distance: 63
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
-------------------
Interrupt flags: 1
Distance: 63
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
-------------------
Interrupt flags: 1
Distance: 63
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
Triggered!
-------------------
Where is my fail?
Info about the external IRQs at the ESP8266:
https://techtutorialsx.com/2016/12/11/esp8266-external-interrupts/
It it possible to add support for the ESP8266?
When i compile the AS3935_demo.ino, i get the following error:
D:\Users\3PO\Documents\Arduino\libraries\SoftWire\src\SoftWire.cpp:1:25: fatal error: util/atomic.h: No such file or directory
#include <util/atomic.h>
^
compilation terminated.
exit status 1
Fehler beim Kompilieren für das Board NodeMCU 1.0 (ESP-12E Module)
Thanks in advance. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.