Microcontroller used to power up resistors

Thread Starter


Joined Jul 18, 2012
Here is my problem. I'm using a PIC18F66K80, my goal is to power up heating resistors to increase the temperature in a close chamber
These resistors are WH50 1k2. Basically, 1200Ohm resistors, delivering up to 50W.

I have a problem, I must be able to control them with my PIC (PORTD than can sustain 8mA). But I don't know how to do it, I'm even wondering if it's possible as these resistors are connected to the sector (230V AC)

After researching how to do it on the Internet, I found that it was possible to drive loads that demands a lot of power. But the only examples I could find were about 24V max. So I'm thinking that maybe there is a limit.

So my question is, is it possible to drive a device that is connected to the sector using a microcontroler?

My first idea was to use a MOSFET transistor instead of a NPN as the current on the "base" will be 0. But I might be wrong.

What do you think?
Thank you


Joined Apr 24, 2011
First, DO NOT connect the PIC directly to the AC line. While there may be some good ways to do that we cannot discuss them here as they violate the site's TOS and they are probably not necessary.

Next, get some other resistors. While they are rated for 50W you will be dissipating 44 watts inside each one (assuming it is direct across the 230V AC line). They are only rated for 50W at 25°C, it drops with temperature, though you did not tell us just how hot you will be running these. What is your max temperature?

So assuming you select some proper resistors you can connect them using a relay with contacts that accept 230VAC at the current your resistors0 will run at. The current with 1200 ohms is under 0.2A so that should be easy for any relay rated for the voltage to safely handle.

Any micro (PICs too) can drive a transistor or MOSFET that turns on the relay. The SSR mentioned is also a nice solution (and probably cheaper then the relay).

Will you be 'closing the loop"? Will your PIC actively monitor and control the temperature? That is not difficult: you read temperature "somehow" (A2D off a voltage device, or I2C off some other sensor) and make some guard bands: if the temp is lower then your set-point turn relay on. If temperature goes a degree or two above you turn it off. Using a dead band like so keeps the system from "chattering" on and off continuously.
Last edited:

Thread Starter


Joined Jul 18, 2012
Thank you nsaspook and ErnieM for your help.

For the Resistor.
As I must simulate the environment of a desert I think that the max temperature would be 55-60° Celsius. And you were right about the power decreasing, I didn't even think about that... at 60°C I should be around 40W max.

About the calculation of the power dissipated. I have 5 resistors WH50 1K2. Is it better to put them in serial or parallel? I think parallel is better so I will have more power. After calculating the power dissipated with serial configuration I have barely 10W.

So I think that if I have 5 parallel resistors connected to the sector, I should get 44 W for each like you said. Is that hot? I'm sorry, it's the first time I'm using these. I mean I'm thinking about a lamp which is 60W and it's not even hot (unless I touch the lamp lol) so I don't see how 44W is going to heat a chamber (75 cm x 30 cm x 30 cm), but maybe because the resistor have a larger surface it could work. Should I get other resistors? or could it work with these ones?

About he PIC.
Yes I will close the loop, I'm actually using OneWire DS18B20 temperature sensors to monitor the temperate and I'm pretending to regulate the temperature. I'm saying that I'm pretending because it's just an on/off solution. I know nothing about how the temperature is increasing (I mean the speed), I also have no data on the inertia of the temperature. So yes, the loop is closed, but nothing fancy to close it.

Question on the first solution, so I need a transistor and use the SSR directly?

Questions on the second solution.
If I use a transistor to drive a relay that will drive my resistor, then the transistor must be able to sustain 230V right? or not?
EDIT : It seems that the relay is completely isolating the transistor from the sector, but I don't know if my transistor has to support 230V anyway.
As I'm using a pin that can deliver only 8 mA I suppose I should use a MOSFET as the current is zero on the grid.

Thank you again both!
Last edited:


Joined Aug 27, 2009
You could drive the SSR directly (with a current limiting resistor in series) with PORTA, PORTB or PORTC as they have 25ma drive capacity.

Resistor = (VS - VL) / I

From the SSR data-sheet at 20mA VL is about 1.2 volts typical.

When used as digital I/O, the output pin drive strengths
vary, according to the pins’ grouping to meet the needs
for a variety of applications. In general, there are two
classes of output pins, in terms of drive capability:
• Outputs that are designed to drive higher current
loads, such as LEDs:
• Outputs with lower drive levels, but capable of
driving normal digital circuit loads with a high input
impedance. Able to drive LEDs, but only those
with smaller current requirements:

Thread Starter


Joined Jul 18, 2012
Thank you very much, the schematic on wikipedia about the SSR quite scared me.

I will investigate this solution too as it's more accessible for me than I thought.


Joined Apr 24, 2011
At 60°C the resistors derate to about 80% or 40W each. (I saw that on a TT Electronics data sheet.) Connected directly across the line means 44 watts in each which may work for a while but may have a long term reliability problem, meaning if you only intend this for a short time test it should be OK, but don't do this is it will be used every day for the next 5 years.

If you place 2 resistors in series across the 230V line then the power is down to 22W with 11W in each: that should be reliable for the long term: I never use resistors above 50% of their rated dissipation but my stuff tends to be for military products and needs to be very conservative. Two pairs (4 resistors total) gives you 44W and a spare resistor.

Depending on how large your chamber is you may be able to use an incandescent light bulb as the heating element. It is certainly cheap and makes lots of heat.

All "temperature chambers" I've ever used (they go both cold and hot) use a bang-bang control such as this: heat (or cool) to the setpoint then turn off, and back on when the temperature changes a small bit. It works, it's very standard way to do things.

A fan inside the chamber will go far in eliminating hot spots.

Check the data sheet for that SSR and peek at the "Standard Circuit." The "Vcc" comes from your PIC side and could be the 5V the PIC runs off. They spec the part with 20mA thru the driving LED at 1.2 to 1.4V, so a 180 ohm series resistor should work. TR1 will need a series base resistor, something around 2K will do as it only needs to supply 2mA (what the PIC safely delivers) to turn TR1 on.

John P

Joined Oct 14, 2008
Using the solid state relay should be safe, and it's cheap and easy.

It's common in temperature control systems to use a PID (proportional-integral-derivative) control loop, which you can program into the processor. There are probably lots of examples out on the Internet. If you just turn on the heater when the temperature drops and turn it off again when the temperature rises, you're likely to get a some serious fluctuations in temperature. But I think for the size of chamber you're talking about (unless it has a lot of leaks) 44W as Ernie suggested should be plenty of power. Though there is a question of how rapidly you want to change the temperature from ambient up to desert conditions--big heaters would get the temperature up quickly, but then you might never need them to maintain the level.

I think where you're using the word "sector" we'd say "power line".

Thread Starter


Joined Jul 18, 2012
Thank you all for your help.

Well I'm trying to know how much time I would need to rise the temperature from 30°C to 55°C. Thing is, my supervisor won't let me play with the power line and I don't want to die prematurely. I would like to do it in less than a minute but that seems quite a lot of power. Unfortunately I can't check, I don't have the training for that.

And yes, I'm saying sector for power line, my French overpowers me sometimes.

I'm trying to implement both solutions (SSR and transistor + relay) as the work will actually be for someone else next year. But thanks to you I'm learning a lot and way faster!


Joined Sep 7, 2009
If you can, get a 60W light bulb in your enclosure and see what that does to the temperature.
I have a vivarium a little bigger than your tank that is heated by a 60W light bulb on a thermostat (although only to about 10 C above ambient) and I would say the bulb is on about 10% of the time.
How much power you require to keep a constant temperature depends a lot on how well insulated it is. The vivarium is chipboard with a glass front and has ventilation holes so not well insulated at all.


Joined Apr 24, 2011
Thing is, my supervisor won't let me play with the power line and I don't want to die prematurely. I would like to do it in less than a minute but that seems quite a lot of power. Unfortunately I can't check, I don't have the training for that.
Too bad... how will you ever test your final circuit?

You can jump start your development by forgetting the controller and just wiring the resistors direct to the line. Pop them into your chamber and see how long it takes to get to temperature.

Just make damn sure the resistors are well insulated and please be safe.


Joined Sep 7, 2009
If you want an idea of how fast it will warm up in a perfectly insulated box of your size (67.5 litres), you can use the heat capacity of air which is about 30 joules per mole per kelvin.
You have about 3 moles of air so you need 90 joules to raise the temperature 1 kelvin, and in this ideal situation 50W would raise the temperature by 1 kelvin about every two seconds.