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

Face Detection Using OpenCV With Raspberry Pi
Intermediate
  • 2,372
  • 21

Protip

In this project, we are going to detect faces using OpenCV with Raspberry Pi.

Creating an IoT Server with Home Assistant and MQTT
Intermediate
  • 2,523
  • 17

Full instructions

Home Assistant is one powerful home automation platform and it is complacently open source. Access it from any web browser and automatons.

Adding RC Transmitter/Receiver to Control Mecanum Bot
Intermediate
  • 431
  • 6

Full instructions

We previously showed our Mecanum Bot being controlled by a wireless Xbox controller, now we added RC transmitter/receiver.

Automated GPS Controlled Photo Taker
Intermediate
  • 1,613
  • 19

Full instructions

For this build, I put together a backpack to take pictures when I am close to places that like. And what better place to test than London?

Setting up a "User Data" drive for Raspberry Pi
Intermediate
  • 47
  • 1

Full instructions

Mounting external memory to store users programs, files, etc...

DIY Smart Assistant Speaker/Lamp (Google Home or Alexa)
Intermediate
  • 1,644
  • 5

Full instructions

DIY build using 3D printed enclosure and parts, a recycled Bluetooth speaker, a Raspberry Pi, and a Philips Hue light bulb.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login