Wifi Fridge
- Hey, your makerspace lacks a fridge, here, take this!
- Thanks! But pal, it's broken.
- Exactly.
And that's how I got a box to have cold milk in my coffee. Or to be a bit more precise: milk popsicles.
Refrigerator 101. A fridge can be broken many ways. You have an insulated box with a door. Since it doesn't have a handle, it can't break. And the door closes perfectly, it can be used as a storage. The insulation is in perfect condition, so if you put something cool in it, it will try to do its best and keep it cool. Very old fridges had ice in them, so if you freeze 3-4 bottles of water and put it in, it could be called a fridge.
Since 1927, a fridge can cool itself. In most cases a compressor compresses a gas to heat it up. How? It's the law! The ideal gas law. PV=nRT - n, the amount of gas is a pretty fixed since the system is closed, no gas enters or leaves the pipes. R is the gas constant, and since the pipes are metal, they don't expand, so V volume is also fixed. So, P pressure is proportional to T temperature: increase the pressure, the gas will be hotter, that's why the back of the fridge is warm. (I know, I cheated, we add old gas from the cold side) We compress (so heat it up) our gas, let it cool by the room and release, expand it inside the fridge. Decreased P means lower T, so the fridge must be cool now.
The compressor makes some sound, no leak, it works perfectly. Then how is it broken? It never stops cooling, it became a freezer! The last component is the thermostat. This has a mechanical one, and it doesn't stop, even when I turn it from 5 to "OFF". Gotcha. It's time to repair!
Supplies
A fridge, better if the thermostat is broken.
A microcontroller, ESP8266/ESP32 if you want to use the wifi.
Temperature sensor, preferably digital.
A magnetic sensor, a Hall-sensor is good too, but reed relays are cool. Oh, and a magnet.
I only had a classic relay, SSR-s are superior, use them.
Electronics
You can freely change anything, just please update the code. Also, even if you use the sample code with this schematic, be aware: the support of these boards are fantastic! They can keep you busy for a long time just because digital pin 4 in the code is D2 pin on the board for the DHT11. And D0 is pin 16, D4 - pin 2.
I tried an unlabeled analog NTC sensor from my box of random parts first, but switched to a digital sensor pretty fast. It's a nightmare to calibrate analog sensors. Even the infamously inaccurate DHT11 is more than enough for this task. Dirt cheap and way better than a self-calibrated one.
I hope you found the LED. The fridge is missing a key component: light when you open it. The light is done by hardware, there is no need to turn it on and off by a microcontroller! A lowend NFET is enough, or if you utilize some 12V led strips, choose a correct one depending on the amps.
The reed relay gives the "someone is raiding your supplies" and "that lazy guy forgot to close the door" signal.
The SSR/relay gives power to the compressor. For safety reasons, use the NO (Normally Open) and COM (common) pins, so if the microcontroller fails, it won't turn your cool drinks to ice. Also I have a relay module, NEVER drive a relay directly from a microcontroller pin! Inductive loads will kill the micro! Also safety: depending on your location, it's 110-240V AC. It can kill you, so never EVER do this when the fridge is plugged in!
The Cool Side Assembly
Everything on the sensor side is fitted on a small proto PCB, but how do you connect the "cold end" and the "hot end"? 4-core security alarm cable is the answer! The temperature of the fridge is usually measured INSIDE, so the old probe went in there somehow. The security alarm cable is similar in diameter (UTP is too thick in this case), VCC-GND-door-temp signals utilize exactly 4 wires, just do it!
The plastic inside is weird, my double-sided tape couldn't stick to it, so had to improvise until I find a better tape. I don't want to use screws, but it would be a solution.
Hot End Assembly
Everything must fit inside the old thermostat's box. Some interesting facts:
- you can buy compact 230V AC to 5V DC power supplies, no need for wall warts or "DC IN" barrell connectors
- with the smart use of Wagos (not Vagos) it's easier to assemble
- the red light doesn't always mean something is burning
CLEARANCE, again, it's mains AC which won't hesitate to kill you; make a wide "demilitarized zone" between the AC and DC parts. You can clearly draw a straight line somewhere in the middle, left means dead, right means it will probably tickle you but it's more likely that your ESD sparks will kill the electronics.
Also, glue or screw the parts, you don't want them to jiggle around and make a warm little electric fire.
The fridge is a huge metal box, and wifi signals tend to trap inside closed metal boxes. The antenna shall face the outside. If you can, make the USB port accessible.
Final Steps
Now go to my GitHub page and download the code: https://github.com/the-developer-guy/wifiFridge
Arduino, ESP8266WiFi library and a DHT11 driver is needed for this project. Change the SSID and password, doublecheck everything, and upload the code!
If you give your device a fixed address, it will be easier to find the info later.
Now you can check the status online: the door, current temperature and the compressor!
Endless further development possibilities:
- beeps when someone leaves the door open
- getting a mail when someone leaves the door open
- not wasting electricity if someone leaves it open
- setting the temperature remotely
- maybe access logs
Thanks for reading and leave your upgrade ideas in the comments!