Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Gregory Estell
Published

Group 32 MEGR 3171 Automatic AC Damper

A perfectly climate controlled house is a luxury you may not know you needed.

IntermediateShowcase (no instructions)68
Group 32 MEGR 3171 Automatic AC Damper

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×2
Adafruit SHT30 Temperature And Humidity Sensor - Wired Enclosed Shell
×2
Futaba S148 Servo
×2
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Drill / Driver, 20V
Drill / Driver, 20V
DURATOOL Metal Hacksaw of 300mm Blade Length

Story

Read more

Schematics

Wiring Diagram

Code

Greg's Argon

C/C++
// Include Thingspeak library
#include <ThingSpeak.h>
// Include Servo Library
#include <Tinker-Servo.h>
// Include Temperature & Humidity Sensor Library
#include <adafruit-sht31.h>
// Clarify which sensor is being used with the sensor library
Adafruit_SHT31 sht31 = Adafruit_SHT31();
// Introduce all the variables used as integers
int roomtemp;
int roomhumidity;
int fahrenheit;
int highertemp;
int higherhumidity;
int ventopen;
int roomtemperature2;
int roomhumidity2;
int vent1;
//Introduce the servo function
Servo myservo; 
//Needed to initialize Thingspeak
TCPClient client;
//Introduce Thingspeak channel number and API key
unsigned long myChannelNumber = 1935369;
const char * myWriteAPIKey = "IE74J8LAV2D2UWDI";

void setup() {
    //Initialize Temperature & Humidity Sensor
    sht31.begin(0x44);
    //Assign pin 4 as the servo signal output and assign time delays for the servo
    myservo.attach(4,600,2300);
    //Initialize Thingspeak
    ThingSpeak.begin(client);
    //Introduce particle variable roomtemperature1 as the integer value of fahrenheit
    Particle.variable("roomtemperature1", &fahrenheit, INT);
    //Introduce particle variable roomhumidity1 as the integer value of roomhumidity
    Particle.variable("roomhumidity1", &roomhumidity, INT);
    //Subscribe to particle variable roomtemperature2 and store it in function roomtempl
    Particle.subscribe("roomtemperature2", roomtempl);
    //Subscribe to particle variable roomhumidity2 and store it in function roomhumidl
    Particle.subscribe("roomhumidity2", roomhumidl);
    //Initialize serial printing
    Serial.begin(9600);
}
    //Run function roomtempl
void roomtempl(const char *event, const char *data){
    //convert subscribed "roomtemperature2" string data to integer data
    sscanf(data, "%d", &roomtemperature2);
}
    //Run function roomhumidl
void roomhumidl(const char *event, const char *data){
    //convert subscribed "roomhumidity2" string data to integer data
    sscanf(data, "%d", &roomhumidity2);
}

void loop() {
    // Read temperature and store it in roomtemp
    roomtemp = sht31.readTemperature();
    // Read humidity and store it in roomhumidity
    roomhumidity = sht31.readHumidity();
    //Convert temperature roomtemp from celcius to fahrenheit and store it in fahrenheit
    fahrenheit = (roomtemp*1.8)+32;
    //Publish fahrenehit to the particle variable roomtemperature1
    //*Note integer values must be converted to string in order to be printed to the cloud
    Particle.publish("roomtemperature1", String(fahrenheit));
    //Publish roomhumidity to the particle variable roomhumidity1
    //*Note integer values must be converted to string in order to be printed to the cloud
    Particle.publish("roomhumidity1", String(roomhumidity));
    //If the temperature of the local temperature sensor fahrenheit is less than the other
    //temperature sensor roomtemperature2, highertemp=1. Otherwise highertemp=0
    if (fahrenheit > roomtemperature2){
        (highertemp=1);
    }
    else{
        (highertemp=0);
    }
    //If the humidity of the local humidity sensor roomhumidity is greater than the other
    //temperature sensor roomhumidity2, higherhumidity=1. Otherwise higherhumidity=0
    if (roomhumidity < roomhumidity2){
        (higherhumidity=1);
    }
    else{  
        (higherhumidity=0);
    }
    //Publish highertemp to the particle variable highertemp. This helps with debugging
    Particle.publish("highertemp1", String(highertemp));
    //Publish higherhumidity to the particle variable higherhumidity. This helps with debugging
    Particle.publish("higherhumidity1", String(higherhumidity));
    //if highertemp and higherhumidity=1, then the vent will close. The vent is intstructed
    //to close by myservo.write(120) [**120 means 120 degrees]. Otherwise the vent stays open
    vent1 = highertemp+higherhumidity;
    if (vent1 > 1){
        myservo.write(120);
    }
    else{
        myservo.write(0);              
    }
    //Write fahrenheit to Thingspeak field 1
    //Write roomhumidity to Thingspeak field 2
    //Write vent1 to Thingspeak field 3
    ThingSpeak.setField(1,fahrenheit);
    ThingSpeak.setField(2,roomhumidity);    
    ThingSpeak.setField(3,vent1);    
    ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    //Reset vent1 to zero before the loop begins again
    vent1=0;
    //delay 10 seconds before the loop restarts
delay(10000);

}

Layne's Argon

C/C++
// Include Thingspeak library
#include <ThingSpeak.h>
// Include Servo Library
#include <Stepper.h>
// Include Temperature & Humidity Sensor Library
#include <adafruit-sht31.h>
// Clarify which sensor is being used with the sensor library
Adafruit_SHT31 sht31 = Adafruit_SHT31();
// Introduce all the variables used as integers
int roomtemp2;
int roomhumidity2;
int fahrenheit2;
int highertemp2;
int higherhumidity2;
int ventopen;
int roomtemperature1;
int roomhumidity1;
int vent2;
//Introduce the servo function
Servo myservo;
//Needed to initialize Thingspeak
TCPClient client;
//Introduce Thingspeak channel number and API key
unsigned long myChannelNumber = 1935369;
const char * myWriteAPIKey = "IE74J8LAV2D2UWDI";

void setup() {
    //Initialize Temperature & Humidity Sensor
    sht31.begin(0x44);
    //Assign pin 4 as the servo signal output and assign time delays for the servo
    myservo.attach(4,600,2300);
    //Initialize Thingspeak
    ThingSpeak.begin(client);
    //Introduce particle variable roomtemperature2 as the integer value of fahrenheit2
    Particle.variable("roomtemperature2", &fahrenheit2, INT);
    //Introduce particle variable roomhumidity2 as the integer value of roomhumidity2
    Particle.variable("roomhumidity2", &roomhumidity2, INT);
    //Subscribe to particle variable roomtemperature1 and store it in function roomtempm
    Particle.subscribe("roomtemperature1", roomtempm);
    //Subscribe to particle variable roomhumidity1 and store it in function roomhumidm
    Particle.subscribe("roomhumidity1", roomhumidm);
    //Initialize serial printing
    Serial.begin(9600);
delay(200);
}
    //Run function roomtempm
void roomtempm(const char *event, const char *data){
    //convert subscribed "roomtemperature1" string data to integer data
    sscanf(data, "%d", &roomtemperature1);
}
    //Run function roomhumidm
void roomhumidm(const char *event, const char *data){
    //convert subscribed "roomhumidity1" string data to integer data    
    sscanf(data, "%d", &roomhumidity1);
}

void loop() {
    // Read temperature and store it in roomtemp2
    roomtemp2 = sht31.readTemperature();
    // Read humidity and store it in roomhumidity2
    roomhumidity2 = sht31.readHumidity();
    //Convert temperature roomtemp2 from celcius to fahrenheit and store it in fahrenheit2
    fahrenheit2 = (roomtemp2*1.8)+32;
    //Publish fahrenehit2 to the particle variable roomtemperature2
    //*Note integer values must be converted to string in order to be printed to the cloud
    Particle.publish("roomtemperature2", String(fahrenheit2));
    //Publish roomhumidity2 to the particle variable roomhumidity2
    //*Note integer values must be converted to string in order to be printed to the cloud
    Particle.publish("roomhumidity2", String(roomhumidity2));
    //If the temperature of the local temperature sensor fahrenheit2 is less than the other
    //temperature sensor roomtemperature1, highertemp2=1. Otherwise highertemp2=0
    if (fahrenheit2 > roomtemperature1){
        (highertemp2=1);
    }
    else{
        (highertemp2=0);
    }
    //If the humidity of the local humidity sensor roomhumidity2 is greater than the other
    //temperature sensor roomhumidity1, higherhumidity2=1. Otherwise higherhumidity2=0
    if (roomhumidity2 < roomhumidity1){
        (higherhumidity2=1);
    }
    else{  
        (higherhumidity2=0);
    }
    //Publish highertemp to the particle variable highertemp2. This helps with debugging
    Particle.publish("highertemp2", String(highertemp2));
    //Publish higherhumidity to the particle variable higherhumidity2. This helps with debugging
    Particle.publish("higherhumidity2", String(higherhumidity2));
    //if highertemp2 and higherhumidity2=1, then the vent will close. The vent is intstructed
    //to close by myservo.write(110) [**110 means 110 degrees]. Otherwise the vent stays open
    vent2 = highertemp2+higherhumidity2;
    if (vent2 > 1) {
        myservo.write(110);
    }
    else{
        myservo.write(0);           
    }
    //Write fahrenheit2 to Thingspeak field 4
    //Write roomhumidity2 to Thingspeak field 5
    //Write vent2 to Thingspeak field 6
    ThingSpeak.setField(4,fahrenheit2);
    ThingSpeak.setField(5,roomhumidity2);
    ThingSpeak.setField(6,vent2);    
    ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    //Reset vent2 to zero before the loop begins again
    vent2=0;
    //delay 10 seconds before the loop restarts
delay(10000);

}

Credits

Gregory Estell

Gregory Estell

1 project • 1 follower
Thanks to Layne Riggs.

Comments