arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.21k stars 4.81k forks source link

AS3935 I2C device goes missing from I2C on restarts #9016

Closed rowanalex123 closed 4 years ago

rowanalex123 commented 4 years ago

PROBLEM DESCRIPTION

AS3935 is detected on I2C on cold starts but goes missing if the device is restarted

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:

Rules output here:

- [ ] Provide the output of this command: `Status 0`:

STATUS 0 output here: 19:30:42 CMD: Status 0 19:30:42 RSL: stat/tasmota_FC5E57/STATUS = {"Status":{"Module":0,"FriendlyName":["Tasmota"],"Topic":"tasmota_FC5E57","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://thehackbox.org/tasmota/release/tasmota.bin","RestartReason":"External System","Uptime":"0T00:01:09","StartupUTC":"2020-08-02T18:29:33","Sleep":50,"CfgHolder":4617,"BootCount":32,"BCResetTime":"2020-08-02T18:15:12","SaveCount":86,"SaveAddress":"F6000"}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS2 = {"StatusFWR":{"Version":"8.3.0(sensors)","BuildDateTime":"2020-05-14T16:18:52","Boot":31,"Core":"2_7_1","SDK":"2.2.2-dev(38a443e)","Hardware":"ESP8266EX","CR":"325/699"}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["abcd",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C8000100060000005A00000000000000","00000000","00006000"]}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS4 = {"StatusMEM":{"ProgramSize":621,"Free":380,"Heap":24,"ProgramFlashSize":4096,"FlashSize":4096,"FlashChipId":"1640EF","FlashMode":2,"Features":["00000809","8FDAA787","0415A3A4","B7FFBFCD","01DA9BC4","64367CC7","00000072"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,14,16,17,20,21,24,29,34","Sensors":"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,31,34,37,39,40,42,43,51,52,55,56,58,59,62,64,66,67"}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS5 = {"StatusNET":{"Hostname":"espgeiger","IPAddress":"192.168.1.118","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"84:F3:EB:FC:5E:57","Webserver":2,"WifiConfig":4,"WifiPower":17.0}} 19:30:42 RSL: stat/tasmotaFC5E57/STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES%06X","MqttClient":"DVES_FC5E57","MqttUser":"DVES_USER","MqttCount":0,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS7 = {"StatusTIM":{"UTC":"2020-08-02T18:30:42","Local":"2020-08-02T19:30:42","StartDST":"2020-03-29T02:00:00","EndDST":"2020-10-25T03:00:00","Timezone":"+01:00","Sunrise":"05:25","Sunset":"20:26"}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS10 = {"StatusSNS":{"Time":"2020-08-02T19:30:42","AS3935":{"Event":0,"Distance":0,"Energy":0}}} 19:30:42 RSL: stat/tasmota_FC5E57/STATUS11 = {"StatusSTS":{"Time":"2020-08-02T19:30:42","Uptime":"0T00:01:09","UptimeSec":69,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"MqttCount":0,"Wifi":{"AP":1,"SSId":"abcd","BSSId":"D4:6E:0E:36:CA:C8","Channel":11,"RSSI":70,"Signal":-65,"LinkCount":1,"Downtime":"0T00:00:03"}}}

- [ ] Provide the output of the Console log output when you experience your issue; if applicable:
  _(Please use_ `weblog 4` _for more debug information)_

Console output here:

00:00:00 CFG: Loaded from flash at F6, Count 86 00:00:00 Project tasmota Tasmota Version 8.3.0(sensors)-2_7_1 00:00:00 WIF: Connecting to AP1 abcd Channel 11 BSSId D4:6E:0E:36:CA:C8 in mode 11N as espgeiger... 00:00:01 WIF: Connected 00:00:01 HTP: Web server active on espgeiger with IP address 192.168.1.118 19:31:36 RSL: tele/tasmota_FC5E57/INFO1 = {"Module":"Generic","Version":"8.3.0(sensors)","FallbackTopic":"cmnd/DVES_FC5E57_fb/","GroupTopic":"cmnd/tasmotas/"} 19:31:36 RSL: tele/tasmota_FC5E57/INFO2 = {"WebServerMode":"Admin","Hostname":"espgeiger","IPAddress":"192.168.1.118"} 19:31:36 RSL: tele/tasmota_FC5E57/INFO3 = {"RestartReason":"Software/System restart"} 19:31:40 RSL: tele/tasmota_FC5E57/STATE = {"Time":"2020-08-02T19:31:40","Uptime":"0T00:00:09","UptimeSec":9,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"Wifi":{"AP":1,"SSId":"abcd","BSSId":"D4:6E:0E:36:CA:C8","Channel":11,"RSSI":74,"Signal":-63,"LinkCount":1,"Downtime":"0T00:00:03"}} 19:31:46 APP: Restarting

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 3456, room 16 tail 0 chksum 0x84 csum 0x84 va5432625 ~ld 00:00:00 CFG: Loaded from flash at F5, Count 87 00:00:00 Project tasmota Tasmota Version 8.3.0(sensors)-2_7_1 00:00:00 WIF: Connecting to AP1 abcd Channel 11 BSSId D4:6E:0E:36:CA:C8 in mode 11N as espgeiger... 00:00:01 WIF: Connected 00:00:01 HTP: Web server active on espgeiger with IP address 192.168.1.118 19:31:51 RSL: tele/tasmota_FC5E57/INFO1 = {"Module":"Generic","Version":"8.3.0(sensors)","FallbackTopic":"cmnd/DVES_FC5E57_fb/","GroupTopic":"cmnd/tasmotas/"} 19:31:51 RSL: tele/tasmota_FC5E57/INFO2 = {"WebServerMode":"Admin","Hostname":"espgeiger","IPAddress":"192.168.1.118"} 19:31:51 RSL: tele/tasmota_FC5E57/INFO3 = {"RestartReason":"Software/System restart"} 19:31:55 RSL: tele/tasmota_FC5E57/STATE = {"Time":"2020-08-02T19:31:55","Uptime":"0T00:00:09","UptimeSec":9,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"Wifi":{"AP":1,"SSId":"abcd","BSSId":"D4:6E:0E:36:CA:C8","Channel":11,"RSSI":72,"Signal":-64,"LinkCount":1,"Downtime":"0T00:00:03"}}



### TO REPRODUCE
Add the DFRobot AS3935 board and click on the restart button on the UI, click Ok to confirm

### EXPECTED BEHAVIOUR
AS3935 is detected on restart and appears on the UI. Instead there are no devices detected.

### ADDITIONAL CONTEXT
 If I add a BME680, it comes back without issues after restarts.

**(Please, remember to close the issue when the problem has been addressed)**
ascillato2 commented 4 years ago

Hi,

Can you update to latest Tasmota and try again please?

Your template shows Tasmota binary firmware version number used: 8.4.0 But your status 0 shows ("Version":"8.3.0(sensors)")

Please update and try again. Thanks.

ascillato commented 4 years ago

@rowanalex123

Hi, any news on this? Were you able to try with latest Tasmota?

rowanalex123 commented 4 years ago

@ascillato Yes I tried initially on 8.4.0 and then downgraded to 8.3.0 to see if this was a regression bug. AS3935 disapears after a "restart 1" command on both versions.

joba-1 commented 4 years ago

an app restart probably does not reset the sensor. Maybe it does not like to be setup twice? Then toggling bit 0 (power) of addr 0x00 and waiting a bit at the start of AS3539Setup() might help.

device111 commented 4 years ago

an app restart probably does not reset the sensor. Maybe it does not like to be setup twice? Then toggling bit 0 (power) of addr 0x00 and waiting a bit at the start of AS3539Setup() might help.

this might be not helped, but the sensor is missing and we don't can send commands.

@rowanalex123 : do you have additional sensors on the bus? what does I2C scan indicate after restart? give please a status0 after a fail restart.

thanks

PS.: please use 8.4.0!

arendst commented 4 years ago

Sorry, I can't help.

I don't understand the device and have no clue how to get rid of the abundance of mqtt messages and gui texts like "noise detected","interrupt with no event","disturber detected". I guess it has something to do with the capacitor data to be entered but my device has a (standard it seems) sticker with the standard "MA5532-AE" label. No clue what 8-bit value (deducted from the code) I should use here.

But at least I can say the device always pops back up after a restart ;-) so you likely have a power issue as @device111 suggested.

device111 commented 4 years ago

yes, the device had a lot of messages and a lot of things to adjust. The device itself is verry complex and you have to study the datasheet. You can watch the youtube Video for a better understanding the settings and the messages. (21 minutes!)

https://www.youtube.com/watch?v=fTEEDfWbGEU

otherwise you can go to https://github.com/arendst/Tasmota/pull/8130 or contact @ludwich66. Ludwich has a lot of Experience with the device.

@arendst The sticker with the "tuningcap" Value is apparently stuck on the outside of the packaging. If the sticker is not there, you can calibrate the sensor with "AS3935calibrate". The device should now calibrated.

The funny thing is, I never had a sensor...my order and my money fell victim to the COVID crisis and the sensor never arrived. All the tests were made by ludwich66. :-)

rowanalex123 commented 4 years ago

I don't have any other device on the i2c bus. If I add a bme680, it comes up after restart correctly. I'm away from my computer for the next one week, will try setting toggling bit 0 (power) of addr 0x00 and post here. I'm using the df robot breakout board of this sensor.

device111 commented 4 years ago

@rowanalex123 can you try the bin here? It reset the device to there defaults every restart and then load the settings from eeprom.

tasmota.bin.gz

alfista2600 commented 4 years ago

FWIW, the Sparkfun version of this sensor says it is not supported on I2C, but they left that code there anyway. SPI is how they recommend interfacing. I have one but haven't submitted a request to have it supported over SPI.

device111 commented 4 years ago

thats definitiv not true. the Sparkfun Sensor have full I2c support and even with a 2nd address.

grafik

alfista2600 commented 4 years ago

I was not clear in my post. They left the circuitry not code.

See notes here may only apply to V2 of the board

https://learn.sparkfun.com/tutorials/sparkfun-as3935-lightning-detector-hookup-guide-v20?_ga=2.115263175.1580721257.1597002705-930883413.1597002705

device111 commented 4 years ago

ah, ok. :-) they don't give code support for I2c, but the sensor can be used with I2c.

alfista2600 commented 4 years ago

Yes, but it may be why you are having inconsistent/intermittent issues:

"SparkFun does not actively support I2C on this product due to the inconsistency of its' implementation by its' manufacturer AMS and their lack of active support of the product."

device111 commented 4 years ago

ok, do you know what errors can occur? they don't write about the detailed issues.

rowanalex123 commented 4 years ago

@device111 thanks for the build.

There's a description of some issues with the device here esp. in the comments, in case you've not come across it before - http://fll-freak.com/blog/?p=554.

I tried with a different NodeMCU board and the AS3935 seems to be coming back after restarts now. I dont know how the board influences the I2C device scan though. I'll keep testing and post here if I encounter the issue with this new board.

Could you please share the code changes you made? I'd like to add them back and retest if I face an issue again.

device111 commented 4 years ago

thanks for the link. So I didn't know the article before.

Several problems are described:

  1. Problem with register 0x00: The problem should not actually occur with Tasmota, since all registers are read with the I2cRead8() function and the function does always a "Repeated Start". But, in your case this could eventually the Issue. The The chip is identified using the 0x00 address. So, we need more investigation, what extactly the Problem is. (So we can read the Chip always after Cold Boot)

  2. Problems with the board / antenna. Unfortunately there is nothing we can do with the Code.

  3. Problems with the IRQ pin. This behavior cannot be suppressed even by SPI communication. This is mostly noticeable in Tasmota with "IRQ with no event".

ok, some questions:

  1. you have no Problems with the new Board?
  2. Do you have tested both Versions of Tasmota with the new board? (Normal and my modified)
  3. What does I2Cscan says if the AS3935 was not detected?

at he moment a make a refactor of the driver and if its ready, i do a Pull-Request with the changes i made.

alfista2600 commented 4 years ago

Not sure if it is helpful but here is some code that runs on an ESP8266 and connects to the sensor over SPI. It uses a REST API to make the data available. I haven't had any lightning in a while so not sure if it is working or not.

https://github.com/shred/kaminari

device111 commented 4 years ago

there is no reason to switch to SPI at the moment.

mar565 commented 4 years ago

What does the status "Interrupt with no Event!" exactly mean? Im getting this status almost constantly and cant figure out how to get rid of it.

device111 commented 4 years ago

This means that an interrupt was triggered via the interrupt pin but there is no event in register 0x03 (Int). The article described by @ rowanalex123 states that the interrupt register is sometimes empty when an interrupt is triggered.

what kind of board do you have? have you checked the wiring of the interrupt Pin? have you only this event or can you simulate a Disturber via an piezzo lighter?

I have written to @ludwich66. He does a logging from his sensor and gave Infos about the counts of "Interrupt with no event".

Now, i have orderd a second time a AS3935. With no testing, its hard to find some issues.

device111 commented 4 years ago

@mar565 do you have defined the right interrupt Pin in Tasmota settings?

mar565 commented 4 years ago

Almost 95% of the time I get "IRQ..", 4% "noise detected" and almost never "listening..". Based on the changing status, I gues the wirering and Tasmota setting are correct. Testing with a piezo lighter has no effect (and today there was a Thunderstrom, also without an effect). I have the MA5532-AX board from AliExpress. IMG_20200822_212225

ludwich66 commented 4 years ago

HI As 3935 User,

I use my AS3935 with a ESP8266 Board . There are no "great" electrical differences but: A stable Poweradapter (2 Meter Cable) 220 mycroF on 3,3 V rail An old Ferrit clamp filter

image

on the Sensor Cable 25cm.

Tasmota Config:

image

This Sensor Settings: 22:31:14 MQT: stat/tasmota_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"}}

Yesterday i changed my Node Red setting. Now it sends a E-Mail for Event "Interrupt with no Events"but there is no Mail yet.

I received 1800 messages Since 1.07.2020 (node red birth. the messages coincide with the lightning card (https://kachelmannwetter.com/de/blitze)

--> Pay attention to a good voltage supply without spikes

ludwich

Jason2866 commented 4 years ago

All sonoff devices do NOT have a good stable power supply. For such a high sensitive sensor a sonoff device is not a good choice

device111 commented 4 years ago

@mar565 what else you have to consider: I don't know your Board but you will need to wire up all of the associated pins for the different boards.

For I2C Use:

device111 commented 4 years ago

new version. go to 9221

device111 commented 4 years ago

@ascillato2 can be closed.

philpetnz commented 4 years ago

I was not clear in my post. They left the circuitry not code.

See notes here may only apply to V2 of the board

https://learn.sparkfun.com/tutorials/sparkfun-as3935-lightning-detector-hookup-guide-v20?_ga=2.115263175.1580721257.1597002705-930883413.1597002705

Not sure if it's relevant, but it worked for me... Most* dev. boards have pull-downs on I2C address pins (A0 & A1) Page 24, in Data Sheet states in bold "The combination a0 = 0 (low) and a1 =0 (low) is explicitly not allowed for I²C communication." I pulled both A0 & A1 HIGH & now everything is working reliable. [ESP-07 & CJMCPU-AS3935]

AS3935 - CJMCU board I2C

device111 commented 4 years ago

Ok, thanks! If you want, Feel free to enter the changes in the Tasmota Docs.

hadahop commented 3 years ago

@rowanalex123 Hi, I also have a DFRobot AS3935 board and can't get it connected to a D1Mini to work.

Bildschirmfoto 2021-09-22 um 11 47 14

How did you do that ?

The DFRobot AS3935 board is recognized, but no lightning bolts are displayed.

11:06:06.001 -> 00:00:00.001 HDW: ESP8266EX
11:06:06.035 -> 00:00:00.050 CFG: Loaded from flash at FA, Count 10
11:06:06.035 -> 00:00:00.055 QPC: Count 1
11:06:06.070 -> 00:00:00.065 Project tasmota - Tasmota Version 9.5.0.8(sensors)-2_7_4_9(2021-09-21T12:38:43)
11:06:06.246 -> 00:00:00.250 I2C: AS3935 found at 0x3
11:06:08.794 -> 00:00:02.006 HTP: Web server active on tasmota-4EFD7B-7547 with IP address 10.1.1.118
11:06:09.820 -> 10:06:09.030 RSL: INFO1 = {"Info1":{"Module":"Generic","Version":"9.5.0.8(sensors)","FallbackTopic":"cmnd/DVES_4EFD7B_fb/","GroupTopic":"cmnd/tasmotas/"}}
11:06:09.820 -> 10:06:09.034 RSL: INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"tasmota-4EFD7B-7547","IPAddress":"10.1.1.118"}}
11:06:09.854 -> 10:06:09.045 RSL: INFO3 = {"Info3":{"RestartReason":"Software/System restart"}}
11:06:13.035 -> 10:06:12.217 QPC: Reset
11:06:13.932 -> 10:06:13.138 RSL: STATE = {"Time":"2021-09-22T10:06:13","Uptime":"0T00:00:09","UptimeSec":9,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":21,"MqttCount":0,"Wifi":{"AP":1,"SSId":"Microwelle","BSSId":"78:8A:20:2A:70:8D","Channel":8,"Mode":"11n","RSSI":74,"Signal":-63,"LinkCount":1,"Downtime":"0T00:00:03"}}
11:06:13.966 -> 10:06:13.160 RSL: SENSOR = {"Time":"2021-09-22T10:06:13","AS3935":{"Event":0,"Distance":0,"Energy":0,"Stage":7}}
11:11:13.980 -> 10:11:13.170 RSL: STATE = {"Time":"2021-09-22T10:11:13","Uptime":"0T00:05:09","UptimeSec":309,"Heap":22,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"Wifi":{"AP":1,"SSId":"Microwelle","BSSId":"78:8A:20:2A:70:8D","Channel":8,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:03"}}
11:11:13.980 -> 10:11:13.192 RSL: SENSOR = {"Time":"2021-09-22T10:11:13","AS3935":{"Event":0,"Distance":0,"Energy":0,"Stage":7}}
11:16:04.958 -> 10:16:04.170 APP: Serial logging disabled

Do I have to change anything on the DFRobot AS3935 board? Bildschirmfoto 2021-09-22 um 11 45 03

Current Settings: Bildschirmfoto 2021-09-22 um 11 48 10