NAME
App::RPi::EnvUI - One-page asynchronous grow room environment control web application

SYNOPSIS
cd ~/envui
sudo plackup bin/app.pl
Now direct your browser at your Pi, on port 3000:
http://raspberry.pi:3000
DESCRIPTION
A self-contained web application that runs on a Raspberry Pi and monitors and manages an indoor grow room environment, with an API that can be used external to the web app itself.
***NOTE*** This distribution is still in heavy development. It will unit test on any *nix PC, but at this time, it will only run correctly on a Raspberry Pi with wiringPi installed. We also require sudo
to run the webapp, due to limitations in other software I rely upon, but I've got fixes in the works to eliminate the sudo
requirement.
This distribution reads environmental sensors, turns on/off devices based on specific thresholds, contains an adjustable grow light timer, as well as feeding timers.
The software connects to Raspberry Pi GPIO pins for each "auxillary"
, and at specific times or thresholds, turns on and or off the 120/240v devices that you've relayed to that voltage (if you choose to use this functionality).
Whether or not you connect/use the automation functionality, the web UI is a one-page app that relies on jQuery/Javascript to pull updates from the server, push changes to the server, and display up-to-date live information relating to all functionality.
Buttons are present to manually override devices (turn on/off) outside of their schedule or whether they've hit thresholds or not. Devices that have been overridden through the web UI will not be triggered by automation until the override is lifted.
The current temperature and humidity is prominently displayed as are all of the other features/statistics.
This is pretty much a singleton application, meaning that all web browsers open to the app's UI page will render updates at the same time, regardless if another browser or the automation makes any changes.
WHAT IT DOES
Reads temperature and humidity data via a hygrometer sensor through the RPi::DHT11 distribution.
It then allows, through a one-page asynchronous web UI to turn on and off 120/240v devices through buttons, timers and reached threshold limits.
For example. We have a max temperature limit of 80F. We assign an auxillary (GPIO pin) that is connected to a relay to a 120v exhaust fan. Through the configuration file, we load the temp limit, and if the temp goes above it, we enable the fan via the GPIO pin.
To prevent the fan from going on/off repeatedly if the temp hovers at the limit, a minimum "on time" is also set, so by default, if the fan turns on, it'll stay on for 30 minutes, no matter if the temp drops back below the limit.
Each auxillary has a manual override switch in the UI, and if overridden in the UI, it'll remain in the state you set.
We also include a grow light scheduler, so that you can connect your light, set the schedule, and we'll manage it. The light has an override switch in the UI, but that can be disabled to prevent any accidents.
...manages auto-feeding too, but that's not any where near complete yet.
HOW IT WORKS
Upon installation of this module, a new directory envui
will be created in your home directory. All of the necessary pieces of code required for this web app to run are copied into that directory. You simply change into that directory, and run sudo plackup bin/app.pl
, then point your browser to http://raspberry.pi:3000
.
ROUTES
/
Use: Browser
Returns the pre-populated template to the UI. Once the browser loads it, it does not have to be reloaded again.
Return: Template::Toolkit template in HTML
/light
Use: Internal
Returns a JSON string containing the configuration for the light
section of the page.
Return: JSON
/water
Use: Internal
Returns a JSON string containing the configuration for the water
(feeding) section of the page.
Return: JSON
/get_config/:want
Use: Internal
Fetches and returns a value from the core
section of a configuration file.
Parameters:
:want
The core
configuration directive to retrieve the value for.
Return: String. The value for the specified directive.
/get_control/:want
Use: Internal
Fetches and returns a value from the control
section of a configuration file.
Parameters:
:want
The control
configuration directive to retrieve the value for.
Return: String. The value for the specified directive.
/get_aux/:aux
Use: Internal
Fetches an auxillary channel's information, and on the way through, makes an App::RPi::EnvUI::API switch()
call, which turns on/off the auxillary channel if necessary.
Parameters:
:aux
Mandatory, String. The string name of the auxillary channel to fetch (eg: aux1
).
Return: JSON. The JSON stringified version of an auxillary channel hashref.
/fetch_env
Use: Internal
Fetches the most recent enviromnent details from the database (temperature and humidity). Takes no parameters.
Return: JSON. A JSON string in the form {"temp": "Int", "humidity": "Int"}
/set_aux/:aux/:state
Use: Internal
Sets the state of an auxillary channel, when an on-change event occurs to a button that is associated with an auxillary.
Parameters:
:aux
Mandatory: String. The string name of the auxillary channel to change state on (eg: aux1
).
:state
Mandatory: Bool. The state of the auxillary after the button change.
Return: JSON. Returns the current state of the auxillary in the format {"aux": "aux_name", "state": "bool"}>.
AUTHOR
Steve Bertrand, <steveb@cpan.org<gt>
LICENSE AND COPYRIGHT
Copyright 2016 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.