::lcdproclib::cmd ${sid} "widget_add 1 ti title"
::lcdproclib::cmd ${sid} "widget_set 1 ti Vivarium"
-::lcdproclib::cmd ${sid} "widget_add 1 i_up icon"
-::lcdproclib::cmd ${sid} "widget_set 1 i_up 1 2 ARROW_UP"
-::lcdproclib::cmd ${sid} "widget_add 1 i_th string"
-::lcdproclib::cmd ${sid} "widget_set 1 i_th 2 2 T"
-::lcdproclib::cmd ${sid} "widget_add 1 v_ut string"
-::lcdproclib::cmd ${sid} "widget_add 1 i_uh string"
-::lcdproclib::cmd ${sid} "widget_set 1 i_uh 8 2 H"
-::lcdproclib::cmd ${sid} "widget_add 1 v_uh string"
+::lcdproclib::cmd ${sid} "widget_add 1 i_up string"
+::lcdproclib::cmd ${sid} "widget_set 1 i_up 1 2 M"
+::lcdproclib::cmd ${sid} "widget_add 1 i_mt string"
+::lcdproclib::cmd ${sid} "widget_set 1 i_mt 2 2 T"
+::lcdproclib::cmd ${sid} "widget_add 1 v_mt string"
+::lcdproclib::cmd ${sid} "widget_add 1 i_mh string"
+::lcdproclib::cmd ${sid} "widget_set 1 i_mh 8 2 H"
+::lcdproclib::cmd ${sid} "widget_add 1 v_mh string"
::lcdproclib::cmd ${sid} "widget_add 1 i_l icon"
::lcdproclib::cmd ${sid} "widget_set 1 i_l 1 3 ARROW_LEFT"
-i ${logsid} -re "${datapfx}hide-far.* temp=${datare}.*\n" { drawtemp 1 "v_rh" 4 4 }
-i ${logsid} -re "${datapfx}tank-near.* temp=${datare}.*\n" { drawtemp 1 "v_lt" 11 3 }
-i ${logsid} -re "${datapfx}tank-far.* temp=${datare}.*\n" { drawtemp 1 "v_rt" 11 4 }
- -i ${logsid} -re "${datapfx}tank-top.* temp=${datare}.*\n" { drawtemp 1 "v_ut" 3 2 }
- -i ${logsid} -re "${datapfx}tank-top.* humid=${datare}.*\n" { drawtemp 1 "v_uh" 9 2 }
+ -i ${logsid} -re "${datapfx}tank-mid.* temp=${datare}.*\n" { drawtemp 1 "v_mt" 3 2 }
+ -i ${logsid} -re "${datapfx}tank-mid.* humid=${datare}.*\n" { drawtemp 1 "v_mh" 9 2 }
-i ${logsid} -re "${datapfx}dmx-near.* dmx=${datare}.*\n" {
::lcdproclib::cmd ${sid} "widget_set 1 v_ldmx 18 3 ${expect_out(1,string)}"
}
#!/bin/zsh
+DATA_DIR=/home/pi/sc/data
+OUTDIR=/home/pi/public_html
+
DMX_SCALE=5
DMX_SHIFT=20
--lazy
)
-TEMP_ARGS=(
+NEAR_ARGS=(
--step=60 -v "degrees C" --upper-limit ${TEMP_SCALE_UPPER} --lower-limit ${TEMP_SCALE_LOWER} --rigid
--right-axis-label "DMX"
--right-axis ${DMX_SCALE}:-${DMX_SHIFT}
- DEF:tempH=/home/pi/sc/data/heater-temp.rrd:temp:AVERAGE
- DEF:tempHN=/home/pi/sc/data/hide-near-temp.rrd:temp:AVERAGE
- DEF:dmxHN=/home/pi/sc/data/hide-near-dmx.rrd:dmx:AVERAGE
- DEF:tempHF=/home/pi/sc/data/hide-far-temp.rrd:temp:AVERAGE
- DEF:tempTN=/home/pi/sc/data/tank-near-temp.rrd:temp:AVERAGE
- DEF:tempTF=/home/pi/sc/data/tank-far-temp.rrd:temp:AVERAGE
+ DEF:tempH=${DATA_DIR}/heater-temp.rrd:temp:AVERAGE
+ DEF:tempHN=${DATA_DIR}/hide-near-temp.rrd:temp:AVERAGE
+ DEF:dmxHN=${DATA_DIR}/hide-near-dmx.rrd:dmx:AVERAGE
+ DEF:tempTN=${DATA_DIR}/tank-near-temp.rrd:temp:AVERAGE
CDEF:scaled_dmxHN=dmxHN,${DMX_SHIFT},+,${DMX_SCALE},/
LINE:scaled_dmxHN\#000000:"dmx left"
LINE2:tempH\#FF0000:"heater"
LINE2:tempHN\#808000:"hide left"
- LINE2:tempHF\#FF8000:"hide right"
LINE2:tempTN\#00FF00:"tank left"
- LINE2:tempTF\#00FFFF:"tank right"
HRULE:30#800000
)
HUMID_SCALE=$(( 100.0/(TEMP_SCALE_UPPER-TEMP_SCALE_LOWER) ))
HUMID_SHIFT=$(( TEMP_SCALE_LOWER * HUMID_SCALE ))
-TOP_ARGS=(
+MID_ARGS=(
--step=60 -v "degrees C" --upper-limit ${TEMP_SCALE_UPPER} --lower-limit ${TEMP_SCALE_LOWER} --rigid
--right-axis-label "Humidity"
--right-axis ${HUMID_SCALE}:-${HUMID_SHIFT}
- DEF:temp=/home/pi/sc/data/tank-top-temp.rrd:temp:AVERAGE
- DEF:humid=/home/pi/sc/data/tank-top-humid.rrd:humid:AVERAGE
+ DEF:tempT=${DATA_DIR}/tank-top-temp.rrd:temp:AVERAGE
+ DEF:temp=${DATA_DIR}/tank-mid-temp.rrd:temp:AVERAGE
+ DEF:humid=${DATA_DIR}/tank-mid-humid.rrd:humid:AVERAGE
CDEF:scaled_humid=humid,${HUMID_SHIFT},+,${HUMID_SCALE},/
LINE2:scaled_humid\#0000FF:"humidity"
LINE2:temp\#FF0000:"temp"
+ LINE2:tempT\#808000:"top temp"
)
+FAR_ARGS=(
+ --step=60 -v "degrees C" --upper-limit ${TEMP_SCALE_UPPER} --lower-limit ${TEMP_SCALE_LOWER} --rigid
+ --right-axis-label "degrees C"
+ --right-axis 1:0
+ DEF:tempHF=${DATA_DIR}/hide-far-temp.rrd:temp:AVERAGE
+ DEF:tempTF=${DATA_DIR}/tank-far-temp.rrd:temp:AVERAGE
+ LINE2:tempHF\#FF8000:"hide right"
+ LINE2:tempTF\#00FFFF:"tank right"
+)
+
+
+OUTFILE="${QUERY_STRING}.png"
case "$QUERY_STRING" in
- t-4h) OUTFILE="4h.png"; PARAMS=(--start now-4h --title "Melman Vivarium Sensor Data 4h" ${TEMP_ARGS[@]}) ;;
- t-24h) OUTFILE="24h.png"; PARAMS=(--start now-24h --title "Melman Vivarium Sensor Data 24h" ${TEMP_ARGS[@]}) ;;
- t-7d) OUTFILE="7d.png"; PARAMS=(--start now-7d --title "Melman Vivarium Sensor Data 7d" ${TEMP_ARGS[@]}) ;;
- t-30d) OUTFILE="30d.png"; PARAMS=(--start now-30d --title "Melman Vivarium Sensor Data 30d" ${TEMP_ARGS[@]}) ;;
- top-4h) OUTFILE="top-4h.png"; PARAMS=(--start now-4h --title "Melman Vivarium Top Sensor Data 4h" ${TOP_ARGS[@]}) ;;
- top-24h) OUTFILE="top-24h.png"; PARAMS=(--start now-24h --title "Melman Vivarium Top Sensor Data 24h" ${TOP_ARGS[@]}) ;;
- top-7d) OUTFILE="top-7d.png"; PARAMS=(--start now-7d --title "Melman Vivarium Top Sensor Data 7d" ${TOP_ARGS[@]}) ;;
+ near-4h) PARAMS=(--start now-4h --title "Melman Vivarium Near Sensor Data 4h" ${NEAR_ARGS[@]}) ;;
+ near-24h) PARAMS=(--start now-24h --title "Melman Vivarium Near Sensor Data 24h" ${NEAR_ARGS[@]}) ;;
+ near-7d) PARAMS=(--start now-7d --title "Melman Vivarium Near Sensor Data 7d" ${NEAR_ARGS[@]}) ;;
+ mid-4h) PARAMS=(--start now-4h --title "Melman Vivarium Mid Sensor Data 4h" ${MID_ARGS[@]}) ;;
+ mid-24h) PARAMS=(--start now-24h --title "Melman Vivarium Mid Sensor Data 24h" ${MID_ARGS[@]}) ;;
+ mid-7d) PARAMS=(--start now-7d --title "Melman Vivarium Mid Sensor Data 7d" ${MID_ARGS[@]}) ;;
+ far-4h) PARAMS=(--start now-4h --title "Melman Vivarium Far Sensor Data 4h" ${FAR_ARGS[@]}) ;;
+ far-24h) PARAMS=(--start now-24h --title "Melman Vivarium Far Sensor Data 24h" ${FAR_ARGS[@]}) ;;
+ far-7d) PARAMS=(--start now-7d --title "Melman Vivarium Far Sensor Data 7d" ${FAR_ARGS[@]}) ;;
*)
cat <<HERE
Content-Type: text/html
exit 1
esac
-rrdtool graph /home/pi/public_html/${OUTFILE} ${PARAMS[@]} ${COMMON_ARGS[@]} >&2
+CMD=(
+ rrdtool graph ${OUTDIR}/${OUTFILE}
+ ${PARAMS[@]}
+ ${COMMON_ARGS[@]}
+)
+
+touch ${OUTDIR}/.rrdlock
+flock --exclusive ${OUTDIR}/.rrdlock "${CMD[@]}" >&2
cat <<HERE
Location: /~pi/${OUTFILE}
loop_hidenear.setKD(1000.0,0.95)
loop_hidenear.sum_error = -7600.0 # XXX Initialize offset point a bit
-bmetop = BME280.BME280(port=1, address=0x77)
+bmemid = BME280.BME280(port=1, address=0x77)
def with_ow_temp_fk_id2(devfn, loop, s, *arg, **kwarg):
print("WARNING: failed to read %s" % devfn)
# BME280 atop
try:
- top = bmetop.get_data()
- log("bme280-77", top['t'], "tank-top", "/home/pi/sc/data/tank-top-temp.rrd")
- log("bme280-77", top['h'], "tank-top", "/home/pi/sc/data/tank-top-humid.rrd", kw="humid")
- log("bme280-77", top['p'], "tank-top", "/home/pi/sc/data/tank-top-press.rrd", kw="press")
+ top = bmemid.get_data()
+ log("bme280-77", top['t'], "tank-mid", "/home/pi/sc/data/tank-mid-temp.rrd")
+ log("bme280-77", top['h'], "tank-mid", "/home/pi/sc/data/tank-mid-humid.rrd", kw="humid")
+ log("bme280-77", top['p'], "tank-mid", "/home/pi/sc/data/tank-mid-press.rrd", kw="press")
except Exception, e:
- logfail("bme280-77", "hide-top")
+ logfail("bme280-77", "hide-mid", e)
# Log (and populate cache, while we're at it)
with_ow_temp(cache,
"heater-near", "/home/pi/sc/data/heater-temp.rrd")
with_ow_temp(cache,
- "/sys/bus/w1/devices/28-0416526de6ff/w1_slave", log, logfail,
+ "/sys/bus/w1/devices/28-011620c805ee/w1_slave", log, logfail,
"tank-near", "/home/pi/sc/data/tank-near-temp.rrd")
+ with_ow_temp(cache,
+ "/sys/bus/w1/devices/28-0416526de6ff/w1_slave", log, logfail,
+ "tank-top", "/home/pi/sc/data/tank-top-temp.rrd")
+
def checkpid(devfn, temp, loop, s, offset, rrd, logname):
desire = 128.0 + loop.update(temp, time.time())
# 03 00 -- payload length
# 00 -- channel 0 value (ignored by hardware)
# 00 -- channel 1 value
- # 00 -- channel 2 value
+ # nn -- channel 2 value
+ # nn -- channel 3 value
+ # nn -- channel 4 value
# E7 -- footer
- s = "\x7E\x06\x03\x00\x00\x00\x00\xE7"
+ # |hdr|typ|pay len| 0| 1| 2| 3| 4|ftr
+ s = "\x7E\x06\x05\x00\x00\x00\x90\x00\x00\xE7"
# Drive loop
s = with_ow_temp(cache, "/sys/bus/w1/devices/28-011620f10dee/w1_slave",
# Log some other probes
print ("check temps fini: out=%r lhn=(%s)" % (s, loop_hidenear))
- assert(dmxdev.write(s) == 8)
+ assert(dmxdev.write(s) == len(s))
itime = time.time()
s = sched.scheduler(time.time, time.sleep)
tank-near-temp
tank-far-temp
tank-top-temp
+ tank-mid-temp
)
ARGS=(
rrdtool create /home/pi/sc/data/${rrd}.rrd ${=ARGS[@]}
done
-rrdtool create /home/pi/sc/data/tank-top-humid.rrd \
+rrdtool create /home/pi/sc/data/tank-mid-humid.rrd \
--no-overwrite \
--step 60 \
DS:humid:GAUGE:900:-5:105 \
RRA:MAX:0.025:60:87600
-rrdtool create /home/pi/sc/data/tank-top-press.rrd \
+rrdtool create /home/pi/sc/data/tank-mid-press.rrd \
--no-overwrite \
--step 60 \
DS:press:GAUGE:900:-1000:120000 \
</HEAD><BODY>
<TABLE>
<TR>
- <TD><IMG src="cgi-bin/graph.cgi?t-4h" width="1057" height="553"/></TD>
- <TD><IMG src="cgi-bin/graph.cgi?t-24h" width="1057" height="553"/></TD>
- <TD><IMG src="cgi-bin/graph.cgi?t-7d" width="1057" height="553"/></TD>
- <TD><IMG src="cgi-bin/graph.cgi?t-30d" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?near-4h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?near-24h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?near-7d" width="1057" height="553"/></TD>
</TR>
<TR>
- <TD><IMG src="cgi-bin/graph.cgi?top-4h" width="1057" height="553"/></TD>
- <TD><IMG src="cgi-bin/graph.cgi?top-24h" width="1057" height="553"/></TD>
- <TD><IMG src="cgi-bin/graph.cgi?top-7d" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?mid-4h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?mid-24h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?mid-7d" width="1057" height="553"/></TD>
+ </TR>
+ <TR>
+ <TD><IMG src="cgi-bin/graph.cgi?far-4h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?far-24h" width="1057" height="553"/></TD>
+ <TD><IMG src="cgi-bin/graph.cgi?far-7d" width="1057" height="553"/></TD>
</TR>
</TABLE>
<IFRAME src="cgi-bin/log.cgi" width="2116"/>