Chest Freezer To Refrigerator Conversion: Difference between revisions

From Open Source Ecology
Jump to navigation Jump to search
Line 6: Line 6:
**or [https://www.sparkfun.com/products/12587 sparkfun Pro Micro] $19.95 - [https://github.com/sparkfun/Arduino_Boards Install Instructions]
**or [https://www.sparkfun.com/products/12587 sparkfun Pro Micro] $19.95 - [https://github.com/sparkfun/Arduino_Boards Install Instructions]
*[https://www.sparkfun.com/products/13015 24-280VAC Relay] $9.95
*[https://www.sparkfun.com/products/13015 24-280VAC Relay] $9.95
**or [http://www.sainsmart.com/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html SainSmart Relay Module] $3.99
**or [http://www.sainsmart.com/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html SainSmart Relay Module] $3.99 - Requires 5V Board
*[https://www.sparkfun.com/products/250 Thermister] $0.75
*[https://www.sparkfun.com/products/250 Thermister] $0.75
*[https://www.sparkfun.com/products/11508 10k Resistor] $0.95
*[https://www.sparkfun.com/products/11508 10k Resistor] $0.95

Revision as of 21:21, 19 November 2016

BOM

Arduino Code


//A1 read voltage
//D3 sensor power
//D7 relay (+)


  volatile int sensorvalue = 328; //define the variable
  int triggeron = 328;         //number that will trigger fridge on
  int triggeroff = 304;        //number that will trigger fridge off


// the setup function only runs once every time the chip is reset
void setup() {
  digitalWrite(3, HIGH); //for powering thermister  
  digitalWrite(7, LOW);  //for switching relay
  pinMode(3, OUTPUT);    //begin operating pin
  pinMode(7, OUTPUT);    //begin operating pin
  delay(20000);          // wait for thermister to get a good initial reading
}

// the loop function runs over and over again forever
void loop() {
  sensorvalue = analogRead(A1);   //read sensor
if (sensorvalue > triggeron){     //if sensor reads over triggeron, turn on
  digitalWrite(7, HIGH);       //turn on relay
  delay(8000);                 //wait 8 seconds
}
if (triggeroff > sensorvalue){   //if sensor reads below triggeroff, turn off
  digitalWrite(7, LOW);         //turn off relay
  delay(8000);                  //wait 8 seconds
}
}

 

Other Options

Further Reading