CommonGarden/Grow-Hub

Name: Grow-Hub

Owner: Common Garden

Description: An extensible Raspberry Pi powered controller for Hydroponics, Aquaponics, Terrariums, Grow-Tents, Bioreactors, and more!

Created: 2017-10-30 17:57:28.0

Updated: 2018-01-03 05:42:37.0

Pushed: 2018-01-12 01:21:00.0

Homepage: null

Size: 58

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Install on Raspberry Pi

Install the latest version of Node. Todo this, either search for an article to help walk you through it or run the following:

 https://nodejs.org/dist/v8.9.1/node-v8.9.1-linux-armv7l.tar.xz
-xvf node-v8.9.1-linux-armv7l.tar.xz
ode-v8.9.1-linux-armv7l

Then copy to /usr/local:

 cp -R * /usr/local/

Test that's it's working with node -v.

Once node.js is working, you're ready for the rest:

 apt-get update
 apt-get install wiringpi usbrelay git i2c-tools
clone https://github.com/CommonGarden/Grow-Hub
row-Hub/driver
install
 node Grow-Hub.js
Connecting to your Grow-IoT instance

By default, the example driver connects to https://grow.commongarden.org.

To change this see the bottom of the example-device.js file. It currently reads.

owHub.connect({
host: 'grow.commongarden.org',
port: 443,
ssl: true
;

For development it's easier to simply connect to you local computer. Find your computer's IP address and change the host, port, and ssl options:

owHub.connect({
host: '10.0.0.198', // The ip address of the host
port: 3000, // The port you are running Grow-IoT on
ssl: false
;
Run on boot

Once you're happy with your driver you'll want to start it on boot in case your device looses power.

Install forever globally.

 npm install forever -g

Then create a new text file in/etc/init.d/:

 nano /etc/init.d/grow

Paste in the follow (note this assumes you installed Grow-Hub in the home folder for a user named pi):

in/bash
c/init.d/grow
rt PATH=$PATH:/usr/local/bin
rt NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules

 "$1" in
t)
 sudo forever start --sourceDir=/home/pi/Grow-Hub/driver -p /home/pi/Grow-Hub/driver -l forever.log -o out.log -e err.log --append Grow-Hub.js

)
 sudo forever stop --sourceDir=/home/pi/Grow-Hub/driver Grow-Hub.js


 "Usage: /etc/init.d/grow {start|stop}"
 1


 0

Make it executable with the following command:

 chmod 755 /etc/init.d/grow 

Feel free to test it:

etc/init.d/grow start

To stop it:

etc/init.d/grow start/stop

If all goes well, make it bootable:

 update-rc.d grow defaults

To remove it from boot:

 update-rc.d -f grow remove

One last step, edit the /etc/rc.local file.

 nano /etc/rc.local

Insert the following line before exit 0:

etc/init.d/grow start

Reboot and your pi should start into the Grow-Hub driver.

Checking logs

To check the logs, ssh into the raspberry pi and see the out.log and error.log files in the home directory. An additional forever.log file can be found in the driver/ folder. See forever documentation for more info.

Hardware setup / Bill of materials.

Control Box

Inside Control box: Inside Control box

Item | Quantity | Cost | Link —————–|———-|——|—————————— Raspberry Pi Model 3B | 1 | $35 | https://www.adafruit.com/product/3055?src=raspberrypi Micro USB Power Supply - 2.5A w Switch | 1 | $9.90 | https://www.amazon.com/Eleduino-Raspberry-Supply-Adapter-Charger/dp/B01DP6NSW2 MicroSD Card - 16GB | 1 | $7.98 | https://www.amazon.com/SanDisk-16GB-Micro-SDHC-Memory/dp/B004G605OA/ 2x20Pin Stacking Header | 2 | $2.60 | https://www.amazon.com/Extra-Female-Stacking-Header-Raspberry/dp/B01IRRCEBK/ Nylon Standoffs | 20pieces | $0.004 | https://www.amazon.com/Generic-Spacer-Assorted-Raspberry-Pi-Standoff/dp/B014J1ZLD6 3-Channel Relay Board for RPi| 1 | $23.99 | https://www.amazon.com/Waveshare-Board-Relay-Appliances-Intelligent/dp/B01FZ7XLJ4 AC Outlet Receptacles | 2 | $0.71 | http://www.homedepot.com/p/Leviton-15-Amp-Duplex-Outlet-White-R52-05320-00W/202066670 Outlet Box - 2-gang | 1 | $2.31 | http://www.homedepot.com/p/2-Gang-25-cu-in-Non-Metallic-Old-Work-Switch-and-Outlet-Box-B225R-UPC/100404169 Enclosure - 3"x6"x9” | 1 | $11 | https://www.amazon.com/OUTDOOR-CABLETEK-ENCLOSURE-UTILITY-CABLE/dp/B00BMVV758/ AC Power Cord | 1 | $2.99 | https://www.amazon.com/Generic-gss-Universal-Standard-Connector/dp/B00F0UO11Y/ Terminal Strip - 20A | 1/10th pack | $1.10 | https://www.amazon.com/Connector-Screw-Terminal-Barrier-Block/dp/B00NQB718E/ Air Temperature & Relative Humidity Sensor (AM2320) | 1 | $1.45 | https://www.aliexpress.com/item/1pcs-AM2320-digital-temperature-and-humidity-sensor-AM2320B-replace-SHT10-SHT11-series/32818920611.html Temperature Probe (Pt100, RTD type) | 1 | $0.97 | https://www.aliexpress.com/item/Waterproof-PT100-Platinum-Resister-Temperature-Sensor-Temp-Probe-free-shipping/32385652607.html Pt100 Interface Board (MAX31865) | 1 | $7.01 | https://www.aliexpress.com/item/CJMCU-31865-MAX31865-RTD-platinum-resistance-temperature-detector-PT100-to-PT1000/32821269399.html DuPont F/F Jumper Wires | 10 | $0.30 (total) | https://www.aliexpress.com/item/40PCS-LOT-10CM-1P-1P-40P-2-54mm-Dupont-Cable-Female-to-Female-Colorful-Dupont-Jumper/2024402290.html Tentacle T3 Board | 1 | $91 | https://www.whiteboxes.ch/shop/tentacle-t3-for-raspberry-pi/ pH Probe | 1 | $7.39 | https://www.aliexpress.com/item/New-Arrival-PH-Electrode-Probe-BNC-Connector-for-Aquarium-PH-Controller-Meter-Sensor-gib-Best-Promotion/32781193789.html Atlas Scientific pH Interface Board | 1 | $38 | https://www.atlas-scientific.com/product_pages/circuits/ezo_ph.html Oxidation-Reduction Potential (ORP) Probe | 1 | $41.95 | https://www.amazon.com/gp/product/B007Z4GBSY/ Atlas Scientific ORP Interface Board | 1 | $38 | https://www.atlas-scientific.com/product_pages/circuits/ezo_orp.html Atlas Scientific Dissolved Oxygen (DO) Probe | 1 | $198 | https://www.atlas-scientific.com/product_pages/probes/do_probe.html Atlas Scientific DO Interface Board | 1 | $44 | https://www.atlas-scientific.com/product_pages/circuits/ezo_do.html

Optional Bluetooth setup

These instructions come from this Headless Raspberry Pi configuration over Bluetooth article. Thanks to Mozilla and Patrick Hundal for providing an excellent resource.

Let?s start by creating the main script that will set up and establish the default Bluetooth services and serial port you will connect to on startup.

You?ll create this file in the root directory, like so:

 nano /btserial.sh

Add the following lines to the script:

in/bash -e

t the display name of the RaspberryPi so you can distinguish
r unit from others in the Bluetooth console
ry useful in a class setting)

 PRETTY_HOSTNAME=raspberrypi > /etc/machine-info

it /lib/systemd/system/bluetooth.service to enable BT services
 sed -i: 's|^Exec.*toothd$| \
Start=/usr/lib/bluetooth/bluetoothd -C \
StartPost=/usr/bin/sdptool add SP \
StartPost=/bin/hciconfig hci0 piscan \
/lib/systemd/system/bluetooth.service

eate /etc/systemd/system/rfcomm.service to enable 
e Bluetooth serial port from systemctl
 cat <<EOF | sudo tee /etc/systemd/system/rfcomm.service > /dev/null
t]
ription=RFCOMM service
r=bluetooth.service
ires=bluetooth.service

vice]
Start=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100 -a pi

tall]
edBy=multi-user.target


able the new rfcomm service
 systemctl enable rfcomm

art the rfcomm service
 systemctl restart rfcomm

Save the file, and then make it executable by updating its permissions like so:

chmod 755 /home/pi/btserial.sh

Now you have the basics of the script required to turn on the Bluetooth service and configure it. But to do this 100% headless, you?ll need to run this new script on startup. Let?s edit /etc/rc.local to launch this script automatically.

 nano /etc/rc.local

Add the following lines after the initial comments:

nch bluetooth service startup script /home/pi/btserial.sh
 /btserial.sh &

Save the rc.local script.

Now you are ready to go. Plug in power to the Rpi and give it 30 seconds or so to startup. Then unplug it, and plug it in again and let it boot up a second time. Restarting the Bluetooth service doesn?t work correctly, so we need to reboot.

Now let?s connect.

Connecting to your RPi via Bluetooth

On your desktop/laptop, open up your Bluetooth preferences and ensure Bluetooth is enabled.

Select ?raspberrypi? (or whatever you have used for PRETTY_HOSTNAME in the btserial.sh script) when it appears and pair with it. It should pair automatically (remember what we said earlier about security issues?)

Open a terminal window on your local machine, and start a screen session to connect via the new Bluetooth serial port created from the RPi connection. First let?s check the name of the serial connection:

dev/cu.*

This should produce a list of available serial ports, one of which should now be named after your pi. Then we can connect.

en /dev/cu.raspberrypi-SerialPort 115200

Give it a second, and you should be at the prompt of the RPi console! Congrats!

After you setup a solid wifi connection, it's good to secure the bluetooth configuration. To do so, Let?s edit /etc/rc.local to NOT launch the btserial.sh script automatically.

 nano /etc/rc.local

Comment out the following lines:

nch bluetooth service startup script /home/pi/btserial.sh
o /btserial.sh &

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.