Python Forum
Pressure monitor for keg fridge
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pressure monitor for keg fridge
#1
I just put this together and it seems to be working well. I don't have the LEDs connected yet, but the "print" function proves they will with correct connections. I may add a few more LEDs for the scale between 11 and 13.5, each with a .5 range. I can do that just fine. I'm posting here to see if there are any wasted lines of code, can this be cleaned up?

import time
from time import sleep
from datetime import datetime
import Adafruit_ADS1x15
adc = Adafruit_ADS1x15.ADS1115(address=0x48, busnum=1)
from gpiozero import LED

GAIN = 2/3
LEDHIGH = LED(21)
LEDNORM = LED(26)
LEDLOW = LED(16)


while 1:
    value = [0] 
    value[0] = adc.read_adc(0, gain=GAIN)
    volts = value[0]/32767.0 * 6.144    
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    manifoldraw = volts / .145
    manifold = str(round(manifoldraw, 2))

    print(current_time, "  ", manifold)
    
    if 12.25 <= manifoldraw <= 12.75:
        LEDNORM.on()
        print("pressure OK")
    else:
        LEDNORM.off()
        #print("off")
        
    if 0 <= manifoldraw <=12.24:
        LEDLOW.on()
        print("pressure LOW")
    else:
        LEDLOW.off()
        
    if 12.76 <= manifoldraw <= 99999:
        LEDHIGH.on()
        print("pressure HIGH")
    else:
        LEDHIGH.off()

    sleep(1)
    
Basic function in this configuration is that I will have one LED on when the pressure is normal, between 12.25 and 12.75. Other LEDs would indicate when I am higher than 12.76 or lower than 12.24. I intend to add a requests.post that hits a URL that sends a message to my Androids if pressures get above 15 or below 10. Optimum pressure on this application is 12.5. It is for the CO2 manifold for my keg fridge, so pressure is critical to preserve optimum carbonation levels of my homebrew!
Reply


Messages In This Thread
Pressure monitor for keg fridge - by duckredbeard - Dec-02-2020, 05:03 AM
RE: Pressure monitor for keg fridge - by Larz60+ - Dec-02-2020, 11:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Better Way to Monitor Time Request. bill_z 2 2,311 Oct-17-2020, 04:36 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020