Aditya Jaganadha Sai Mangalampalli
Created September 4, 2017

The Portable AC

Keep yourself cool during the summer!

52
The Portable AC

Things used in this project

Hardware components

High RPM Fan
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Li-Po Battery
×1
Omega2 Plus
Onion Corporation Omega2 Plus
×1
Arduino Dock
×1

Hand tools and fabrication machines

Screwdriver
Screws
3d Printer

Story

Read more

Code

Portable AC

Python
#!/usr/bin/python3
import time
import os
import sys
import RPi.GPIO as GPIO

# Identify which pin controls the relay
FAN_PIN = 3
# Temperature check. Start fan after 50C, Shut down under 50C
FAN_START = 50

def GPIOsetup():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(FAN_PIN, GPIO.OUT)
    GPIO.setwarnings(False)

def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    return(res.replace("temp=","").replace("'C\n",""))

def fanON():
    GPIO.output(FAN_PIN, 0)
    print "fan on"
    return()

def fanOFF():
    GPIO.output(FAN_PIN, 1)
    print "fan off"
    return()

def getTEMP():
    CPU_temp = float(getCPUtemperature())
    if CPU_temp>FAN_START:
        fanON()
    else:
        fanOFF()
    return()

def main():
    GPIOsetup()
    getTEMP()

try:
    main()
finally:
    print ("Finish")
    #GPIO.cleanup()

Credits

Aditya Jaganadha Sai Mangalampalli

Aditya Jaganadha Sai Mangalampalli

0 projects • 5 followers
I am a 10th grader at Mission San Jose High School and robotics and Machine Learning is what I am good at!

Comments