Temperatur #2

Skärmklipp

Det som kan mätas ska loggas, därför har jag installerat MRTG på akvariets Raspberry Pi. Med hjälp av följande mrtg.cfg:

######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################
# This file is for use with mrtg-2.5.4c

# Global configuration
WorkDir: /var/www/mrtg
WriteExpires: Yes
RunAsDaemon: Yes
Interval: 5

Title[^]: Temperaturstatistik for 

Title[kar1]: kar 1
PageTop[kar1]: <h1>Temperaturen i kar 1</h1>
Target[kar1]: `/usr/local/bin/aquacontrol/mrtg.py`
MaxBytes[kar1]: 4000
Options[kar1]: growright,gauge,expscale
Factor[kar1]: 0.01
YLegend[kar1]: Temperatur
YTicsFactor[kar1]: 0.01
ShortLegend[kar1]: C
Legend1[kar1]: Temperatur i grader celcius
Legend2[kar1]: 
Legend3[kar1]: Maximal 5 Minute Incoming Traffic
Legend4[kar1]: Maximal 5 Minute Outgoing Traffic
LegendI[kar1]: &nbsp;Temp:
LegendO[kar1]: 

och ett litet pythonskript:

#!/usr/bin/python
from time import strftime

tfile = open("/sys/bus/w1/devices/28-0000065bd235/w1_slave", 'r')
text = tfile.read()
tfile.close()

secondline = text.split("\n")[1]
temperaturedata = secondline.split(" ")[9]
temperature = float(temperaturedata[2:])
temperature = int(temperature / 10)

print(str(temperature))
print("0")
print(strftime("%Y-%m-%d %H:%M:%S"))
print("Temperatur i kar 1")

loggas temperaturen och visas upp i fina grafer för senaste dygnet, veckan, månaden och året.

Privacy Overview
Elofs projekt

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Necessary

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.