-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for AS3935, initial commit #8130
Conversation
tasmota/my_user_config.h
Outdated
@@ -503,7 +503,8 @@ | |||
// #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency | |||
// #define USE_HDC1080 // [I2cDriver45] Enable HDC1080 temperature/humidity sensor (I2C address 0x40) (+1k5 code) | |||
// #define USE_IAQ // [I2cDriver46] Enable iAQ-core air quality sensor (I2C address 0x5a) (+0k6 code) | |||
|
|||
#define USE_AS3935 // [I2cDriver48] Enable AS3935 Franklin Lightning Sensor (I2C address 0x03) (+5k3 code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theo, should it be activated by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, sorry...forgott to deactivate after testing...
Wow great job and super clean code! |
thanks! it was also a lot of work..:-) |
and that I don't forget it, a big thanks to @ludwich66 for testing and give a lot of ideas! |
Add support for AS3935 Lightning Sensor by device111 (#8130)
@device111 please review https://tasmota.github.io/docs/AS3935/ . Hope the wiring is correct, I was deducing from what you wrote |
I see there is a localisation problem,
I use dots as decimal separator and comma 1,000.00 vs 1.000,00 (German Interface)
—> listening … vs. listening ,,,
… Am 15.05.2020 um 00:16 schrieb TimelessNL ***@***.***>:
Great work so far! ⚡
I had this sensor for quite some time now (collecting dust in my desk)
But now I have a reason to finally attach the sensor to a Wemos D1 Mini Pro (on its 3v3 supply). But I got some trouble calibrating the sensor, it's constantly outputting Disturber detected and Storm is Overhead while there clearly isn't. I've been trying to do some calibration guesses but they won't survive a reboot. When I set AS3935setgain Outdoors after a reboot it's back to Indoors.
normaly you don't need the calibrate function. If you buy the AS3935, the Modul has a sticker on it with the calibrated cap.
a sticker? There is a sticker on the coil but this seems to be identical on all modules? Maybe my module is missing the factory calibration sticker somehow.
I also noticed that listening has some unnecessary comma's, or is this as designed?
<https://user-images.githubusercontent.com/10838968/81990544-ac893280-963f-11ea-8af8-e47b916c8ecc.JPG>
Is this an instability issue?
<https://user-images.githubusercontent.com/10838968/81990578-b90d8b00-963f-11ea-8f8e-55108fecd5bd.JPG>
This is my setup (Wemos D1 Mini Pro with DS18B20/BME280/AS3935):
<https://user-images.githubusercontent.com/10838968/81990598-be6ad580-963f-11ea-8adc-cfbd75cf3c47.jpg>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#8130 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AC5DF3LGHGH355RZVVHRI7TRRRUVDANCNFSM4MF4TZVQ>.
|
Ah! That does make sense. But 'listening...' is set using a define, why are the dots replaced by comma's? Ludwich you tested this implementation right? Did you have any problems with saving the calibration settings? |
I have a topic in mind here. The capacitors on your board are too big or too small, outside the area - not in the middle of the adjustment area. Can you measure the cap?
680+270 pF
I use a logic analycer to check the Frequency
There are 16 software configurable Caps to trim the Frequency
4 is the nearest value to generate 500khz
31,25 kHz Clock * Divider 16 == 500Khz
ASM3935 Reference Design
This is the normal calibration on my board
01:13:05 CMD: AS3935CALIBRATE
01:13:08 MQT: stat/AS3935_DEAA8F/RESULT = {"AS3935":{"Cap gesetzt auf:":4}}
01:13:15 MQT: tele/AS3935_DEAA8F/SENSOR = {"Time":"2020-05-15T01:13:15","MAX44009":{"Illuminance": 0.000},"AS3935":{"Event":2,"Distance":0,"Energy":0,"Stage":0}}
|
@TimelessNL can you make a "as3935settings" and report the result? And yes, i have read on an Amazon report, thtat this modul has the wrong caps on it. |
There are 16 steps of sensifity
They are coupled with „AS3935autonf“ 1 or 0
If you set AS3935autonf to 0, you can set Indoors(AS3935setgain) and (AS3935setnf) fix
the algorythmus changes the sensityfity (less noise and less disturber -made it more sensitive —> Rang ist higher > 40000m)
Find the right conditions for your place
AS3935setnf 0,1,2,3,4,5,6,7
AS3935autonf 0,1
AS3935setgain Indoors, Outdoors
Indoors Outdoors
0,1,2,3,4,5,6,7 0,1,2,3,4,5,6,7
0,1,2,3,4,5,6,7 8,9,10,11,12,13,14,15 (Stage)
This are my local setting:
11:24:59 CMD: as3935settings
11:24:59 MQT: stat/AS3935_DEAA8F/RESULT = {"AS3935":{"Gain":"Indoors","NFfloor":0,"uVrms":28,"Tunecaps":4,"MinNumLight":1,"Rejektion":2,"Wdthreshold":2,"MinNFstage":0,"NFAutoTime":4,"DisturberAutoTime":1,"Disturber":"Off","NFauto":"On","Disturberauto":"On","NFautomax":"On","Mqttlightevent":"Off"}}
|
Yes I did, and indeed when I restart Tasmota the gain indeed goes up (to around 6 after a while). Sorry I didn't notice, I was only looking at But what does
I've found the review, and this indeed seems unfortunate 😢, I've bought this module a while ago, but never took the time to write some code for it. Until I saw this change-set and was happily surprised by the ease of use.
To reliably measure the capacitance I have to remove the capacitor from the board, I prefer not to do that until I have some replacements. Maybe I can order some correct capacitors so I can replace them anyway. I have mounted the sensor on the roof today. So when the first summer thunderstorm arrives I can test if this sensor 'hears' anything. I've set |
I tried to set as3935setnf to 0
after this setting i do calibrate
no automatic reset follows
did you help this info?
17-05-2020
13:59:51 CMD: as3935setnf 0
13:59:51 MQT: stat/AS3935_DEAA8F/RESULT = {"AS3935":{"setnf":0}}
14:00:09 CMD: as3935calibrate
14:00:12 MQT: stat/AS3935_DEAA8F/RESULT = {"AS3935":{"Cap gesetzt auf:":4}}
14:00:20 MQT: tele/AS3935_DEAA8F/SENSOR = {"Time":"2020-05-17T14:00:20","MAX44009":{"Illuminance": 2154},"AS3935":{"Event":5,"Distance":0,"Energy":0,"Stage":1}}
ludwich
|
@ludwich66 your posts are very hard to read because you're replying to a github mail. And could you please try to use markdown to make them easier to read? |
If you set as3935autonf to 1, do you have also reboots?
If "as3935autonfmax" is Enabled, the AutoNF Funktion goes over both Areas (Indoor and Outdoor). and "as3935setminstage" is combined with Autonf: |
i think, you have a problem with your sensor. if you can not adjust right now with the calibrate function, it does not work. |
@TimelessNL |
Hello, I have a problem with the calibration procedure: as a result I got {"calibration failed":12}. So I changed the caps to the needed value (680p and 270p). But i got the same result, also if I changed them to 680p and 220p. It would be nice, if the calibration routine could output the error value of the 16 steps, so one can determine, if the cap is too large or too small. |
@device111 Which video do you mean? Is it this one: https://www.youtube.com/watch?v=fTEEDfWbGEU? |
Yes! |
Hi, I'm trying to get a GY AS3935 working without success. The system detects noise and disturbances but definitely does not detect lightning. What could be happening. |
Hi Birthon, Works "as3935calibrate" fine? (There are Boards with wrong capacitance Values) ludwich |
Hi Ludwich, I'm developing a tricorder project that contains several different sensors. The code is too big to put in here. However, the basic sketch for AS3935 was the one placed below. This was the only sketch that adapted to the rest of my code and did not offer incompatibility with other libraries. As I said before, the system detects triggering of tasers, electrical welding, short circuits, but it does not detect lightning. `/* This example demonstrates how to detect lightning! It has a few basic By: Elias Santistevan */ #include <SPI.h> // 0x03 is default, but the address can also be 0x02, 0x01. SparkFun_AS3935 lightning(AS3935_ADDR); // Interrupt pin for lightning detection // This variable holds the number representing the lightning or non-lightning void setup() Serial.begin(115200); Wire.begin(); // Begin Wire before lightning sensor. if( !lightning.begin() ) { // Initialize the sensor. // The lightning detector defaults to an indoor setting at void loop() |
FTR, connecting/configuring AS3935 to another ESP32 device, I got the sensor detected and active as in providing data on Tasmota front page and in MQTT messages. |
Working on a selfcompiled Tasmota 12.0.2.2 Version. See Tests: Work stable for me since first implementation. I'm happy to help if I get concrete ideas. ludwich |
Have you had success with Tasmota? I have the same CJMCU and is not working... |
Have you read the discussion #16400 ? |
What is not working? |
and I,m not sure if the wiring in Tasomta Docs are right for the CJMCU. I have made the Descripton for the CJMCU from another side. I have found anothe Wiring for I2C. The EN_V here is connected to GND and not to VCC. Can you test this wiring. If it works, i must change the Docs. |
PIN 15 (AS3935) = ADD0 = A0 L SET I2C Adress: |
ok, then normaly should work without wiring to VCC. The Datasheet says "Connect to GND or VCC". |
so if not needed, please cancel your PR |
SPI wiring and that project works, but I2C wiring and Tasmota not. |
There is an error at all of the wiring pictures: MISO is an output of the chip, so it shouldn't be connected to ground! |
As the Tasmota driver for the AS3935 expects to use I2C communication (selected with connecting the SI pin to 3.3V), instead of SPI, the pins used for communication are SCL and the MOSI pin used as SDA. Hence MISO is not part of the communication, and it may not be important what you do with it. I'd assume that connecting it to GND is fine. |
Don't agree with You. As data sheet says, MISO is an output, it's not good in any circumstances to short it with ground. You don't know, which voltage is put out in that case. If not used, let it left open! |
Well, "output" does not mean always outputting, the data sheet suggests that MISO is set to tristate if not active. And my AS3935 board has solder jumpers for connecting MISO and CS to GND, supposedly for a reason. With MISO connected to GND, I'm getting |
Figure 19 page 15 |
If someone wonders, that refers to the data sheet linked in the first post here, which clearly shows that the solder jumpers on my board are there for a good reason. |
I have now found another data sheet for the MOD-1016 breakout board with the AS3935 on it. Strangely enough, there is other information here about wiring with I2C. The manufacturer's original data sheet for the AS3935 states that with I2C wiring the CS and MISO should be connected to ground. (Figure 19 page 15). The MOD-1016 Datasheet states:
Maybe @ludwich66 can write here which module he used. This also seems to work perfectly. MOD1016 Datasheet: actual AS3935 Datasheet v1.04: |
Reading that, I do not see any requirement to remove the CS/GND solder jumper, except if you want to use SPI instead of I2C. And while MISO/GND is not stipulated, it is not suggesting "should not be connected", merely that it is not used. Thus, not importantly different from existing suggestions around those two pins, having both to GND should still be fine for I2C usage. Of course, not using I2C Address (ludwich66 has not been posting here for two years now). |
I think, it's not so easy with the CS Pin. the MOD1016 datasheet says: "Also, you will need to remove the solder jumper that keeps CS pulled to ground for I can't imagine that this has an influence on the internal behavior of the AS3935, but apparently it does. However, the MOD1016 Modul is working for me. I have a look tomorrow on my Modul, if i have shorted the CS-GND Pad. |
Yes, I did read that, in the clear context of To use the module with SPI communications As we are not talking about SPI but I2C, I'd simply disregard that obvious warning about not having CS grounded for SPI operation. |
ahhhh...ok. Thanks sfromis! |
wow, great setup! |
@ludwich66: really nice setup! |
Description:
Support for AS3935 Lightning Sensor added:
-support for all AS3935 Parameters
-support of all related commands for configuration
-support of NF-Auto Function to auto Threshold the Noise Reduction
-support auf Auto Disturber
-support of calibrating the internal OSC with switchable Caps
Datasheet available at: https://www.mouser.com/datasheet/2/588/ams_AS3935_Datasheet_EN_v5-1214568.pdf
supported commands and functions:
notice for the as3935calibrate:
normaly you don't need the calibrate function. If you buy the AS3935, the Modul has a sticker on it with the calibrated cap.
Use the "as3935settunecaps" for setting up this value.
notice for the IRQ Pin:
the sensor uses a software interrupt.
Make sure, that the connections with the IRQ pin are stable to prevent flicker.
Mqtt Events:
Setting table of the NF-noise sensitivity and stages:
the Modul need 5k4 of flash memory. By default, this module is not activated.
you must set "USE_AS3935" to compile this module.
Tasmota settings:
Related issue (if applicable): fixes #
Checklist: