Project : Temperature control

The project goal was to be able to measure the temperature of the pot while brewing beer.
The requirements are continous readout of the temperature on a screen and LEDs which will show if the temperature is within desired range, close to desired range or out of desired range.

For this project the primary component is the temperature sensor, which needs to be waterproof and be able to withstand temperatures reaching 100 degrees C.

This is what I chose to use and its connectors:
DS18B20 (waterproof):
Yellow = Data = GPIO
Green = Ground
Red = Power

To be able to use the sensor you need to get its physical address.
Connect it as stated above and use this command: “ls -l /sys/bus/w1/devices/”
For mine it was 28-0000065657f0
To test it and get data: “cat /sys/bus/w1/devices/28-0000065657f0/w1_slave”

I connected the sensor to GPIO4, the low RED LED to GPIO 14, GREEN LED to GPIO 15 and the low RED LED to GPIO 18.

import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(14,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)

while 1:
    tempfile = open("/sys/bus/w1/devices/28-0000065657f0/w1_slave")
    thetext = tempfile.read()
    tempfile.close()
    tempdata = thetext.split("\n")[1].split(" ")[9]
    temperature = float(tempdata[2:])
    temperature = temperature/1000
# Temp 61.0-63.0 GREEN
# Temp 59.9-60.9 RED LOW & GREEN
# Temp < 58.9 RED LOW
# Temp 63.1-65.0 RED HIGH & GREEN
# Temp > 65.1 RED HIGH
    GPIO.output(14,GPIO.LOW)
    GPIO.output(15,GPIO.LOW)
    GPIO.output(18,GPIO.LOW)

    print temperature

    if (temperature>=61.0 and temperature<=63):
        print "GREEN"
        GPIO.output(15,GPIO.HIGH)
    if (temperature>63 and temperature<=65):
        print "GREEN & RED HIGH"
        GPIO.output(15,GPIO.HIGH)
        GPIO.output(18,GPIO.HIGH)
    if (temperature>65):
        print "RED HIGH"
        GPIO.output(18,GPIO.HIGH)
    if (temperature<61 and temperature>60):
        print "GREEN & RED LOW"
        GPIO.output(14,GPIO.HIGH)
        GPIO.output(15,GPIO.HIGH)
    if (temperature<=60):
        print "RED LOW"
        GPIO.output(14,GPIO.HIGH)

    time.sleep(1)

This is how the connectors are setup

Temperature5_bb