Freezer Door Alarm

I am brand new to this and only received my Uno 8 days ago. (And have never coded before, So please be gentle with me)
This has probably been covered many times before.
I needed an alarm system for the freezer because the kids are forever leaving the door open. Unfortunately there is only one place in the kitchen that the freezer can go, and it is a tight fit.
Because of this a simple "switch" wouldn't work because of the space constraints, and the freezer door only needs to be left open a couple of mm's to cause a problem.
I measured the temperature at ground level and thought if I can monitor this, knowing that any cold air from an open freezer door will "sink" I might be on to a solution.

I will post the complete code below, anything to do with the lcd and wire can be deleted, it was just me wanting to have a play and look at the numbers

The calibration may be a bit off, I originally wanted to set the buzzer off at below 5 degrees, but couldn't seem to get it that low even with an ice cube in poly bag sat on the sensor!!!

I used an LM35 sensor and basic active buzzer

So chuffed this worked first time.

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

float tempC; //defines that the temp is a decimal number//

int reading; //defines that the reading is an integer//

int tempPin = 0; //sets sensor pin to pin 0 (analog)//

int buzzPin = (8); //sets buzzer output pin NB this is a digital pin//

LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3,POSITIVE); //sets the I2C address for the lcd//

void setup()

{
analogReference(INTERNAL); //defines that the ref voltage will be 1.1v//

Serial.begin(9600); //starts serial port and sets baud rate//

pinMode (buzzPin, OUTPUT); //sets the buzzer pin as an output//

lcd.begin (20,4); // states that the lcd is a 20 x 4 display)

lcd.backlight (); // turns the lcd backlight on//

}

void loop()
{
reading = analogRead(tempPin); //takes the reading from the sensor and//

tempC = reading / 9.31; //converts it into Celsius and prints the value//

Serial.println(tempC); //to the console //

lcd.setCursor(0,0); // starts the lcd display at top left//

lcd.print (tempC); // prints the sensor reading to the lcd//

delay(2000); // repeats after 2 seconds//

if (tempC < 9.00){ //if the temerature is below 9 degrees C, //

digitalWrite (buzzPin, HIGH); //turns the buzzer on - if above 5dgrees C, //

delay(2000); // wait 2 secs//

}else{ }

digitalWrite (buzzPin, LOW); // turns the buzzer off//

}

It has now been hard wired to a Nano (obviously without the display) and powered by a PP9, sits in a little project box just under the freezer.

Rob.

Sounds complicated.
If space is problem you could sense the open door using a miniature optical photo interrupter stuck to the fridge body and a piece of thin cardboard taped to the door.
This should give you a mechanical resolution of about 1mm. If the fridge has a standard rubberised magnetic seal then it'll snap closed at that distance.

Hi thanks for your reply.

I did think about miniature sensors on the door, but the freezer is between a wall and a kitchen unit, the reason that the door doesn't close properly is that it just about rubs against the wall, stopping the magnetic strip taking over.
The code itself isn't too complicated if you take out the lcd display part once you have your temperatures calibrated. It can't be I understood it!!.

Congrats on a successful first project!

A tip for using this forum: Its easier to read your code if you use the code tags (</>) around it.

//Like this

I wonder if your floor ever gets cold enough in the middle of winter to trigger the alarm? You will not be popular if your alarm goes off in the middle of the night!