Skip to content
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

Merged
merged 2 commits into from
Apr 11, 2020
Merged

support for AS3935, initial commit #8130

merged 2 commits into from
Apr 11, 2020

Conversation

device111
Copy link
Contributor

@device111 device111 commented Apr 11, 2020

Description:

Support for AS3935 Lightning Sensor added:

grafik

-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:

Console Commands Description values Bitlength
as3935setnf Noise Floor Level value from 0-7 (3 Bit)
as3935setml Minimum number of lightning 1, 5, 9, 16 (2 bit)
as3935default load default for Sensor and Settings no argument
as3935setgain Set Inddoor/Outdoor Indoors/Outdoors (Ascii)
as3935settunecaps Internal Tuning Cap. value from 0-15 (4 Bits)
as3935setrej Spike rejection value from 0-15 (4 Bits)
as3935setwdth Watchdog threshold value from 0-15 (4 Bits)
as3935setminstage min stage that could be come with NFautotune value from 0-15: 0-7 Indoors, 8-15 Outdoors (4 Bits)
as3935disturber Set Disturber 0/1 (1 Bit)
as3935autonf Set Auto Tune for Noise Level 0/1 (1 Bit)
as3935autodisturber Set Auto-Disturber 0/1 (1 Bit)
as3935autonfmax Auto Tune with INDOOR and OUTDOOR 0/1 (1 Bit)
as3935mqttevent mqtt messages only for lightning events 0/1 (1 Bit)
as3935settings show all settings no argument
as3935calibrate auto calibrate the internal Capacitors no argument
as3935disttime time for reset Disturber in auto-mode 0-15 min. (4 Bit)
as3935nftime time for auto-Nf treshhold 0-15 min (4 Bit)

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:

nr. Description suppress with
0 no event
1 Lightning with Distance detected
2 Lightning out of Distance
3 Distance cannot be determined
4 Storm is Overhead
5 Noise level too high *
6 Disturber detected *
7 Irq with no Event detected

Setting table of the NF-noise sensitivity and stages:

Stages NF-LEV AFE-GB uVrms sensitivity
Stage 0 000 Indoors 28 highly sensitive
Stage 1 001 Indoors 45
Stage 2 010 Indoors 62
Stage 3 011 Indoors 78
Stage 4 100 Indoors 95
Stage 5 101 Indoors 112
Stage 6 110 Indoors 130
Stage 7 111 Indoors 146
Stage 8 000 Outdoors 390
Stage 9 001 Outdoors 630
Stage 10 010 Outdoors 860
Stage 11 011 Outdoors 1100
Stage 12 100 Outdoors 1140
Stage 13 101 Outdoors 1570
Stage 14 110 Outdoors 1800
Stage 15 111 Outdoors 2000 less sensitive

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:

grafik

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest dev branch
    • Only relevant files were touched
    • Only one feature/fix was added per PR.
    • The code change is tested and works on core Tasmota_core_stage
    • The code change pass travis tests. Your PR cannot be merged unless tests pass
    • I accept the CLA.

@@ -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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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...

@s-hadinger
Copy link
Collaborator

Wow great job and super clean code!

@arendst arendst merged commit 2a74196 into arendst:development Apr 11, 2020
@device111
Copy link
Contributor Author

thanks! it was also a lot of work..:-)

@device111
Copy link
Contributor Author

device111 commented Apr 11, 2020

and that I don't forget it, a big thanks to @ludwich66 for testing and give a lot of ideas!

arendst added a commit that referenced this pull request Apr 11, 2020
Add support for AS3935 Lightning Sensor by device111 (#8130)
@blakadder
Copy link
Collaborator

@device111 please review https://tasmota.github.io/docs/AS3935/ . Hope the wiring is correct, I was deducing from what you wrote

@TimelessNL
Copy link

TimelessNL commented May 14, 2020

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 on it? 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?
listening
Is this an instability issue?
interupt_issue

This is my setup (Wemos D1 Mini Pro with DS18B20/BME280/AS3935):
20200514_235516
Using these pinouts:
afbeelding

@ludwich66
Copy link

ludwich66 commented May 14, 2020 via email

@TimelessNL
Copy link

TimelessNL commented May 14, 2020

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?

@ludwich66
Copy link

ludwich66 commented May 14, 2020 via email

@device111
Copy link
Contributor Author

@TimelessNL
do you have set the option "as3935autonf"?
If you set this option, the gain will always start on "INDOOR".

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.
you can read it in german, if you search "as3935" and the user "Hotzenplotz94".
He talk about wrong caps on the pcb and he don't can adjust the antenna calibration.

@ludwich66
Copy link

ludwich66 commented May 15, 2020 via email

@TimelessNL
Copy link

TimelessNL commented May 16, 2020

@TimelessNL
do you have set the option "as3935autonf"?
If you set this option, the gain will always start on "INDOOR".

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 Indoors/Outdoors. And when I set as3935autonf 0 the calibration does survive a reboot.

But what does as3935autonfmax do? The description: "Auto Tune with INDOOR and OUTDOOR" is a bit cryptic, does it mean that as3935autonfmax 0 limits the stages to only indoors?

can you make a "as3935settings" and report the result?

19:52:37 CMD: as3935settings
19:52:37 MQT: stat/sonoff/RESULT = {"AS3935":{"Gain":"Indoors","NFfloor":6,"uVrms":130,"Tunecaps":15,"MinNumLight":1,"Rejektion":2,"Wdthreshold":2,"MinNFstage":0,"NFAutoTime":4,"DisturberAutoTime":1,"Disturber":"On","NFauto":"On","Disturberauto":"On","NFautomax":"On","Mqttlightevent":"On"}}

And yes, i have read on an Amazon report, thtat this modul has the wrong caps on it.
you can read it in german, if you search "as3935" and the user "Hotzenplotz94".
He talk about wrong caps on the pcb and he don't can adjust the antenna calibration.

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.
mY module may have the wrong caps but I have the small PCB not the bigger one Hotzenplotz94 is writing about on amazon. So maybe that makes a difference

(this is my sensor)
as3935-small

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?

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 as3935autonf 1 and with a clear sky there is no disturbance detected or Storm is Overhead but it is listening,,, as it should. Maybe last time I tested there where some disturbance's within 40Km, but I simple didn't notice since it was night :)

@ludwich66
Copy link

ludwich66 commented May 17, 2020 via email

@TimelessNL
Copy link

@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?

@device111
Copy link
Contributor Author

And when I set as3935autonf 0 the calibration does survive a reboot.

If you set as3935autonf to 1, do you have also reboots?
Did you have always reboots with calibrating?

But what does as3935autonfmax do? The description: "Auto Tune with INDOOR and OUTDOOR" is a bit cryptic, does it mean that as3935autonfmax 0 limits the stages to only indoors?

If "as3935autonfmax" is Enabled, the AutoNF Funktion goes over both Areas (Indoor and Outdoor).
If disabled, the AutoNF goes about the Floor that you have set with "as3935setgain". (Indoor or Outdoor)

and "as3935setminstage" is combined with Autonf:
this the limit for the minimum stages you can come. (highly sensitive).
It makes no sense to go up in sensitivity if there is a lot of Base-Noise anyway.

@TimelessNL
Copy link

If you set as3935autonf to 1, do you have also reboots?

Yeah I disabled flash writes, when I determent a config is correct I reboot Tasmota to make those changes permanent.

If "as3935autonfmax" is Enabled, the AutoNF Funktion goes over both Areas (Indoor and Outdoor).
If disabled, the AutoNF goes about the Floor that you have set with "as3935setgain". (Indoor or Outdoor)

Ah that makes sense, I've tried this and indeed it does what it is suppose to do.

and "as3935setminstage" is combined with Autonf:
this the limit for the minimum stages you can come. (highly sensitive).
It makes no sense to go up in sensitivity if there is a lot of Base-Noise anyway.

But when I set this to as3935setminstage 6 it still starts at stage 0 after a reboot, shouldn't this then start at stage 6?

Last few days AutoNF detected noise until it hit stage 6 and then became stable and started listening... we did finally receive some heavy clouds today, which can carry some high altitude thunder (not very close though) and the AS3935 started to give some output. But these seem like false-positives to me because it was giving lightning overhead within 1KM so I raised it to stage 9 and then the range went to 5KM which may be plausible, it stopped when I raised it to stage 15 after which it went back to listening.... Still finding it strange that AutoNF does not make the sensor reliably detect thunder though.
lightning
I also get allot of Interrupt with no event messages during those heavy clouds.
interupt_without_event

These are my current settings:

22:17:43 CMD: AS3935settings
22:17:43 MQT: stat/sonoff/RESULT = {"AS3935":{"Gain":"Outdoors","NFfloor":1,"uVrms":630,"Tunecaps":15,"MinNumLight":1,"Rejektion":5,"Wdthreshold":2,"MinNFstage":6,"NFAutoTime":4,"DisturberAutoTime":1,"Disturber":"On","NFauto":"Off","Disturberauto":"On","NFautomax":"On","Mqttlightevent":"On"}}

@device111
Copy link
Contributor Author

i think, you have a problem with your sensor. if you can not adjust right now with the calibrate function, it does not work.
you can contact @ludwich66 . He have a sensor and can you explain the settings.
On youtube gives a realy good viedo about adjusting the as 3935. the Sensor have a lot of settings, that you can change.

@device111
Copy link
Contributor Author

@TimelessNL
Now, the initial Settings for as3935setminstage is correct. the changes are now in developement.

@TimelessNL
Copy link

TimelessNL commented May 31, 2020

i think, you have a problem with your sensor

That is very unfortunate, since most sensors that can be bought from Ebay or Aliexpress are those purple color PCBs that most likely have wrong spec capacitors on them like you suggested.

Now, the initial Settings for as3935setminstage is correct.

Great, thanks!

I've not tried to integrate this sensor in Domoticz yet so I do not have any real statistics, but what I've been thinking: yes the sensor does indicate lightning yet nothing can be seen by the naked eye, but what if the energy levels are much higher during visible thunder and the sensor is now only announcing some static electricity in the atmosphere.

There is probably no easy way to use the build-in Domoticz configuration to send the appropriate information to Domoticz I guess?
afbeelding

EDIT:
I've added this rule, but I'm not sure if the AS3935 supports tele- massages?
Rule1 ON Tele-AS3935#Distance DO publish domoticz/in {"idx":x,"svalue":"%value%"} ENDON ON Tele-AS3935#Energy DO publish domoticz/in {"idx":x,"svalue":"%value%"} ENDON
It does send the values to Domoticz, but even when the web-interface shows noise detected the information in the tele- message is "AS3935":{"Event":0,"Distance":0,"Energy":0}. This should have been "AS3935":{"Event":5,"Distance":0,"Energy":0} I guess.

@HelmiBeh
Copy link

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.

@Maddinthebrain
Copy link

Maddinthebrain commented Dec 29, 2020

i think, you have a problem with your sensor. if you can not adjust right now with the calibrate function, it does not work.
you can contact @ludwich66 . He have a sensor and can you explain the settings.
On youtube gives a realy good viedo about adjusting the as 3935. the Sensor have a lot of settings, that you can change.

@device111 Which video do you mean? Is it this one: https://www.youtube.com/watch?v=fTEEDfWbGEU?

@device111
Copy link
Contributor Author

Yes!

@Birthon
Copy link

Birthon commented Sep 20, 2021

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.

@ludwich66
Copy link

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,
Please post first your settings:
Konsole: "as3935settings"

Works "as3935calibrate" fine? (There are Boards with wrong capacitance Values)

ludwich

@Birthon
Copy link

Birthon commented Sep 21, 2021

Hi Ludwich,
I have used this settings in a board Feather MO adalogger

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.
I've used AS3935 before on other projects and I've never had any problems, although I've never used this basic sketch before. Can you give me any tips to investigate this issue?
How does the calibration process work?
Thank you for any help.

`/*

This example demonstrates how to detect lightning! It has a few basic
settings to help with rejecting noise or "disturbers" (false lightning events).
It uses the onboard interrupt hardware pin, so in addition to attaching to
it data lines you'll need to connnect to the interrupt pin labled "INT".

By: Elias Santistevan
SparkFun Electronics
Date: May, 2019
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

*/

#include <SPI.h>
#include <Wire.h>
#include "SparkFun_AS3935.h"

// 0x03 is default, but the address can also be 0x02, 0x01.
// Adjust the address jumpers on the underside of the product.
#define AS3935_ADDR 0x03
#define INDOOR 0x12
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

SparkFun_AS3935 lightning(AS3935_ADDR);

// Interrupt pin for lightning detection
const int lightningInt = 4;

// This variable holds the number representing the lightning or non-lightning
// event issued by the lightning detector.
int intVal = 0;
int noise = 2; // Value between 1-7
int disturber = 2; // Value between 1-10

void setup()
{
// When lightning is detected the interrupt pin goes HIGH.
pinMode(lightningInt, INPUT);

Serial.begin(115200);
Serial.println("AS3935 Franklin Lightning Detector");

Wire.begin(); // Begin Wire before lightning sensor.

if( !lightning.begin() ) { // Initialize the sensor.
Serial.println ("Lightning Detector did not start up, freezing!");
while(1);
}
else
Serial.println("Schmow-ZoW, Lightning Detector Ready!");

// The lightning detector defaults to an indoor setting at
// the cost of less sensitivity, if you plan on using this outdoors
// uncomment the following line:
//lightning.setIndoorOutdoor(OUTDOOR);
}

void loop()
{
if(digitalRead(lightningInt) == HIGH){
// Hardware has alerted us to an event, now we read the interrupt register
// to see exactly what it is.
intVal = lightning.readInterruptReg();
if(intVal == NOISE_INT){
Serial.println("Noise.");
// Too much noise? Uncomment the code below, a higher number means better
// noise rejection.
//lightning.setNoiseLevel(setNoiseLevel);
}
else if(intVal == DISTURBER_INT){
Serial.println("Disturber.");
// Too many disturbers? Uncomment the code below, a higher number means better
// disturber rejection.
//lightning.watchdogThreshold(threshVal);
}
else if(intVal == LIGHTNING_INT){
Serial.println("Lightning Strike Detected!");
// Lightning! Now how far away is it? Distance estimation takes into
// account any previously seen events in the last 15 seconds.
byte distance = lightning.distanceToStorm();
Serial.print("Approximately: ");
Serial.print(distance);
Serial.println("km away!");
}
}
delay(100); // Slow it down.
}
`

@sfromis
Copy link
Contributor

sfromis commented Aug 18, 2022

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.

@barbudor
Copy link
Contributor

@rb2k I suggest that to open a new discussion detailing:

  • which binary you are using as per BUILDs this is available only in tasmota32 and tasmota-sensors
  • if you have enabled the driver with i2cdriver48 1

@ludwich66
Copy link

I am using a

Working on a selfcompiled Tasmota 12.0.2.2 Version.
HW:
ESP8266
Mod 1016 Module
Difference of 15 cm between Sensor and ESP-Module

See Tests:
#8130 (comment)

Work stable for me since first implementation.

I'm happy to help if I get concrete ideas.

ludwich

@rb2k
Copy link

rb2k commented Aug 19, 2022

@rb2k I suggest that to open a new discussion detailing:

  • which binary you are using as per BUILDs this is available only in tasmota32 and tasmota-sensors
  • if you have enabled the driver with i2cdriver48 1

Ok, makes sense! I put it up over here: #16263

@vidalpascual
Copy link

Yes the wiring is from these dokument, i have a CJMCU.

The sensor has worked with this : https://github.com/shred/kaminari

Then i have changed to Tasmota, better for use at me with the mqtt

And this wil not work

Have you had success with Tasmota? I have the same CJMCU and is not working...

@barbudor
Copy link
Contributor

Have you read the discussion #16400 ?

@device111
Copy link
Contributor Author

What is not working?
Do you know, that the https://github.com/shred/kaminari Projekt work with SPI? You must wire the sensor correct.
read the discussion that barbudor mentiod..

@device111
Copy link
Contributor Author

device111 commented Sep 16, 2022

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.
And you must connect the A0 and A1 to VCC to have the right I2C Address.

Can you test this wiring. If it works, i must change the Docs.

grafik

@device111
Copy link
Contributor Author

ok, i have corrected the Schematic in the Docs. The one should working:

grafik

@ludwich66
Copy link

ludwich66 commented Sep 16, 2022

image

image

PIN 15 (AS3935) = ADD0 = A0
PIN 16 (AS3935) = ADD1 = A1
I see 2 x 10KΩ to GND as Preset on this Picture

L

SET I2C Adress:
The device addresses for the AS3935 in read or write mode are defined by:
0-0-0-0-0-a1-a0-0: write mode device address (DW)
0-0-0-0-0-a1-a0-1: read mode device address (DR)
Where a0 and a1 are defined by the pins 5 (ADD0) and 6 (ADD1).

@device111
Copy link
Contributor Author

ok, then normaly should work without wiring to VCC. The Datasheet says "Connect to GND or VCC".
Let's give it a try..

@device111
Copy link
Contributor Author

device111 commented Sep 16, 2022

you are right...

grafik

this circuit diagram even shows the wrong capacitors of the antenna...:-)

@barbudor
Copy link
Contributor

so if not needed, please cancel your PR

@vidalpascual
Copy link

What is not working?
Do you know, that the https://github.com/shred/kaminari Projekt work with SPI? You must wire the sensor correct.
read the discussion that barbudor mentiod..

SPI wiring and that project works, but I2C wiring and Tasmota not.

@device111
Copy link
Contributor Author

Do you wire to an ESP32 or ESP8266?
Have you tried this wiring?

grafik

@vidalpascual
Copy link

Do you wire to an ESP32 or ESP8266? Have you tried this wiring?

grafik

Yes, I tested that wiring with Tasmota and the AS3935 is not recognised.

I'am testing with a Wemos D1 mini that has an ESP8266.

@HelmiBeh
Copy link

HelmiBeh commented Oct 4, 2024

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!

@sfromis
Copy link
Contributor

sfromis commented Oct 4, 2024

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.

@HelmiBeh
Copy link

HelmiBeh commented Oct 4, 2024

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!

@sfromis
Copy link
Contributor

sfromis commented Oct 4, 2024

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 I2C: AS3935 found at 0x03 at boot, and a lot of "noise" reading like "AS3935":{"Event":5,"Distance":0,"Energy":0,"Stage":7} in the sensor payloads.

@barbudor
Copy link
Contributor

barbudor commented Oct 4, 2024

Figure 19 page 15

@sfromis
Copy link
Contributor

sfromis commented Oct 4, 2024

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.

@device111
Copy link
Contributor Author

device111 commented Oct 5, 2024

I have now found another data sheet for the MOD-1016 breakout board with the AS3935 on it.
(I'm not sure but I think the MOD-1016 board was the one I did my testing with).

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:

  1. the CS pin should NOT be connected to ground. (page 5)
  2. In addition, the AS 3935 probably has a firmware bug. The I2C address cannot be 0x00 (broadcast). (page 4)
  3. Also, in the MOD-1016 schematic, the MISO pin is not connected to anywhere. (Page 7)
  4. The next difference is that AMS has corrected the data sheet with Rev. 1.01 and you should now set the address pins to VREG and not to VCC when the voltage regulator is activated. I don't know whether these changes have been implemented in all available breakout-boards.

Maybe @ludwich66 can write here which module he used. This also seems to work perfectly.
Edit: Ok, Ludwich66 use a MOD1016 Board, as he wrote above.
Question: Have you shorted the CS-GND solder-pad?

MOD1016 Datasheet:
MOD-1016_hw_v8_doc_v4.pdf

actual AS3935 Datasheet v1.04:
AS3935-Datasheet_104.pdf

@sfromis
Copy link
Contributor

sfromis commented Oct 5, 2024

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 0x00 may be useful; however Tasmota already expects address 0x03.

(ludwich66 has not been posting here for two years now).

@device111
Copy link
Contributor Author

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
I2C use. In many devices, the use of CS is optional and allows the microcontroller to
talk to different devices on the one buss. However, in the case of the AS3935, you
will need access to CS since it forms part of the protocol (CS returning high triggers
the AS3935 to execute the command it was given).
"

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.

@sfromis
Copy link
Contributor

sfromis commented Oct 5, 2024

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.

@device111
Copy link
Contributor Author

ahhhh...ok. Thanks sfromis!
Now i understand the english sentenence! I should improve my english knowledge... 😄 😃

@ludwich66
Copy link

ludwich66 commented Oct 6, 2024

Ludwig lebt!
ludwich is alive!
I have the MOD-1016 running in my design.
Only 5 wires are wired, the rest is in its original state.
(GND, VCC, SCK, SDA, IRQ) (+ferrite core)
The whole thing has been running for quite some time without any problems.
image

image image image

@device111
Copy link
Contributor Author

wow, great setup!

@HelmiBeh
Copy link

HelmiBeh commented Oct 9, 2024

@ludwich66: really nice setup!
I use two different boards: GY-AS3935, which doesn't need any connection on SI and CS. MISO is also open. The other is CJMCU-3935, which needs SI high and CS low. MISO is again open. Supply voltage in both cases is 3V3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.