Raspberry Pi

Enclosure Project For Helium Mining

Description

A few fans will turn on and heat the enclosure if the humidity goes up to a certain level and will turn off once the humidity goes down to a certain level. Also when the enclosure gets too hot the fans will turn on, and the current going to the Peltier device will go the other way to cool the enclosure.

Note: Wait time is short right now, but if it's over 5 seconds the fan will turn on and off kind of randomly. Mostly based off smart vent code.

Code

#!/usr/bin/env python


#Import libraries I may need

import time

import atexit

import pigpio

import RPi.GPIO as GPIO

import sqlite3 as lite

import Adafruit_DHT


#Set sensor to the DHT22 sensor using Adafruit syntax

sensor = Adafruit_DHT.DHT22


#Set mode to BCM (rather than board) so pin numbers are the same as the GPIO#

GPIO.setmode(GPIO.BCM)


#Set GPIO pin(s) relay is connected to

pinList = [17,27,22]


#Set GPIO pin DHT22 sensor is connected to

pin = 4


# loop through pins and set mode and state to 'high'


for i in pinList:

GPIO.setup(i, GPIO.OUT)


GPIO.output(i, GPIO.HIGH)


"""

Grab sensor reading using 'read_retry' which will

try 15 times (once every 2 seconds) to get a reading.


Using a try loop Make it grab a measurement every X (must be more than 2) seconds

until it is interupted by a keystroke which would end the program.


See Relay Loop for turning fan on or off based on sensor measurements

"""


HH= 60 #High Humidity value

HL= 55 #Low Humidity value

TH= 85 #High temperature value

TL= 45 #Low temperature value

timewait= 5 #Time interval between measurements in seconds


try:

while True:

humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)

#Convert from Celcius to Fahrenheit comment out if Celcius is desired

temperature = temperature * 9/5.0 + 32

print('Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(temperature, humidity))

#Relay loop

if humidity >HH or temperature <TL:


GPIO.output(17, GPIO.LOW)

GPIO.output(27, GPIO.HIGH)

GPIO.output(22, GPIO.LOW)


elif temperature >TH:


GPIO.output(17, GPIO.HIGH)

GPIO.output(27, GPIO.LOW)

GPIO.output(22, GPIO.LOW)


elif humidity <HL and temperature >TL and temperature <TH:


GPIO.output(17, GPIO.HIGH)

GPIO.output(27, GPIO.HIGH)

GPIO.output(22, GPIO.HIGH)

time.sleep(timewait)

except KeyboardInterrupt:

GPIO.output(i, GPIO.HIGH)

GPIO.cleanup(i)

pass



#Display results of reading

if humidity is not None and temperature is not None:

print('Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(temperature, humidity))

else:

print('Failed to get reading.')



"""

Put Temp and Humidity data into Database


Once I figure that out I'll do it!

"""



Smart Vent Project

Description

A fan that will turn on if the humidity goes up to a certain level and will turn off once the humidity goes down to a certain level. Also has a button for venting out unpleasant odors which will turn on the fan for 5 minutes when pressed.

Note: Right now the button has to be held for the fan to activate but I would like to fix the code to make the button work instantaneously.

Code

#!/usr/bin/env python

#Import libraries I may need

import time

import atexit

import pigpio

import RPi.GPIO as GPIO

import sqlite3 as lite

import Adafruit_DHT


#Set sensor to the DHT22 sensor using Adafruit syntax

sensor = Adafruit_DHT.DHT22


#Set mode to BCM (rather than board) so pin numbers are the same as the GPIO#

GPIO.setmode(GPIO.BCM)


#Set GPIO pin(s) relay is connected to

pinList = [14]


#Set GPIO pin DHT22 sensor is connected to

pin = 4


#Set GPIO pin button is connected to

bt = 26


# loop through pins and set mode and state to 'low'


for i in pinList:

GPIO.setup(i, GPIO.OUT)


GPIO.output(i, GPIO.LOW)


# set button as input

GPIO.setup(bt, GPIO.IN)




"""

Grab sensor reading using 'read_retry' which will

try 15 times (once every 2 seconds) to get a reading.

Using a try loop Make it grab a measurement every X (must be more than 2) seconds

until it is interupted by a keystroke which would end the program.

See Relay Loop for turning fan on or off based on sensor measurements

"""


HH= 80 #High Humidity value

HL= 70 #Low Humidity value

timewait= 3 #Time interval between measurements in seconds


try:

while True:

input_value = GPIO.input(bt)

humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)


temperature = temperature * 9/5.0 + 32

print('Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(temperature, humidity))

if input_value == False or humidity >HH:


GPIO.output(i, GPIO.HIGH)


time.sleep(3)


elif input_value == True and humidity <HL:


GPIO.output(i, GPIO.LOW)


if input_value == False:


GPIO.output(i, GPIO.HIGH)


time.sleep(timewait)


except KeyboardInterrupt:

GPIO.output(i, GPIO.LOW)

GPIO.cleanup(i)

pass



#Display results of reading

if humidity is not None and temperature is not None:

print('Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(temperature, humidity))

else:

print('Failed to get reading.')



"""

Put Temp and Humidity data into Database

Once I figure that out I'll do it!

"""


Smart Greenhouse

Description

A programmable Greenhouse with light, humidity and temperature control. Also future plans include computer vision enhanced control and remote capabilities.

Code

**In Progress**

Octopi 3D Printing Camera

You can visit this link to download disk image file:

https://octoprint.org/download/