def main(): while True: output = ("%s %3.1f%s" % ("ambient", read_sensor(sensors["ambient"]), chr(0xb0) + "C"), "%s %3.1f%s" % ("basking", read_sensor(sensors["white"]), chr(0xb0) + "C"), "%s %3.1f%s" % ("in hide", read_sensor(sensors["black"]), chr(0xb0) + "C") ) t = time.strftime("%H:%M", time.localtime()) gotnet = network_on() if not gotnet: t += " (no net)" for s in output: lcd.lcd_init() #print s time.sleep(0.1) # Give the screen time to wake up lcd.lcd_string(s) lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD) lcd.lcd_string(t) time.sleep(10) if not gotnet: call("/bin/sync") # Write pending data to SD card call("/usr/bin/sudo /sbin/reboot -f")
# 21/27 is rev1/rev2 board # LCD_D6 = 21 LCD_D6 = 27 LCD_D7 = 22 GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers GPIO.setup(LCD_E, GPIO.OUT) # E GPIO.setup(LCD_RS, GPIO.OUT) # RS GPIO.setup(LCD_D4, GPIO.OUT) # DB4 GPIO.setup(LCD_D5, GPIO.OUT) # DB5 GPIO.setup(LCD_D6, GPIO.OUT) # DB6 GPIO.setup(LCD_D7, GPIO.OUT) # DB7 # Initialise display lcd.lcd_init() # 28-0000043e37d7 white # 28-00000457d048 black # 28-0000048be4e7 ambient sensors = {"white": "28-0000043e37d7", "black": "28-00000457d048", "ambient": "28-0000048be4e7"} def read_sensor(sensor): """Attempt to get temperature readings from compatible sensors.""" tries = 0 while True: