thebedroomlaboratory / BrewMonitor

The Arduino and Cloud-based homebrewing controller
Other
16 stars 6 forks source link

BrewMonitor

The Arduino and Cloud-based homebrewing controller

Homepage: http://thebedlab.com/brewmonitor-the-arduino-and-cloud-based-homebrewing-controller/

Demo sites:

Arduino Library Requirements (latest versions):

REST API Format

Installation

First thing to do is to clone this repository. All paths are given relative to the root of the repository. From here on it is also assumed that the root of the repository will show up at http://domain/

Stable Version (PHP/MySQL Backend with Angular on frontend)

Development Version (Node.js/MongoDB Backend)

MongoDB

Make sure Mongo is installed and running. A dump of the DB was created in Backend using:

cd Backend
mongodump -d brew

This can be loaded locally using:

cd Backend
mongorestore
Node-Red

Download and extract node-red zip file from http://nodered.org/ to Backend/node-red

cd Backend/node-red
npm install --production
npm install mongodb
rm settings.js
ln -s ../settings.js

If you have any complications or want to install Additional Nodes, check the instructions on http://nodered.org/docs/getting-started/installation.html

Apache2 and Node-Red at same time

Configure Apache with the following settings:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

ProxyPreserveHost On
ProxyRequests Off
ProxyPass /brewmonitor/comms ws://127.0.0.1:8123/brewmonitor/comms
ProxyPass /brewmonitor http://127.0.0.1:8123/brewmonitor
ProxyPassReverse /brewmonitor http://127.0.0.1:8123/brewmonitor

You can do this using:

After that, check that your node-red app/server settings match up. This can be found in Backend/settings.js:

You may as well allow AJAX calls from other servers at this point too, if required (Ionic app for instance...)

 httpNodeCors: {
  origin: "*",
  methods: "GET,PUT,POST,DELETE"
 },
Running Server

Make sure MongoDB and Apache are running, then run the following command:

./startNodeRed.sh

This launches the Node-Red server which can then be found at http://domain/brewmonitor/. To run it as a daemon, do the following (sudo may be required for global npm install):

cd Backend/node-red
npm install forever -g
forever start red.js ../BrewMonitor.json