Hi,
I bought one of these from eBay - MA5532 AS3935 2.4V to 5.5V Lightning
Fulmine Sensor Breakout SPI/I2C Antenna. I have connected it all up and
have it working fine, confirmed by using the demo script and install
instructions supplied here https://github.com/pcfens/RaspberryPi-AS3935.
I can see that a few people had problems connecting the module, so I have
attached a picture of how I have wired to get it working perfectly (note one
address line has to be set to common ground and the address is 00x0 NOT 00x3).
I then followed these instructions https://github.com/weewx/weewx/wiki/as3935 in order that it can be used within my weewx weather station. I have managed to do everything as it says on this page, including the part at the bottom of the page with regards to the extra sqlite database holding the lightening detector data (which I confirmed exists in the same place as the weewx db).
Now I am using the Seasons skin and would like to get help on adding the two new lightening detector values (lightning_strikes and avg_distance)into the Seasons skin web page (at the bottom of the Current Conditions list). I think the file I need to alter is /etc/weewx/skins/Seasons/current.inc.
I am OK with electronics and getting better at Linux, but I am terrible at HTML. Any pointers would be greatly appreciated...
Dan
Mikael,
The two pads A0 and A1 are for setting the base address and are not allowed to float (not documented very well so this stumped me for ages). Your setup is exactly (all be it with a different base address) the same as mine by the looks of things.
When you stop and then restart start weewx using: -
sudo /etc/init.d/weewx stop
sudo /etc/init.d/weewx start
and then issue this command quickly: -
tail -f /var/log/syslog
you should see the AS3935 load and adjust itself for noise. Bear in mind where you are using this board, it is sensitive to noise around 500khz, which can occur many places inside a house (bad and cheap LED lamps are very noisy). If you can use outside in a weatherproof housing you would experience less interference (Google about long cables from the board to your PC, this needs to be done correctly too).
Take care
Dan.
Thanks
Hi,I have seen this a number of times with these sensors, what I have done is the following to make it less of an issueChecking for loose wires or wires not making good contact at either the GPIO pins or the device..Power cycle the system.Replacing the device.Making sure there are no other devices with the same bus and address being usedPutting a while loop with a fixed loop count and a try except around the i2cbus read and sleeping for a second or two before trying the read again.. (This is the best solution and if it is still failing after 10-20 seconds of trying then there is probably a hardware failure most likely the device or a loose connection.Thanks Jerry
| Sorry I have not been about and replying to board messages. Started some DIY project which turned out larger than expected... This is how I got my AS3935 to work in Weewx. It may not bee 100% correct, but it is now working on two pi's really well. Note if you think you are going to run this on 6" pieces of cable, so its close to the pi, indoors, next to all your gizzmos, the lightning will bite your bum for this thing sees it. Its best run in a low noise environment (away from power supplies, cheap LED lights, computer screens, etc). From what I can gather, its a 500khz receiver and some clever logic, so like any radio, it likes to be able to see the sky. I will start from scratch so you can get going from a new pi sdcard/AS3935 board This is the detection board I use - https://www.ebay.co.uk/itm/AS3935-Lightning-Strike-Storm-Distances-Detector-I2C-SPI-Sensor-Programmable/333265065400?_trkparms=ispr%3D1&hash=item4d982555b8:g:VWUAAOSw1NNdKCt2&enc=AQAEAAAB4BPxNw%2BVj6nta7CKEs3N0qX6knsPaWu2HyFk9u1VHKBpz81ghsTUEAWuMAkGOyv6nDm%2FfHF6ZNRVWUmyw6fMizGZ%2BYp4db2m9KpEC601RxylniwLIMm1Yna7V1VtB3WNTdeLsrOFmUXb8ykzBxZK2B3hLzfgKkhHP80k%2BXuEpKA7AgDyaSN%2FJluRWLSOUQ88THmlkf3DW0W6wL2mUZW5Sp9gkMFWxvt2OpppfyNs2YHI%2B2C%2Ftbi5YMd%2BCv5q6K300H7lsatLWwQEkE6kv1YXLLis4zt4NUw58qFrTss5O%2B%2FnahobycDwpibwG%2B%2Bj8LZ5Hn3HJgTc8sQFNyhu%2Bm6M2RUolopnAvcJu%2BWCVgM%2Fz3fr0O7l1u%2FZ1cd64SuOKVm%2FvCNIDddFrgZNW0gbMjAVxwlS11mmQuiIowAqFlf6d16f7t1yrCXjHYPZyTEqdNhTNpycb1IGseu6FoaXpJquvoB4nZrnPvn0qe7P1xPdyHVfNXh224r8jd4NDdC0jCDVDJlJD8ilWZKXe6%2Fb5sNQIoJqw5tWlPbv5gbq%2FC%2BdpTM%2BJMKdeeAPfLpHN%2FpirKMAKcbKuW6wydhGa7aa%2BRk6SnCsySeIvixE2%2Fet4FPn%2BRvEQVFVNg2M1L4tkPkpFW6bdA%3D%3D&checksum=333265065400e9f0e246d5364032ab0e55b879590ef8 - they seem fairly tough little things to be honest and can seemingly withstand lots of abuse - (I must have changed every wire ((not power pins of course)) in my experimentation's). Using RPi 3 board - using this image https://downloads.raspberrypi.org/raspbian/images/raspbian-2018-11-15/. Its not the latest - I prefer something tried and tested and sort of bug free. NOTE - once the image is burnt to sdcard (https://www.balena.io/etcher/ makes prepping sdcards a cup of tea - DONT buy cheap sdcards, they will make the system crawl like a snail), eject card, then reinsert to the same MAC/WIN PC you just prepped card on, then add a little file called ssh (make with a text editor) with no extension (so thats no full stop after ssh file name - just a file called ssh) to the bootable partition (the partition you see when you insert this rpi OS ready sdcard into a MAC/WIN machine). This enables ssh access as default. I dont use a desktop on the pi, just ssh. Put new card in pi - boot - log in via ssh run sudo rpi- config = enable IC2 and expand filesystem, change your locale and give the pi a hostname that makes sense (then it can be any IP it wants to be, you can easily look up on your LAN using hostname - easier to remember than IP addresses. Reboot pi. Update the pi when its rebooted (sudo apt-get update - and sudo apt-get upgrade). I also change the default pi password, just to be safe (note to use this new password when you reboot pi!). Reboot pi - ssh in (I run everything from my home pi directory unless otherwise stated) Install apache2 - sudo apt-get install apache2 -y (I like this to be on the pi so weewx sees it on install). Install weewx as follows (or any other way that you like, this adds the repository to the pi so updating and installation is real easy). wget -qO - http://weewx.com/keys.html | sudo apt-key add - wget -qO - http://weewx.com/apt/weewx.list | sudo te e /etc/apt/sources.list.d/weewx.list sudo apt-get update sudo apt-get install weewx Now when you do a sudo apt-get update/upgrade, weewx gets updated too. Power down you pi Wire up your as3935 module (earth yourself first for a few seconds, the little pcb is static sensitive). Board VDD = 3.0VDC - PIN # 1 - RED Board GND = Ground - PIN # 6 - BLACK Board SCK/SCL = SCL - PIN # 5 - GPIO 3 - WHITE Board MOSI/SDA = SDA - PIN # 3 - GPIO 2 - GREEN Board IRQ = Pin #11 - GPIO 17 - YELLOW Board SI = 3.0VDC - Pin #17 for i2c - RED Board A0 and A1 = 3.0VDC - Pin #17 I use a soldering iron to make the last 3 connections above to pin #17 (modify some push on connections with the soldering iron rather than solder anything directly to the pi) - ditto push on connections for the AS3935 board. The reason to put 3V on A0 and A1 is to give it an address that can read by by ic2-tools. Power up your pi and ssh in. Type - sudo apt-get install i2c-tools Type i2cdetect -y 1 You should now see the module show up as address 03 (if you don't use the address pins of the module A0 and A1 - you leave then unconnected for instance - the module will have an address that wont show on ic2detect). I then install the python library using - sudo pip install RPi_AS3935 this makes the module directly accessible by python. I then install smbus - sudo apt-get install python-smbus I then run the Weewx installer for the AS3935 using this link https://github.com/weewx/weewx/wiki/as3935 I then edit weewx.conf like this - sudo nano /etc/weewx/weewx.conf Go to the end of the file, I then alter the AS3935 section at the end like this [AS3935] bus = 1 indoors = false # set to True if indoors noise_floor = 0 calibration = 6 pin = 17 address = 3 binding = archive Save this file Reboot pi (some say just restart weewx service but when I fiddle lots I like to reboot) Once pi has rebooted, as quick as you can type sudo tail -f /var/log/syslog The pi will now display services etc. as they start, including weewx. Look carefully for the 'noise level too hi' line If its running all OK, move to the next part... Now its time to alter the weewx schema so the two new variables are recorded in the weewx database (two new variables being lightning_strikes and avg_distance) For this I followed this page https://github.com/poblabs/weewx-belchertown/wiki/Adding-a-new-observation-type-to-the-WeeWX-database Read it through a couple of times until it makes sense. Dont forget, you are substituting [('appTemp', 'REAL'), ('windrun', 'REAL')] with [('lightning_strikes', 'REAL'), ('avg_distance', 'REAL')] Now you can alter one of the default skins (I use Seasons and played with this so it shows both the new values in text and graph format) NOTES - My first port of call for all help with weewx is the forum. If you get stuck, post a message. I have used many web sites to help me make the list above so many thanks go to all the clever folk I leanrt from. |
Hi Dan,Nice write up of your work.Here are a couple items to help with the correctness of the device.If you are using the very common python code found on the net there are a number of issues with it.The big one is the disturber mask part. In the specs when a disturber is detected the device turns off for a 1.5 seconds. It also sends the interrupt. If you are using the python code the interrupt handler turns on the mask interrupt bit in the device. So now no more interrupts but the device still turns off and this is bad. Also to make things worse very far away lightning is sometimes detected as a disturber. So IMHO I would disable the setting of the mask bit and if you are having a lot of issues with disturbers either move the device or change the Watchdog setting, or the AFE setting or the Spike setting or the Noise setting to reduce the number of disturbers. This is not a perfect solution since changing the settings reduces the device sensitivity but at least it does not turn it off for a 1.5 seconds.The next problem is the Noise threshold part of the python code. The problem here is noise can come and go but the code only raises the Noise Threshold there is no code for lowering it. Again IMHO I found that it is best to disable this code and if the noise is truly an issue manually raise the Noise threshold or put in timer code that lowers it to see if the noise is still high.Another code issue is that there is no auto calibrate of the tune cap. There does exist a "c" version for auto tune and I have written my own python version of auto tune. Auto tune IMHO is only needed if you have the device outside where there are large temp swings. I have found that as the devices get hot the tune cap value needs to go higher to keep it as close as possible to 500khz. The specs state that the other oscillators are temp compensated but nothing about the 500khz oscillator. Usually the change is just one or two steps up or down. So I run the auto-tune 3 times a day (morning, noon,night) and if the device is detecting lightning then I skip the auto-tune for that time.Thanks Jerry