Heizung Temperature Measurement, Support Programs
The temperature measurement, diagram generation and web-cam snapshots are done in about 30 second intervals. See description in HeizungTempMess (German) for the self written programs (in Python and shell script).
Here the Linux support programs from SlugOS 4.8 (see Nslu2Einrichten) and Debian (see DockStarOverview) repository will be described.
In SlugOS 5.3 a memory leakage problem prevented me from using this application. While the version with analog sensors run very reliable, the version with digital sensors has a problem about every 2 weeks, and needs a restart.
The normal ipkg packages: rudi@LKG300DB0:~$ sudo ipkg update Downloading http://ipkg.nslu2-linux.org/feeds/slugosbe/cross/4.8-beta/Packages.gz Downloading http://ipkg.nslu2-linux.org/feeds/slugosbe/native/4.8-beta/Packages.gz Updated list of available packages in /var/lib/ipkg/native The optware packages: rudi@LKG300DB0:~$ sudo ipkg-opt update Downloading http://ipkg.nslu2-linux.org/feeds/optware/slugosbe/cross/unstable/Packages.gz Updated list of available packages in /opt/lib/ipkg/lists/optware
Now in September 2012 I could port the application to the Seagate Free Agent Dockstar computer with Debian Linux, please see DockStarDebian. I hope this will run more stable than the RAM limited NLU2 box (32 MB). Actually only 41-43 MB from the 128 MB RAM are used.
Temperature Data Collection, digitemp
The program digitemp was written from Brain C. Lane http://www.digitemp.com . It installs the following programs:
$ sudo ipkg-opt install digitemp rudi@LKG300DB0:~$ ls -ls /opt/bin/digi* 0 lrwxrwxrwx 1 root root 24 Mar 3 11:22 /opt/bin/digitemp -> /opt/bin/digitemp_DS9097 52 -rwxr-xr-x 1 root root 51636 Sep 10 2008 /opt/bin/digitemp_DS2490 51 -rwxr-xr-x 1 root root 50860 Sep 10 2008 /opt/bin/digitemp_DS9097 55 -rwxr-xr-x 1 root root 55044 Sep 10 2008 /opt/bin/digitemp_DS9097U Explanation: DS9097 is the RS232 to 1-wire adapter. It can be build homemade. With the softlink "digitemp" the suitable adapter is set. $ cd /opt/bin $ ln -s digitemp_DS9097 digitemp
The first action is to initialize the 1-wire bus, in order to check for the connected sensors and to created a resource file.
$ digitemp -i -s /dev/ttyUSB0 -a -o2 rudi@LKG300DB0:~/heizung$ ls -ls .digitemprc 1 -rw-r--r-- 1 root www-data 441 Feb 13 16:08 .digitemprc rudi@LKG300DB0:~/heizung$ cat .digitemprc TTY /dev/ttyUSB0 READ_TIME 1000 LOG_TYPE 2 LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C" CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C" HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%" SENSORS 5 ROM 0 0x10 0x50 0x0B 0x6D 0x01 0x08 0x00 0x75 ROM 1 0x10 0xCC 0x10 0x6D 0x01 0x08 0x00 0xB5 ROM 2 0x10 0xA1 0xF9 0x6C 0x01 0x08 0x00 0x9A ROM 3 0x10 0xC7 0x19 0x6D 0x01 0x08 0x00 0xBE ROM 4 0x10 0x37 0x2A 0x6D 0x01 0x08 0x00 0x06
The program digitemp is called from the Python program heizung20.py.
Function Test for digitemp:
# check for the config file $ cd heizung $ ls -a .di* 4 -rwxrwxrwx 1 rudi users 441 Apr 7 2011 .digitemprc # check for readout $ digitemp -a -- 5 s wait -- DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane GNU General Public License v2.0 - http://www.digitemp.com 0 31.12 29.50 43.38 34.06 33.25
Diagram software Gnuplot
With the program gnuplot it is easy to generate nice diagrams for the 5 different temperature data. The only problem was the font selection for the diagram selection. The original 7x5 pixel font does not look very nice.
Fortunately the GD library allows to use a Freetype font, e.g. bitstream Vera.
optware version
root@LKG300DB0:~$ ipkg-opt install gnuplot Installing gnuplot (4.2.6-1) to /opt/... Downloading http://ipkg.nslu2-linux.org/feeds/optware/slugosbe/cross/unstable/gnuplot_4.2.6-1_armeb.ipk rudi@LKG300DB0:~$ ls -ls /opt/bin/gnuplot 1152 -rwxr-xr-x 1 root root 1172764 Mar 8 04:09 /opt/bin/gnuplot rudi@LKG300DB0:/opt/lib/ipkg/info$ cat gnuplot.list /opt/share/gnuplot/4.2/PostScript/cp437.ps /opt/lib/X11/app-defaults/Gnuplot /opt/share/info/dir /opt/share/gnuplot/4.2/PostScript/8859-2.ps /opt/share/gnuplot/4.2/PostScript/prologue.ps /opt/share/gnuplot/4.2/PostScript/koi8u.ps /opt/share/gnuplot/4.2/PostScript/cp852.ps /opt/share/man/man1/gnuplot.1 /opt/bin/gnuplot /opt/share/gnuplot/4.2/PostScript/cp850.ps /opt/share/gnuplot/4.2/PostScript/koi8r.ps /opt/share/gnuplot/4.2/PostScript/8859-15.ps /opt/share/gnuplot/4.2/PostScript/cp1250.ps /opt/share/gnuplot/4.2/PostScript/8859-1.ps /opt/share/texmf/tex/latex/gnuplot/gnuplot.cfg /opt/share/gnuplot/4.2/gnuplot.gih /opt/share/info/gnuplot.info /opt/share/info/dir.old root@LKG300DB0:~$ ldd /opt/bin/gnuplot libreadline.so.6 => /opt/lib/libreadline.so.6 (0x40022000) libncurses.so.5 => /opt/lib/libncurses.so.5 (0x4005d000) libz.so.1 => /opt/lib/libz.so.1 (0x400a5000) libgd.so.2 => /opt/lib/libgd.so.2 (0x400bf000) libjpeg.so.62 => /opt/lib/libjpeg.so.62 (0x40107000) libfontconfig.so.1 => /opt/lib/libfontconfig.so.1 (0x40130000) libfreetype.so.6 => /opt/lib/libfreetype.so.6 (0x40159000) libpng12.so.0 => /opt/lib/libpng12.so.0 (0x401cb000) libm.so.6 => /lib/libm.so.6 (0x401f4000) libstdc++.so.6 => /opt/lib/libstdc++.so.6 (0x4029b000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40379000) libc.so.6 => /lib/libc.so.6 (0x4038b000) libexpat.so.1 => /opt/lib/libexpat.so.1 (0x40492000) /lib/ld-linux.so.2 (0x40000000)
ipkg version
Second installing gnuplot from ipkg repository, for compare with optware. Unfortunately no package libgd was included. Hence, it is necessary to use the optware version. In order to do so, /usr/bin/gnuplot must be renamed, because it comes first in the PATH list.
$ sudo ipkg install gnuplot rudi@LKG300DB0:~/heizung$ ls -ls /usr/bin/gnuplot 1061 -rwxr-xr-x 1 root root 1079532 Mar 2 2008 /usr/bin/gnuplot rudi@LKG300DB0:~/heizung$ sudo ipkg files gnuplot Package gnuplot (4.2.0-r1) is installed on root and has the following files: /usr/share/gnuplot/4.2/PostScript/koi8r.ps /usr/share/gnuplot/4.2/PostScript/8859-2.ps /usr/share/gnuplot/4.2/PostScript/cp437.ps /usr/share/gnuplot/4.2/PostScript/8859-15.ps /usr/share/gnuplot/4.2/PostScript/cp852.ps /usr/share/gnuplot/4.2/PostScript/prologue.ps /usr/share/gnuplot/4.2/PostScript/koi8u.ps /usr/share/gnuplot/4.2/PostScript/cp850.ps /usr/bin/gnuplot /usr/share/gnuplot/4.2/PostScript/cp1250.ps /usr/share/gnuplot/4.2/PostScript/8859-1.ps rudi@LKG300DB0:~/heizung$ ldd /usr/bin/gnuplot libreadline.so.4 => /usr/lib/libreadline.so.4 (0x40022000) libncurses.so.5 => /usr/lib/libncurses.so.5 (0x40054000) libz.so.1 => /usr/lib/libz.so.1 (0x40098000) libgd.so.2 => /usr/lib/libgd.so.2 (0x400b1000) libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x40109000) libpng12.so.0 => /usr/lib/libpng12.so.0 (0x4012d000) libm.so.6 => /lib/libm.so.6 (0x40154000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x401fb000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x402d9000) libc.so.6 => /lib/libc.so.6 (0x402eb000) libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x403f2000) libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x40422000) /lib/ld-linux.so.2 (0x40000000) libexpat.so.1 => /usr/lib/libexpat.so.1 (0x4048e000) rudi@LKG300DB0:~/heizung$ sudo ipkg -test install gdlib Nothing to be done An error ocurred, return value: 4. Collected errors: Cannot find package gdlib. Check the spelling or perhaps run 'ipkg update'
Debian Squeeze, Gnuplot ver. 4.4
The Seagate Free Agent Dockstar is the new (2012-09) server for my heater temperature measurement.
There is installed Debian Squeeze with kernel version 2.6.35.7.
Gnuplot has version 4.4. With the diagram script gnuplot.png_Vera written for Gnuplot version 4.2 there is now a problem with the diagram size within the PNG graphic. The solution was to specify the graphic size in the set term command. The paramter: size 544, 360 (pixel) fits best for the web page, beside of the WebCam picture.
# HowTo find out the picture size rudi@FADS90:~/heizung$ file temperaturM.png temperaturM.png: PNG image data, 544 x 360, 8-bit colormap, non-interlaced rudi@FADS90:~/heizung$ cat gnuplot.png_Vera # 2012-09-04 RR, adopted to Debian Squeeze, Dockstar #set term png font "/usr/share/fonts/truetype/freefont/FreeSans.ttf,10" set term png font "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf,9" size 544, 360 set output "/var/volatile/www/temperaturM.png" #set output "/home/rudi/heizung/temperatureM.png" # plot the title a bit larger, 12 pt set title "Temperaturverlauf Heizung, 5 h" font "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf,12" #set title "Temperaturverlauf Heizung, 5 h" set xlabel "Datum/Zeit" offset graph -0.1; set ylabel "Temperatur in ▒C"; set label "1" at graph 0.01, graph 0.84 set label "0" at graph 0.01, graph 0.78 set label "RudolfReuter" at screen 0.01, screen 0.02 set autoscale set grid set timestamp "generiert %Y-%m-%d %H:%M" offset 34,1 set timefmt "%Y-%m-%d %H:%M:%S" set xdata time set format x "%d.%m\n%H:%M" set yrange [-10:70] set key horizontal # ___insert your plot here___ # The next 2 lines are for test only # plot "temperature" using 1:7 smooth unique title 'Schreibtisch' # plot "heizdata300s.txt" using 1:3:4:5:6:7:8 smooth unique title 'Heizung' plot "heizdata300s.txt" using 1:($3*3+54.0) smooth unique title 'Pumpe', \ "heizdata300s.txt" using 1:($4/10.0) smooth unique title 'Vorlauf', \ "heizdata300s.txt" using 1:($5/10.0) smooth unique title 'Ruecklauf', \ "heizdata300s.txt" using 1:($6/10.0) smooth unique title 'WWSpeicher', \ "heizdata300s.txt" using 1:($7/10.0) smooth unique title 'Dachboden', \ "heizdata300s.txt" using 1:($8/10.0) smooth unique title 'Aussen'
WebCam support, USB UVC Video Class Snapshot SW
In order to use a Logitech E3500 WebCam I needed to have the file uvccapture in order to capture a JPEG picture. It is available from http://packages.debian.org/lenny/uvccapture in an ARM version (0.5-1), but it does not work under SlugOS 4.8, but you can get the source code there.
Fortunately I got in December 2008 via the mail list http://groups.yahoo.com/group/nslu2-linux/ from Jon Barber the already compiled versions of uvccapture and the suitable kernel modules.
For SlugOS 5.3 I compiled the programs by myself and documented that on http://www.nslu2-linux.org/wiki/HowTo/AddUvccaptureToPackages :
rudi@LKG300DB0:/opt/lib/ipkg/info$ ls -ls /opt/bin/uvccapture 26 -rwxr-xr-x 1 root root 25370 Dec 16 2008 /opt/bin/uvccapture rudi@LKG300DB0:/opt/lib/ipkg/info$ ldd /opt/bin/uvccapture libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x40022000) libc.so.6 => /lib/libc.so.6 (0x40046000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4014d000) /lib/ld-linux.so.2 (0x40000000) Kernel modules, video for Linux (v4l) drivers: rudi@LKG300DB0:/opt/lib/ipkg/info$ lsmod Module Size Used by uvcvideo 51980 0 v4l2_compat_ioctl32 480 1 uvcvideo videodev 32960 1 uvcvideo v4l1_compat 12580 2 uvcvideo,videodev rudi@LKG300DB0:/lib/modules/2.6.21.7/kernel/drivers/drivers/media/video$ ls -ls 1 drwxr-xr-x 2 root root 1024 Mar 5 11:48 uvc 19 -rw-r--r-- 1 root root 18352 Dec 16 2008 v4l1-compat.ko 3 -rw-r--r-- 1 root root 2216 Dec 16 2008 v4l2-compat-ioctl32.ko 48 -rw-r--r-- 1 root root 47232 Dec 16 2008 videodev.ko rudi@LKG300DB0:/lib/modules/2.6.21.7/kernel/drivers/drivers/media/video/uvc$ ls -ls 70 -rw-r--r-- 1 root root 70488 Dec 16 2008 uvcvideo.ko
For Debian-Dockstar the software uvccapture was already included in the repository. Also the driver for the Logitech E3500 WebCam was included.
moin Wiki for presentation
In order to present the temperature data and the WebCam picture, it was the easiest way to use the moin Wiki software, written in Python. The moin Wiki software also helped to document a few things, and was small enough to run on the NSLU2 box.
It is the best to stay with version 1.8.7 (http://www.moinmo.in/MoinMoinDownload), because the actual version 1.9.2 has more demand to RAM and a lot of things are changed under the hood, so a lot of macros no longer work.
For Debian Squeeze the actual moin version 1.9.4 will run.
The moin distribution package was copied to /home/<user> and expanded. The temperature measurement page is HeizungWebcam (Simulation).
wikiconfig.py adoption
The wikiconfig.py file was copied from the moin/wiki/config folder to the moin folder and adopted:
sitename = u'RudisWiki' logo_string = u'<img src="/moin_static186/common/nslu2-slugosbe-baby_re.png" alt="rudiwiki.de Logo">' interwikiname = 'RudisWiki' show_interwiki = 1 # show page load timings on web page show_timings = True superuser = [u'RudolfReuter', ] acl_rights_before = u"RudolfReuter:read,write,delete,revert,admin All:read" mail_smarthost = "mail.arcor.de" mail_from = u"reuterru" mail_login = "xxxx" language_default = 'de'
moin wiki start
In order to start and stop the moin wiki with the standalone server the file moin must be copied and started.
rudi $ cp /home/rudi/moin/wiki/server/moin /home/rudi/moin/moin rudi $ chmod a+x /home/rudi/moin/moin rudi $ /home/rudi/moin server standalone --start or rudi $ /home/rudi/moin server standalone --stop
A few macros must be copied to moin/wiki/data/plugin/macro
form.py - The Form macro displays forms based on database records (example only), http://www.moinmo.in/MacroMarket/Form
- GetVarURL2.py - Read out data to insert into a wiki page.
SiteIndex.py - from http://www.moinmo.in/MacroMarket/SiteIndex
Macro GetVarURL2.py
1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - GetVarUrl2
4
5 This macro is used to exctract data from a .csv file.
6 The file name is URL coded, to be found under wiki/htdocs.
7 The data are taken from the first line.
8 The second parameter n defines which element n to extract (0..n-1),
9 or 'info' for the file info (date, length, type),
10 or 'loadavg' for the load average string.
11
12 @copyright: 2008 MoinMoin:RudolfReuter
13 @license: GNU GPL, see COPYING for details.
14 2009-01-20 setup, debug help is provided, ver. 2.2
15 """
16
17 Dependencies = ['time'] # do not cache
18
19 import urllib, re
20 from MoinMoin import config, wikiutil
21 from MoinMoin.parser.text_moin_wiki import Parser
22
23 def execute(macro, params):
24 request = macro.request
25 formatter = macro.formatter
26 #import pdb; pdb.set_trace() # debug
27 #import rpdb2; rpdb2.start_embedded_debugger('123') # http://winpdb.org
28 paramslst = params.split(',')
29 url = paramslst[0]
30 n = 0
31 if paramslst[1].isdigit(): # for csv parameters
32 n = int(paramslst[1]);
33 try:
34 text = urllib.urlopen( url ).read()
35 textlst = text.split(';') # element separation character = ";"
36 text = textlst[n]
37 if n > 1: # scale temperatur by 10
38 a = int(text)/10.0
39 text = str(a)
40 except IOError:
41 text = "{{{ IncludeUrl failed on " + url + " }}}"
42
43 elif paramslst[1].find("loadavg") >= 0 :
44 loadavgstr = open('/proc/loadavg', 'r').readline().strip()
45 text = loadavgstr
46
47 elif paramslst[1].find("finfo") >= 0 :
48 # for file date use file://... instead of http://...
49 infoobj = urllib.urlopen( url ).info()
50 infodict = infoobj.items()
51 infotxt = ''
52 for info in infodict:
53 infotxt += info[0] + ': ' + info[1] + '<<BR>>'
54 text = infotxt
55
56 elif paramslst[1].find("meminfo") >= 0 :
57 # some regular expressions for searching and matching
58 EXPR={ 'free_swap':re.compile('^SwapFree.*'), \
59 'total_swap':re.compile('^SwapTotal.*'), \
60 'free_mem':re.compile('MemFree.*'), \
61 'total_mem':re.compile('MemTotal.*'), \
62 'buffer_mem':re.compile('Buffers.*'), \
63 'cache_mem':re.compile('Cached.*'), \
64 'number':re.compile('[0-9]+'), \
65 }
66 fd = file('/proc/meminfo', 'r') # open file
67 for line in fd: # iterate through it
68 if EXPR['free_swap'].match(line):
69 free_swap=int(EXPR['number'].findall(line)[0])
70 elif EXPR['total_swap'].match(line):
71 total_swap=int(EXPR['number'].findall(line)[0])
72 elif EXPR['free_mem'].match(line):
73 free_mem=int(EXPR['number'].findall(line)[0])
74 elif EXPR['total_mem'].match(line):
75 total_mem=int(EXPR['number'].findall(line)[0])
76 elif EXPR['cache_mem'].match(line):
77 cache_mem=int(EXPR['number'].findall(line)[0])
78 elif EXPR['buffer_mem'].match(line):
79 buffer_mem=int(EXPR['number'].findall(line)[0])
80 fd.close() # close file
81 text = '/proc/meminfo [KB]: !SwapFree: ' + str(free_swap)
82 text += ', !SwapTotal: ' + str(total_swap)
83 #text += '<<BR>>'
84 text += ', !MemFree: ' + str(free_mem)
85 text += ', !MemTotal: ' + str(total_mem)
86 text += ', Buffers: ' + str(buffer_mem)
87 text += ', Cached: ' + str(cache_mem)
88
89 else:
90 text = 'Parameter not known, use: finfo, loadavg, meminfo '
91
92 result = unicode(text)
93 #pagename = formatter.page.page_name
94
95 # from "minipage.py" macro (MacroMarket)
96 Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", request.page.pi['format'])
97 return wikiutil.renderText(request, Parser, result)
moin logging, wikiserverlogging.conf
The moin logging was changed to output to the RAM disk with the rotating file handler:
1 # This is the standalone wikiserver logging configuration.
2 # It can be easily modified to help when debugging, see the comments.
3 # Available loglevels, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
4 # 2009-05-31 RudolfReuter, changed to rotating file handler
5
6 [DEFAULT]
7 #logfile=moin.log
8 logfile=/var/volatile/www/moin_rot.log
9
10 [loggers]
11 keys=root,moin_debug
12
13 [logger_root]
14 level=INFO
15 #handlers=stderr
16 handlers=logfile
17
18 [logger_moin_debug]
19 # adapt the next lines to your debugging needs:
20 level=INFO
21 handlers=stderr
22 qualname=MoinMoin.auth
23 propagate=0
24
25 [handlers]
26 keys=logfile,stderr
27
28 [handler_logfile]
29 #class=FileHandler
30 class=handlers.RotatingFileHandler
31 formatter=default
32 level=DEBUG
33 #args=('%(logfile)s', 'at')
34 # rotate if the size of 32000 bytes are reached, 2 files total.
35 # args filename, mode, maxBytes, backupCount
36 args=('%(logfile)s', 'a', 32000, 1)
37
38 [handler_stderr]
39 class=StreamHandler
40 formatter=default
41 level=DEBUG
42 args=(sys.stderr, )
43
44 [formatters]
45 keys=default
46
47 [formatter_default]
48 format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s
49 datefmt=
50 class=logging.Formatter
moin page HeizungWebcam setup
Beside of the wiki text a few specialties are needed to show the measurement values:
- In order to not wear out the flash memory too fast, a RAM disk was setup to store temporary data:
- /var/volatile/www
A macro GetVarURL2.py is used to place the measurement values into the page. You can see if it works, if you look at the raw text of the page. The source code is here HeizungSoftware#Macro_GetVarURL2.py
- Path: wiki/data/plugin/macro/GetVarURL2.py
The WebCam picture is found in /var/volatile/www/shot.jpg
- It shows the control panel of the heating system, if it is working and the water pressure.
- The control panel is illuminated at night by a LED lamp, but the webcam must adjust automatically.
The temperature diagram (last 5h) is accessed as an attachment, which is a link to /var/volatile/www/temperaturM.png.
The last temperature measurement (6 values) is in the file: /var/volatile/www/heizdata.csv.
The measured temperature values are (in degree celsius):
- Heating water pump ON / OFF (0 / 1)
- Heating water inlet flow (Vorlauf)
- Heating water return flow (Rücklauf)
- Warm water storage (WWSpeicher)
- Attic (Dachboden)
- Outside the house (Außen)
CSS adoptions for better appearance at different screen width (Theme modern).
The file is MoinMoin/web/static/modern/css/screen.css
add to the body spec (line 18) to limit screen width: width: 1000px;
change in the page spec (line 354) to reduce the padding on the right side: padding: 2px 2px 20px 20px;
change in the preview spec (line 393) to reduce the padding on the right side: padding: 2px 2px 20px 30px;
Liste der Seiten in dieser Category
-- RudolfReuter 2010-03-06 17:39:02
Go back to CategoryHeizung or FrontPage ; KontaktEmail (ContactEmail)