Code Monkey home page Code Monkey logo

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

Watchers

 avatar

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.