Programmatically Changing Wall Voltage

Hi Everyone,

I am trying to control the temperature in a refrigerator using my Arduino. I am correctly sensing the temperature inside of the fridge and now I am trying to determine the best way to control the temperature.

The easiest way is for me to use a relay for on/off control (same as a thermostat). This will likely be good enough but I am considering designing a feedback control system (PID) to control the temperature.

I was wondering if anyone has any experience with controlling a refrigerator cooling element in this way. Ideally I would like to be able to output a voltage from Arduino which then controls (likely steps down) the 120V coming from the wall.

I've seen variable transformers but I think these are overkill and are very expensive. Any cheap DIY ideas?

The mains power drives a compressor.
I imagine the white-goods company who designed the fridge designed it to run as efficiently as possible, so running the compressor at less the full-power seems to me like Not A Sensible Thing To Dotm.

PWM somewhere in the mHz rate would seem to me to be the way to go. That’s the way the thermostat in the fridge does it.

If the refrigerator is of the type that turns on light when it opens then often they turn off the refrigeration while open, as a kind of defrosting method (open freezer an it goes into defrosting mode).

So the sensor is connected with the light, just open and close this circuit with the arduino with a transistor.

Else try the relay thingy :wink: it is a crude method

why does not the ordinary temp circuit work, that came with the freezer?
Trace these lines and find the regulating mechanism, there should be some low power circuit turning on and off the freezer that can be tapped into.

Else: the regulator that is turned to adjust the temperatur normally (* ** *** ****) should be some kind of a pot or tunable resistor, get a meter and mesure voltage and Ohm on both extremes. Duplicate that with the Arduino using f.ex. resistor on digital pins, so to turn off fridge the arduino sends high on the pin that duplicates the value that you got from fridge on lowest value (often defrost) and high on the other pin when the fridge is on max.


Many thanks for the replies.

PWM is likely the route that I will have to follow if I can’t supply a variable voltage to the compressor. Unfortunately this type of on/off control w/ some hysteresis doesn’t give me a ton of accuracy.

PWM is likely the route that I will have to follow if I can’t supply a variable voltage to the compressor.

No this will not work. If you throttle back the compresses motor speed you will not change the amount of cooling you have in a liner fashion. In fact you will probably reach a switch situation where you are running the motor to no great effect. A fridge only cools when the compressor turns off and the gas is allowed to expand. It is the on / off cycle that is in itself a form of low speed PWM. There is the on / off period to get a shot of cooling and then a prolonged off which allows the temperature to rise to the target. There is not much else you can do.

Hmm, could try to add a fan to the heat exchanger to dissipate the heat faster or even watercool it, to be able to have faster on/off cycles = more stable temperatures. It will of course be a powerhog but more precise ::slight_smile:

to be able to have faster on/off cycles

The speed of the on / off cycle is governed by the physics of pressurising the gas to turn it to liquid and then letting it expand to provide the cooling. All that improving the heat exchanger would do is to increase the efficiency of the compressor / cooler. It would not shorten the cycle time.

A fridge only cools when the compressor turns off and the gas is allowed to expand.

  • Not quite true.

A standard refrigerator refrigeration cycle is continuous. Here is a link to a good explination. The Refrigeration Cycle | HowStuffWorks

Basically the longer you run the compressor the more energy you remove from inside the refrigerator (cools the inside). You can't however just quickly cycle the compressor on and off (PWM) like a motor or light, because the compressor needs a settling time of some sorts. I think it is because when you turn it off it has to drain the liquid out of the compressor before it can start again, can't compress liquid (not 100% on this though.)

If you use some sort of a closed loop feedback like a PID controller. You will calculate the difference between the actual temp and the set temp and if it is greater than your max allowable difference and the compressor has been off long enough, run the compressor. You will need to tune this however because it won't be linear due to settling times.

It will just take alot of experimentation to find the correct values for you PID gains.

What do you keep in the refrigerator that needs so steady temperature? A six pack of Bud? Old cheese?


It would be nice to have my Bud be exactly the correct temperature.

I'm trying to make a temperature and humidity controlled "cheese cave" (not far off w/ the old cheese). It doesn't need to be super steady but it would have been nice.

Overall I'm trying to minimize the time that the cooling element is active because it really drops the humidity in the fridge. I think that a careful on/off w/ hysteresis might do the trick. I'm still tweaking.

I would also like to know the answer to the original question. I have a few AC devices I'd like to be able to control with a micro. Mainly fans and heaters in response to readings from a thermistor and humidity sensor.

If you need fine grained control over the cooling power the best solution may be an inverter compressor Power inverter - Wikipedia. They are widely used in air conditioners and air heat pumps.

can’t compress liquid (not 100% on this though.)

Well you can be 100% sure because no liquid can be compressed, it’s a fundamental property of liquids. That is why they use them in hydraulic systems.

OK let me say that:-
A fridge only cools when the gas is allowed to expand.

@ psilokan

I would also like to know the answer to the original question.

You can proportionally control the power of an AC device with a triac (or SCR) Solid state relay (SSR) using phase angle control. You don’t actually control the voltage but switch on the mains each cycle. The power is determined by a small delay between the mains voltage crossing zero and switching it on.
You can get SSRs with dimming capability as they are sometimes known. Not all SSRs can control power proportionately, but when they can it can control the speed of motors or dim incandescent lights.

A fridge only cools when the gas is allowed to expand.

Although this is technically true - The "Gas" (Refrigerant) expands though a metering device (usually a capillary tube in a domestic Fridge), this happens only when the compressor runs. Refrigerant effect is related to mass FLOW rate - but of course we all knew that!

Most important - a fridge system is usually designed by engineers - most of which are alot smarter than me - the thermostats are designed for a specific 'off' and 'on' period to allow the refrigerant pressures to equalise, so that the compressor starts under minimal load -otherwise it will not start. (An inherent property of single phase comprssors). The 'on' period ensures that the oil that probably got pumped out on start up has time to return to the compressor.

Next, I understand that phase control wont generally run into the problem of starting under load, but if you slow the compressor speed you also inhibit the return of oil to the compressor - again generally bad.

Inverter controlled Direct expansion systems (as we call them in the biz), are very hard to design, even harder to retrofit.

A fridge costs little to run, but more to replace when something goes wrong. If this works - you got lucky.