Skip to content

Laravel PHP app for receiving (API) and interacting with data from Raspberry Pi.

Notifications You must be signed in to change notification settings

clayshek/Pi-Data-WebApp

Repository files navigation

Pi Data WebApp

Summary

PHP web application developed with Laravel framework (v5.4) for receiving data from a Raspberry Pi via an API, and displaying that data via a web front-end. In production WIP running on Heroku app engine at http://pidatawebapp.herokuapp.com/. See About page for more info.

How to Install

Pre-requisites:

Installation

git clone https://github.com/clayshek/Pi-Data-WebApp.git
cd Pi-Data-WebApp
composer install

Create your own custom .env file, and update the settings for your environment. Specifically, the DB_ and MAIL_ settings. Laravel configuration overview & details.

Generate an APP_KEY for your environment:

php artisan key:generate

Confirm APP_KEY in .env file updated accordingly.

Run the following to create database tables:

php artisan migrate

Configure your local web server to serve the application. Locally for Dev, use Artisan:

php artisan serve

In prod, I run on Heroku, which requires the included 'Procfile' file. With Heroku, app configuration variables need to be set either via web front end or using heroku cmd line utility. Alternatively, remove .env file from .gitignore to include the config file in Git repo to be attached to Heroku app (less secure).

Raspberry Pi Setup

NOW IN DOCKER - https://github.com/clayshek/apcupsd-raspi

Copy the 2 provided scripts (pi_heartbeat.sh & ups_data_push.sh, see Pi_bash_scripts.md) to a location on the Raspberry Pi and configure Crontab to run the scripts on the desired schedule. Example below runs pi_heartbeat every 10 minutes, and ups_data_push every hour.


0,9,19,29,39,49 * * * * bash /opt/pidata/pi_heartbeat.sh
0 * * * * bash /opt/pidata/ups_data_push.sh

I have an APC model ES350 UPS attached to the Pi via USB, and use the apcupsd (APC UPS Daemon) software for communication to the UPS. This assumes a similar setup, installed & configured as documented at www.apcupsd.org.

High-level overview:

  • Install package: sudo apt-get install apcupsd
  • Set 'ISCONFIGURED=yes' in /etc/default/apcupsd
  • Set following values in /etc/apcupsd/apcupsd.conf:
    • UPSNAME myupsname
    • UPSCABLE usb
    • UPSTYPE usb
    • DEVICE clear out this value
  • Restart apcupsd: sudo /etc/init.d/apcupsd restart
  • Run 'apcaccess status', this should report various UPS related metrics

To-Do

  • User registration & authentication
  • Add role based authorization for add / delete operations.
  • Add OAuth access token based authentication for API
  • Improve error handling
  • Add Pi delete functionality
  • Add graphical line voltage reporting for APC UPS connected to Raspberry Pi
  • Add SMTP support for event-based notifications (Object addition / removal, power related events, metric threshold breaches)

License

This is open-sourced software licensed under the MIT license.

About

Laravel PHP app for receiving (API) and interacting with data from Raspberry Pi.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages