Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Jeremy Dean
Published

Automatic A/C Vent Controller

A room's A/C vent is opened or closed based on temperature data gathered with a Particle Photon.

IntermediateFull instructions provided10 hours690
Automatic A/C Vent Controller

Things used in this project

Hardware components

Photon
Particle Photon
×2
Temperature Sensor
Temperature Sensor
×1
Servos (Tower Pro MG996R)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
vent
×1

Story

Read more

Schematics

Temperature Sensor Photon

Vent Controller Photon

Code

ventcontroller.ino

Arduino
// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>
#include <string>
#include <sstream>
#define TOKEN "A1E-tc2PXtcBuFWr3W6fYN6JVn7JZAwriN"  // Put here your Ubidots TOKEN
#define varID "5ad5badac03f9751c8060bff"
Ubidots ubidots(TOKEN);

double desiredTemp = 80;
Servo servo;

void setup(){
servo.attach(3);
Particle.subscribe("currentTemp",toggleVent);
}

void loop() {
}



void toggleVent(const char *event, const char *data){
String stuff = "";
stuff = stuff + data;
double temp;
std::string tempString(stuff);
std::stringstream convert(tempString); 

if ( !(convert >> temp) )
    temp = 0;

if (desiredTemp>temp){
    //close vent
    servo.write(0);
}
else{
    servo.write(65);
}
    

}

roomtempsensor.ino

Arduino
// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>
#include <string>
#include <sstream>
#include <cmath>

#define TOKEN "A1E-tc2PXtcBuFWr3W6fYN6JVn7JZAwriN"  // Put here your Ubidots TOKEN
Ubidots ubidots(TOKEN);
double tempC = 0;
double tempF = 0;
String currTemp = "";
int sampleFreq = 1000;

void setup() {
    //get curr and desired
}

void loop() {
    currTemp = "";
    double raw = analogRead(2);    
    double v = raw * (3300.0/4095.0);
    tempC = (v-500.0)/10.0;
    tempF = tempC * 1.8 + 32.0;
    currTemp = currTemp + tempF;
    Particle.publish("currentTemp",currTemp,100,PUBLIC);
    ubidots.add("Room Temperature",tempF);
    ubidots.sendAll();
    delay(sampleFreq);
}

Credits

Jeremy Dean
1 project • 0 followers

Comments