GithubHelp home page GithubHelp logo

pcfens / rpi-as3935-web Goto Github PK

View Code? Open in Web Editor NEW
11.0 6.0 1.0 45 KB

A web server that displays output from an AS3935 connected to a RaspberryPi in real time.

CSS 0.99% Python 42.35% HTML 56.66%

rpi-as3935-web's Introduction

RPi-AS3935-Web

A simple webpage designed to display information read from the AMS Franklin Lightning Sensor.

The website makes use of the RaspberryPi-AS3935 library.

Getting Started

Connecting the AS3935

In my test setup I connected my breakout board to the Pi as shown

AS3935 Pin Raspberry Pi Pin
4 (GND) 25 (Ground)
5 (VDD) 1 (3v3 Power)
10 (IRQ) 11 (GPIO 17)
11 (I2CL) 5 (SCL)
13 (I2CD) 3 (SDA)

Kernel Modules

To run this webserver you'll need to have the correct kernel modules loaded. Adafruit has a nice tutorial set up, though depending on the breakout board that you use, you may not see anything show up when you run i2cdetect.

Python libraries

To directly access the hardware, you'll need to install the python-smbus package available in the repositories on Raspbian.

Other dependencies can be installed using sudo pip install -r requirements.txt. sudo is required unless you use a virtualenv and write udev rules so that the I2C bus is accessible by an unprivilged user.

Configuring the Server

Copy the settings.cfg.sample file to settings.cfg and edit the appropriate portions to match your setup. Each setting has comments to help.

Running the Server

After everything is done, you can start the server by running sudo python lightning_web.py. If everything starts without any errors, you can visit http://pi_address:port/ to interact with the sensor (the default port is 5000).

An upstart/systemd job to start the server on boot will likely come later - we're just not there yet (feel free to submit a PR).

Scaling

Running the server this way does not scale well beyond a few connections. If you need to support more users, I'd suggest looking in to gunicorn, and possibly nginx (configuration information at https://flask-socketio.readthedocs.org/en/latest/).

I've tested running the site with gunicorn using the command

sudo gunicorn \
--worker-class socketio.sgunicorn.GeventSocketIOWorker \
--bind :5000 \
lightning_web:app \
--log-file -

Just ignore the exception it throws early on for now (it appears to be a bug in gunicorn).

If you still have scaling issues (how many people care about lightning at your house anyway?), then things need to be re-designed. At this point you should probably be pushing the data to real server(s) that can re-distribute it as needed.

rpi-as3935-web's People

Contributors

pcfens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

wvanbreukelen

rpi-as3935-web's Issues

Not running after reboot

I installed the web package by cloning it from github. After the installation, it ran and I was able to see the web page, although I couldn't change items via the radio buttons.
After I rebooted, I tried running it again by using sudo python lightning_web.py. All it does now return to the command prompt. There is no process running either. I see no errors nor anything in the syslog.
Any idea on where to start or even to get some error to showup?

I am running a Pi 2 with Raspian Jessie.

Thanks
Steve

Not possible to run lightning_web.py

I get below error and even after making sure the requirements.txt is installed with the appropriate versions listed, it still won't work. Can you help me out here please?

pi@raspberrypi:~/Lightning/RPi-AS3935-Web-master $ sudo python lightning_web.py
lightning_web.py:3: ExtDeprecationWarning: Importing flask.ext.socketio is deprecated, use flask_socketio instead.
from flask.ext.socketio import SocketIO, emit
Traceback (most recent call last):
File "lightning_web.py", line 3, in
from flask.ext.socketio import SocketIO, emit
File "/usr/lib/python2.7/dist-packages/flask/exthook.py", line 110, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.socketio

pip uninstall RPi.GPIO required with latest RPi 4 and Debian Buster 10

With latest iteration of Debian on Raspberry Pi 4 - Buster, you need to unistall library. Default installation after satisfying the README.md requirements returns:

# python lightning_web.py
Traceback (most recent call last):
  File "lightning_web.py", line 5, in <module>
    import RPi.GPIO as GPIO

Proceed to:

# pip uninstall RPi.GPIO
Uninstalling RPi.GPIO-0.5.11:
  Would remove:
    /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.11.dist-info/*
    /usr/local/lib/python2.7/dist-packages/RPi/*
Proceed (y/n)? y
  Successfully uninstalled RPi.GPIO-0.5.11

which gives us:

# pip install RPi.GPIO
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: RPi.GPIO in /usr/lib/python2.7/dist-packages (0.7.0)

and finally:

# python lightning_web.py
 * Running on http://0.0.0.0:5000/
 * Restarting with stat
192.168.1.121 - - [2020-09-08 00:06:09] "GET / HTTP/1.1" 200 5788 0.120335
192.168.1.121 - - [2020-09-08 00:06:09] "GET /static/css/bootstrap-theme.min.css HTTP/1.1" 200 20123 0.002817
192.168.1.121 - - [2020-09-08 00:06:09] "GET /static/css/lightning-sensor.css HTTP/1.1" 200 394 0.002117
192.168.1.121 - - [2020-09-08 00:06:09] "GET /static/css/bootstrap.min.css HTTP/1.1" 200 113788 0.022944
192.168.1.121 - - [2020-09-08 00:06:09] "GET /favicon.ico HTTP/1.1" 404 342 0.016334

Sensitivity problems not really an issue as such.

I have set up the AS3935 on a PiZero up above the gable end of my house. I live in a remote area near the coast in SW Ireland, so very little electrical disturbance.
I am getting lots of strikes even on a clear day with no clouds. I am keeping an eye on Met Eireann for strikes.
I have sensor.set_indoors(False) and I guess looking at the code I need to raise the noise floor.
From your experience have you found a setting which works for you?
I am going to try a setting of 3 (I see the max is 7) and if that is too much reduce it. I also realise that it will take a good while to get it correct because we do not get a lot of lightning here, but that is all part of the fun.
Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.