M
Mepis
- 45
- 18
I very much feel the same way. I originally wasn't going to share it at all. Then I figured it would be nice to give me, and I would just post the repo and let people have a go at it. Then I realized that most people won't even attempt to tackle trying to setup their own web server and DDNS address. Then I figured I'd figure out a way to package it in a nice VM people could just download or very detailed instructions to setup. Then I had that conversation on Reddit with other people...I appreciate your ambition - however I think there is a fundamental issue to your proposed market. I, for one, have no intention of sending my grow data off site. I implement my own system to:
1. Avoid the Revolv syndrome - vendor abandonment. Google bought them, shut down the servers and guess what? No access to the data. They refunded the cost of the appliance - but value lies in data generated.
2. Ability to enhance, reprogram, modify and otherwise hack to my hearts content.
3. Absolute control of the data and who gets access.
Sounds like we have the same goals.... I have specific technical goals to achieve to obtain state of the art indoor grow room efficiency - to allow the ultimate goal of off-grid power use.
To be compelling - your app needs to somehow eliminate work, not just find a way to electronically record what others write on bound paper. Like voice input to record logs. That would be swell.
Thanks! You too! I look forward to seeing your stuff at some point.Good luck with your project!
#!/bin/bash
#set -x
#
#
# read CO2 level Temp and Humidity
#
# Control CO2 valve based on measured value from sensor
#
# Rev 0.5 - basic funcions
# 0.6 - format for redirection to a file
# 0.7 - first go at garbage detection - multiple starts sometimes required without
# some check that input is not sane.
# Daily manual start-stop but otherwise autonomous.
# Logging confirms regulation design.
# First version for regular usage.
# 0.8 - experiments with format for display and logging. Introduce DEBUG variable.
# 0.9 - Time aware for enable valve open. Time in 24hr fmt.
# Currently lighting is asynchronous with the ctlr.
# 0.91 Adding temp, humidity and dewpoint to ouput
#
#
# Need to add -
# - process other var TEMP and Humidity
# - Check for lights ON
# - process for average - lower update rate.
#
# Display does not always use LF. Logging always uses LF.
#
# Initial watermarks - logged when set
# Rationale for values:
#
# to get an accurate low watermark for a run - use an artificially high value.
# high mark is easy since ambient is 400.
#
# Note low mark value will be low (~280) at start.
#
LOWPOINT=2000
HIGHPOINT=400
#
# Setpoints for control
#
# This is the control band range.
#
LOWSET=1200
HIGHSET=1500
#
# Set initial Valve state
#
# Since there is no current method to be sure of valve state
# The design is to always initialize as closed.
#
VALVE=closed
RUNSTATE=online
#
# Set the start and stop times for CO2 enhancement
#
# Start after 8am. Stop (offline) after 7pm
#
TIMESTART=8
#
# Stop at 7pm
#
TIMEEND=19
# Set initial Light state NOT YET IMPLEMENTED
# This is detectable. Before any OPEN action, check for Lights OFF.
#
LIGHTS=on
# Setup port for serial stream
stty -F /dev/ttyUSB0 raw 9600 cs8 clocal
#
#
# Set GPIO pin mode for GPIO25
#
# This is where we assert control of the valve state.
# Initialize as OFF (valve closed)
#
gpio mode 25 output
gpio write 25 0
#
# Capture state to logfile
#
gpio readall >> /var/www/html/CtlrLog`date -I`.txt
#
# initialize variable to some reasonable value
#
level=400
#
# Kick out a few line feeds
echo
echo "-------------------"
echo
echo
#
# Read the serial stream
#
# This is the begin of the endless while-loop.
#
cat /dev/ttyUSB0 | while IFS=":" read -r val1 val2 val3 val4 val5;
do
#
# Discard the header line
#
if [ $val1 == '$CO2' ];
then
continue
fi
#
# Try to discard garbage
#
if [[ $val1 != *ppm ]];
then
continue
fi
# extract the CO2 level in ppm
#
declare -i sample=`echo $val1 | sed -e 's/C//' -e 's/ppm//'`;
#
# extract the temperature in degrees F
#
temp=`echo $val2 | sed -e 's/T//' -e 's/F//'`;
#
# extract the humidity in percent
#
humidity=`echo $val3 | sed -e 's/H//' -e 's/%//'`;
#
# extract the dewpoint
#
dew=`echo $val4 | sed -e 's/d//' -e 's/F//'`;
#
#
#
# This section runs with every sample loop.
#
#
# If the level has not changed - print nothing
#
if [ "$level" -ne "$sample" ];
then
level=$sample;
else
continue
fi
#
# Print the level when it updates
# rev 0.8 updates to print this on the same line NO LF.
#
# To standard out - this is the only output from the script.
# no LF. Could be used with a LCD ( not implemented ).
#
echo -ne " Current Level: $level ppm Status: $RUNSTATE Temp= $temp F Humidity= $humidity % Dewpoint= $dew F \r"
#
# System log basic heartbeat.
#
echo "Current Level: $level ppm Status:$RUNSTATE Temp= $temp F Humidity= $humidity % Dewpoint= $dew F `date` " >> /var/www/html/CtlrLog`date -I`.txt
#
# Set and LOG watermark levels for min-max
#
if [ $level -lt $LOWPOINT ];
then
LOWPOINT=$level
echo "`date` Low mark Set ## $level ppm" >> /var/www/html/CtlrLog`date -I`.txt
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F" >> /var/www/html/CtlrLog`date -I`.txt
fi
if [ $level -gt $HIGHPOINT ];
then
HIGHPOINT=$level
echo "`date` High mark Set ## $level ppm" >> /var/www/html/CtlrLog`date -I`.txt
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F" >> /var/www/html/CtlrLog`date -I`.txt
fi
#
# ACTION : OPEN VALVE
# Test for low setpoint - if less than - open the valve IF the lights are ON.
#
# added check for hours of operation.
#
# -- future dev - add light duration and wait for 30 min after dawn for valve open.
#
if [ $level -lt $LOWSET ];
then
#
# TODO: Add when light detection is present
# <
# Need logic to set based on GPIO read.
# <
if [ $LIGHTS = 'off' ];
then
continue
fi
#
# Check valve STATE - if it is already open, skip VALVE OPEN action.
#
if [ $VALVE = 'open' ];
then
continue
fi
#
# Check the time. hours treated as a simple integer with a known range.
# first check if past shutoff time
# then check if before turn on time
#
if [ `date +%H` -gt $TIMEEND ];
then
gpio write 25 0 # Time to close for the night
VALVE=closed
RUNSTATE=offline
continue
fi
if [ `date +%H` -lt $TIMESTART ];
then
gpio write 25 0 # Time to close for the night
VALVE=closed
RUNSTATE=offline
continue
fi
#
# turn valve on
#
RUNSTATE=online
gpio write 25 1
VALVE=open;
gpio readall >> /var/www/html/CtlrLog`date -I`.txt
#
# print date and action - open valve
#
echo "`date` - VALVE OPEN ACTION "
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F"
echo " High Watermark = $HIGHPOINT Low Watermark = $LOWPOINT"
echo "`date` - VALVE OPEN ACTION " >> /var/www/html/CtlrLog`date -I`.txt
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F" >> /var/www/html/CtlrLog`date -I`.txt
echo " High Watermark = $HIGHPOINT Low Watermark = $LOWPOINT" >> /var/www/html/CtlrLog`date -I`.txt
fi
#
# ACTION : CLOSE VALVE
# Test for high setpoint - if greater than - close the valve.
#
if [ $level -gt $HIGHSET ];
then
#
# Check valve STATE
#
if [ $VALVE = 'closed' ];
then
continue
fi
#
# Close the valve
#
gpio write 25 0
#
# Report and log
#
echo "`date` - VALVE CLOSE ACTION"
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F"
echo " High Watermark = $HIGHPOINT Low Watermark = $LOWPOINT"
VALVE=closed;
echo "`date` - VALVE CLOSE ACTION" >> /var/www/html/CtlrLog`date -I`.txt
echo " Temp= $temp F Humidity= $humidity % DewPoint= $dew F" >> /var/www/html/CtlrLog`date -I`.txt
echo " High Watermark = $HIGHPOINT Low Watermark = $LOWPOINT" >> /var/www/html/CtlrLog`date -I`.txt
gpio readall >> /var/www/html/CtlrLog`date -I`.txt
fi
done
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?