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.



On Monday, 8 July 2019 04:48:22 UTC-4, dan Forster wrote:

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

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/ccae803c-1645-4de7-99ea-4c74a6795e90%40googlegroups.com.

Reply via email to