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] $3.99
*[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:02, 19 November 2016

BOM

Arduino Code


//A1 read voltage
//D3 sensor power
//D5 relay low
//D7 relay high

  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

void setup() {
  digitalWrite(3, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(7, LOW);    // initialize in OFF setting
  digitalWrite(5, LOW);    // set pin 5 low
  pinMode(3, OUTPUT);
  pinMode(7, OUTPUT);
  delay(20000);
}

// 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