May-12-2017, 05:58 PM
hi
im a total noob on this! but anyway... im trying to build a temp monitor for my reef tank.
based on a rpi with lcd hat (non rgb)
im a total noob on this! but anyway... im trying to build a temp monitor for my reef tank.
based on a rpi with lcd hat (non rgb)
#!/usr/bin/python
# Import all the libraries
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from w1thermsensor import W1ThermSensor
import time
# Sample/Refresh time in seconds
refresh = 60
# Temperature history in values (history duration will be samples * refresh)
samples = 60
# Define and initialise the LCD
lcd = Adafruit_CharLCDPlate()
lcd.begin(16,1)
lcd.backlight(lcd.RED)
lcd.message("PiTemp!")
# degree symbol
lcd.createChar(1, [0b01100,
0b10010,
0b10010,
0b01100,
0b00000,
0b00000,
0b00000,
0b00000])
# Diagonal up arrow
lcd.createChar(2, [0b00000,
0b01111,
0b00011,
0b00101,
0b01001,
0b10000,
0b00000,
0b00000])
# Diagonal down arrow
lcd.createChar(3, [0b00000,
0b10000,
0b01001,
0b00101,
0b00011,
0b01111,
0b00000,
0b00000])
# Define the temperature sensor
sensor = W1ThermSensor()
# Set up the history array
temp = sensor.get_temperature()
templist = [temp] * samples
try:
while True:
# Shift out the oldest temperature value
for x in range(len(templist)-1):
templist[x] = templist[x+1]
# Set the end item to be our current temperature
templist[len(templist)-1] = sensor.get_temperature()
# Uncomment the following line for debugging
#print "max %.2f min %.2f\n" % (max(templist),min(templist))
# Display it on the LCD
lcd.clear()
lcd.message("""Temp %.2f \x01C\n\x02 %.2f \x03 %.2f""" %
(templist[len(templist)-1],max(templist),min(templist)))
# Sleep until we need to sample/refresh
time.sleep(refresh)
except KeyboardInterrupt:
print "Interrupted!\n"
lcd.clear()
lcd.message("PiTemp finished")
Error: }
[b]pi@raspberrypi[/b]:[b]~ $[/b] sudo python tempntime.py
File "tempntime.py", line 60
for x in range(len(templist)-1):
^
IndentationError: expected an indented block
