How do I get proportional 240V AC output from an Arduino-based PID controller to "dim" a rice cooker for a Sous-Vide project?

No need to use a PID. You can have a much simpler hysteresis control.

Thermal capacity of water is around $$4184 J/(kg·K)$$ In my case, the heater´s power was actually $$2kW = 2kJ/s$$ This means, it heats 1kg of water for about 0.5 K per second. In my case, 2kg water usually.

The bigger problem is precise measurement of the water temperature because of thermal convection. You want a circulator in there to keep thermal differences minimal.

Once you have established good measurement, you can do a simple hysteresis control, in my case I switched the heater on with a mechanical relays for 1s to have a 0.25 K rise.

Temp reading error is going to be around 0.5 K anyways, so don't bother with too much of a regulation.

For a purely resistive load, you will be fine with a simple relays, which also does the electrical isolation for you.

If you want to go for electronic switches, an optotriac will be just fine.


The device you are controlling has a very long time constant compared to 60 or 50 Hz power cycles. It is perfectly fine, in fact a good idea, to switch the heater on and off for whole line cycles or at least 1/2 line cycles.

I had a project with a PIC 18 controlling a couple dozen heaters and did exactly that. We used zero crossing solid state relays, with the PIC deciding whether each one should be on or off each 1/2 line cycle. Note that 1/2 line cycles (120 Hz at most) is a long time for a microcontroller. You can do straight PWM with a period of 256 half line cycles. Even at 50 Hz line frequency that is only 2.56 seconds, which is fast compared to the heater time constant. I actually did a Bresenham algorithm so that in some cases the period would be shorter, but that really doesn't matter in the scheme of things.

Now you have a single byte with 0-255 representing linear heater power. The outer control loop can do PID or whatever to determine what the heater power should be based on temperature measurements and other known characteristics of the heater.


You can divide SSRs into zero-crossing and non-zero-crossing switching. The former will wait until the main's phase will pass zero before it switches on. It controls a triac, and like any other triac circuit it will remain on until the current drops below a hold current, again at a zero-crossing. This type is not suited for dimming. The other type can be fired at will, and may be used for dimming: just control the moment in the cycle when you switch it on.

A dimmer requires information about where in the the mains cycle you are, and a somewhat accurate timing for switching the triac on. You don't need that. The cooker is just a heating element, and it will be slow in changing temperature. You can easily control the average power by switching half cycles on and off, like the zero-crossing SSR will do. The inertia of the cooker will make that you don't notice it. And it won't cause the interference you have from a dimmer.

For your PID controller it won't make much difference. In one case the output will be the main's phase, in the other the on/off duty cycle.
Olin calculated that for a 256 level control you would have a 2.5s cycle at 50Hz. Again due to the thermal inertia you won't need that accuracy. I think I would choose something like a 20 level control. That would have a cycle of 200ms at 50Hz, a few orders of magnitude faster than the time constant of the cooker.

There are other ways to control a triac, but the SSR is easy to interface and provides a safe isolation between your controller and the mains. SSRs are not cheap, but you can roll your own with just a handful of parts.