Everyone knows that when the refrigerator door is casually closed it sometimes bounces open again just a little. Enough to put the fridge light on, but that’s often un-noticeable even at night unless one looks closely. After a day out, you may come home to sour milk and dodgy chicken. After several mornings with debatable milk, the author decided that something would have to be done, and came up with this little gizmo. The light in his fridge always comes on even with a 2 mm door opening, so that’s a promising place to start. The TEMT6000 phototransistor device from Vishay will ‘see’ visible light, and is both cheap and readily available. It has negligible dark current and can sink a few μA happily. Since a battery powered device is required, the current for the entire circuit has to be as low as possible. A PIC with ‘sleep’ mode is a good choice, and the 12F629 fits the bill nicely: small, cheap, easily obtained, with an internal RC oscillator on board, and up to five I/O pins as well. According to the PIC12F629 datasheet  all pins have to be set as inputs and pulled high for best low power operation, and every peripheral in use will add some drain. Since the unit is permanently powered from a battery, there is no need for brown-out protection. No A/D or comparators are required, and no watchdog timer either, allowing the lowest power settings in Sleep mode to be exploited. Typical current here is shown as 1.2 nA with a guaranteed maximum of 770 nA at a 3 V supply, reducing to 700 nA at 2 V.
The type CR2032/1HF Lithium cell has a rated capacity of 230 mAh and a nominal voltage of 3 V . On this basis with the typical current in sleep mode the battery would last over 250 years, or effectively for its shelf life, so a CR2032 with tags is worth soldering in to a PCB. Even at the maximum Sleep current, it would last for over 30 years — certainly longer than the fridge! One advantage of a Lithium battery is its long shelf life, and an ability to deliver power at low temperatures. An obvious choice to make a squawk is a piezo sounder, again cheap and easily obtained.
This can be driven from the PIC directly across two ports and will withstand 3 Vp-p drive easily. After some testing, a Kingstate KPEG827  proved a worthy candidate. It makes sufficient racket at 3 V drive from about 2.0 kHz to about 4.5 kHz. The PIC program was developed using MikroElektronika products only: a fully paid up MikroBasic compiler and the BigPIC 4 board. However the final program is so small that it can be compiled using the free version of MikroBasic (free up to 2 K of code, download at ). For the simple reason of ease, the PIC used is the 8-pin DIL version. This can be re-programmed easily using a simple DIL socket adapter. ICP is OK if you have to use SMD but the socket takes up a lot of room and negates the purpose of SMD in the first place on a very small PCB. I used the PicFlash2 programmer again from MikroE, but could have used the on-board EasyPIC4 programmer. The source code used is available free from the Elektor website . The timer will work with anything that can pull the GPIO.3 input Low and hold it Low, so could be used with bi-metallic temperatures sensor, or the software adapted to read a One-Wire temperature sensor. It could also be used to sense over- or under-voltage etc. with some adaptation.
The delay before the alarm sounds is adjustable from about 1 to 255 seconds in software. One word of warning: there are many PIC programmers out there. If you use other than the MikroE programmer with the code from the Elektor website, make certain that the PIC oscillator configuration is correct. Not all software reads the Configuration correctly; it needs to be set for INT RC OSC, with GPIO.4 and GPIO.5 as I/O. Anything else will stop the oscillator and may damage the PIC! Some programmers need these parameters to be set manually before blowing the chip. In case of doubt, consult the source code listing. After some tweaking with the port settings, the sample chip consumed an estimated 0.02 μA in Sleep mode. Once triggered the unit consumes about 500 μA for the timer period of 1 minute, then about double that once the sounder is operating. This is well under the maximum current for the cell used (10 mA max. pulsed) and would bleat for about 10 days with a fresh battery, which hopefully will never happen. With a fridge opened say 20 times a day for less than a minute, the battery life expectancy reduces to about 9 years, still a reasonable longevity. The photograph shows a prototype built on a small piece of perfboard by Elektor Labs. Here the ambient light sensor is a type TEPT5600 (which looks like a UV LED).
As opposed to TEMT6000, the TEPT5600 has to be pointed directly to the light source due to its narrower ‘viewing angle’. It also requires the value of R1 to be doubled (approximately). Even on perfboard the circuit is compact enough to be fitted in a small ABS case, preferably one with a battery compartment because that’s the ideal place for the sounder. A small hole in the end should allow the sensor to ‘see’ the light. This hole was filled with clear epoxy resin to act as a window without allowing too much moisture into the case. The latter was achieved by fixing tape over the inside then filling the hole flush. It was then allowed to set whilst the box was fixed upright. The circuit board may be fixed in place with a little hot melt glue. The unit could be mounted to the fridge wall using double-sided adhesive foam strip or Velcro, but space allowing it may equally sit on the shelf. To start the microcontroller for the first time, or when the battery is replaced, the fridge door should be closed or the sensor covered. Once the sensor detects light, it takes 60 seconds before the alarm sounds. When in the fridge with the door closed (or the sensor covered) the unit goes back to sleep… peace! Of course the fridge does have to have a light that works or the unit will think it is in the dark all the time.