Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
BMP 180
×1
Fairchild semiconductor 1n4004. image
1N4007 – High Voltage, High Current Rated Diode
×1
Fairchild semiconductor pn2222abu. image
General Purpose Transistor NPN
×1
DC motor (generic)
×1

Schematics

Circuit Diagram
this diagram shows the circuit layout for this project
Fancontroller bb

Code

turn fan on test codePython
this python code allows you to test to see if your fan will turn on properly. the pin used was 23, so please change pin numbers from 23 if you choose another pin.
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(23, GPIO.OUT)
GPIO.output(23,True)
turn fan offPython
This code allows you to test you circuit to see if your fan will turn off when requested. Pin 23 was used.
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(23, GPIO.OUT)
GPIO.output(23, False)
Temperature Control and Display codePython
This code allows you to set the amount of run time for the program, period between pulsing the sensor, temperature at which the fan will turn on and what temperature it will turn off at. It will display and record the temperature, atmospheric pressure, and altitude based on barometric pressure on the Python command terminal every 10 seconds.
#import needed files/references, sorcery, to read sensors

import sys
import time
import datetime

import Adafruit_BMP.BMP085 as BMP085

sensor = BMP085.BMP085()

# How long to wait (in seconds) between measurements.
FREQUENCY_SECONDS      = 10

# Create sensor instance with default I2C bus (On Raspberry Pi either 0 or
# 1 based on the revision, on Beaglebone Black default to 1).
bmp = BMP085.BMP085()

#Run time of program in seconds
Timesup = 3600
#initial time
times=0
#temperature fan turns on at (celsius)
Tfan_on= 27

#start program
print 'Logging sensor measurements.'
print 'Press Ctrl-C to quit.\n'

while True:
    # Login if necessary.
    if times < Timesup:

    # Attempt to get sensor readings.
            temp = bmp.read_temperature()
            pressure = bmp.read_pressure()
            altitude = bmp.read_altitude()

            print 'Temperature: {0:0.1f} C'.format(temp)
            print 'Pressure:    {0:0.1f} Pa'.format(pressure)
            print 'Altitude:    {0:0.1f} m\n'.format(altitude)
 
#count time allotted
    times=times+10
#turn fan on if hot
    if Tfan_on < temp:
        import RPi.GPIO as GPIO
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23,True)
# turn fan off if acceptable
    else:
        import RPi.GPIO as GPIO
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23,False)        


    # Wait 10 seconds before continuing
    time.sleep(FREQUENCY_SECONDS)
    #kill job if its done
    if times == Timesup:    
        print 'Simulation has ended, time is up!'
        break

Credits

B51b0ba01a01bbff492a37ac9b1af838
Alan Hilliard

Mechanical Engineer-Motorsports concentration Interested in Aerospace and mechanical technologies.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

LoRaWAN for Raspberry Pi with Worldwide Frequency Support
Intermediate
  • 3,878
  • 18

Full instructions

LoRaWAN LMIC 1.6 for Raspberry Pi with Dragino LoRA/GPS HAT or standalone RFM95W LoRa Module.

Human-Following Robot with Kinect
Intermediate
  • 2,571
  • 24

Full instructions

Instead of using single camera and complicated image recognition algorithms we can take advantage of Kinect libraries.

Wireless Programming and Debugging with STM32 and RPi
Intermediate
  • 87
  • 2

Full instructions

Are you tired of connecting programmer every time you want to change some functionality of your robot? Why not to try wireless programming?

Thunderboard Sense and RPi
Intermediate
  • 128
  • 2

Collecting rich sensor data over BLE and uploading it to the cloud for analysis.

Automated Indoor Gardener
Intermediate
  • 4,009
  • 40

Full instructions

Never worry about dead plants again. This automated gardener never forgets to water your plants and provide artificial sunlight.

Computerception
Intermediate
  • 27,480
  • 20

Full instructions

Why not put a Raspberry Pi into a 2007 netbook?

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog