fourstix / Sparkfun_CircuitPython_QwiicAS3935

CircuitPython library for the Sparkfun Qwiic AS3935 Lightning Detector
MIT License
2 stars 6 forks source link

Lightning Detector does not appear to be connected. Please check wiring. #20

Closed emersonsc closed 2 years ago

emersonsc commented 2 years ago

I had to modify where the interrupt and CS pins were connected. I changed the interrupt to D20 because of its placement to the socket vs pinout on the perma-proto hat I was building.

I was assuming the CS was the CE0/1 pin because it was using the MISO/MOSI pins. I couldnt use CE0 because its being used by my MCP3008. I found that multiple devices could use the MISO/MOSI pins, which is why there was a CE0 and CE1 pin, so I ran the CS pin to the CE1 pin on the board, and gave it the D7 pin designation. Also, the MISO on the AS3935 is connected to the MOSI on the Pi, and vs versa for the MOSI/MISO. I also tried swapping them to see if that was the issue, and it wasnt. Continuity was checked and verified between connectors.

Am I wrong for that assumption? Does the CS pin need to be moved to another pin before it will be recognized?

here is my copy of the pin designation in the code:

Set up Interrupt pin on GPIO D6 with a pull-down resistor

as3935_interrupt_pin = digitalio.DigitalInOut(board.D20) as3935_interrupt_pin.direction = digitalio.Direction.INPUT as3935_interrupt_pin.pull = digitalio.Pull.DOWN

Create a library object using the Bus SPI port

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)

Set up chip select on D20

CS can be any available GPIO pin

cs = digitalio.DigitalInOut(board.D7) cs.direction = digitalio.Direction.OUTPUT

lightning = sparkfun_qwiicas3935.Sparkfun_QwiicAS3935_SPI(spi, cs)

My Error:

======================== RESTART: /home/pi/WS2/as3935.py ======================= AS3935 Franklin Lightning Detector Lightning Detector does not appear to be connected. Please check wiring.

fourstix commented 2 years ago

Does it work if you move CS back to pin D20? That's my first suggestion for debugging. If that works, then it's the CS pin you chose is probably not available, and you should use a different pin.

The key is for CS to be on an available (unused by some other function) GPIO pin. Many of the GPIO pins do double-duty, so perhaps CE1 (D7) is reserved for the second SPI channel it may not available when you're using the first SPI channel.

The problem is initialization code can sometimes over-ride a program's settings for some other function that function is not even used. For that reason I would recommend to stay away from the second SPI pins, even though you aren't using that function.

If you can't use GPIO20 I would recommend trying one of the other unused GPIO pins first. Try GPIO 5, 6, 16, 17 or 22 to 27. It can be a challenge sometimes to find a GPIO pin that's available when you're doing a project.

emersonsc commented 2 years ago

I did end up going with another pin (one verified only had 1 duty) and it "works" now. The only issue is that I seem to get a LOT of false interupts. I have the hide false interupts option active, but these interupts say lightening detected 1km away.

fourstix commented 2 years ago

Glad it worked for you