shred / kaminari

AS3935 and ESP8266 based Franklin Lightning Detector
GNU General Public License v3.0
41 stars 10 forks source link

Calibrated antenna frequency 0 Hz #1

Closed HaViGit closed 4 years ago

HaViGit commented 4 years ago

First of all, thank you for sharing this project. I followed your instructions and the sketch runs. Unfortunately, the serial monitor reports the calibrated antenna frequency is 0 Hz and that seems wrong to me. Below the relevant Serial Monitor output. Can you advise me what to do?

Calibrating antenna... Calibrated antenna frequency: 0 Hz MDNS responder started Server is listening on port 80 Connected to TS123 IP address: 192.168.2.39 MAC: 80:7D:3A:66:AB:EE

shred commented 4 years ago

The only reason for 0 Hz after calibration is a problem with the interrupt.

What ESP board are you using?

HaViGit commented 4 years ago

Thanks for your fast respond! The board I use is a Wemos D1 Mini (not the pro), these are my definitions in the sketch:

define SPI_CS 15 // IO15 (D8)

define SPI_MOSI 13 // IO13 (D7)

define SPI_MISO 12 // IO12 (D6)

define SPI_SCK 14 // IO14 (D5)

define AS_INT 5 // IO5 (D1)

define NEOPIXEL 4 // IO4 (D2)

Can you tell me how to connect the AS3935 sensor when using above definitions and the Wemos board? As you know, these are the pins:

Vcc → 3.3 V GND → GND SCL → MOSI → MISO → CS → SI → IRQ → EN_V → A0 → A1 →

shred commented 4 years ago

The Wemos D1 Mini seems to be the same type as the board I am using. The correct wiring is:

Vcc → 3.3 V GND → GND SCL → D5 MOSI → D7 MISO → D6 CS → D8 SI → GND IRQ → D1 EN_V → GND A0 → GND A1 → GND

Be careful with the wiring for MISO and MOSI. The correct wire order on the ESP side is D5-D7-D6-D8, not D5-D6-D7-D8. I had them mixed up on my first wiring attempt.

Thinking about your problem again, it's also possible that the ESP cannot talk to your AS3935 at all. Anyway, my bet is on a wiring issue.

HaViGit commented 4 years ago

After re-wiring as described and double checking, the calibrated antenna frequency is still reported as 0 Hz. During calibration my scope shows a signal on the IRQ line (D1). Although I am using a Wemos D1 mini like you did, do you think this board (sometimes) cannot talk to the AS3935 board?

Also not sure if this AS3935 board is a good choice, there are many issues reported on the internet, especially about calibration. So I now consider to order the SEN0290 sensor from DFRobot.

shred commented 4 years ago

I have added a few diagnostics logs in commit 49baecdd. It should tell you whether the AS board is not visible, or if the IRQ signal is just missing.

"No AS3935 was detected. Please check your wiring!" -> ESP cannot talk to the AS3935. (Bad SPI wiring?) "No interrupt detected during calibration. Please check your wiring!" -> ESP does not receive interrupts. (Bad IRQ wiring?)

You are right, calibrating the AS3935 is difficult. However, the Kaminari firmware should do most of the calibration work for you.

HaViGit commented 4 years ago

To be sure it was not the Wemos D1 Mini I have replaced it with another one, a Pro version. Running your latest sketch this it the serial monitor output:

Calibrating antenna... No interrupt detected during calibration. Please check your wiring! Warning: calibrated frequency is out of tolerance range. Calibrated antenna frequency: 0 Hz Server is listening on port 80

Wiring is okay, board should not be the problem so only the AS3935 sensor seems to cause the issue. Especially since the sensor can only be tested during a thunderstorm, I must be sure that it is reliable. I think this sensor board is not and I have lost confidence, partly because of the many issues on the internet. I am going to order the sensor from DFRobot so I have to be patient.

Anyway thanks for helping Richard!

shred commented 4 years ago

I'm sorry that I couldn't help you, but I'm out of clues. You said there is a signal on the IRQ line, but still the Wemos does not receive any interrupts. Maybe the Wemos ESP firmware is just different to the firmware on my ESP?

But if you need a reliable solution, this might be the wrong project for you anyway. It is just meant for experimental purposes.

I'm closing this issue. Feel free to reopen it if you found something.