NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Programming for realtime clock/ tempsensor

February 08, 2010
by BoloBit64
BoloBit64's Avatar

I want to use the tempsensor ,via adc, to control a transistor(used as a switch) that will turn on and off the a/c unit in my dorm, because it does not have one. I would also, on the same microcontroller, like to control a different transistor hooked to a house alarm on/off switch with the real time clock setup to set a time for it to be on(ex. 8 o'clock to noon) and then turn off when not needed.So my question is how would i go about started/mixing the code from both to combine it into one code? Feel free to leave any comments and i wil be sure to check regularly!

February 08, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi BoloBit,

The best way to figure out how to combine different pieces of code is to just go for it! Start small, definitely put together the base project first. In this case the temperature sensor. Then I would suggest hooking up an LED and just turn that on and off pretending that will be your a/c unit (which you will later figure out how to interface with). After that you can begin working in the elements of our real time clock code and start incorporating the timing elements.

One thing I do have to bring up is that you will have to do a little bit of thinking about how your MCU is going to turn your AC unit on and off. I have no idea how the "power" switch to your AC unit works so you will have to be careful when interfacing with it.

Let us know how your project gets along, and let us know if you run into any problems.


February 08, 2010
by BoloBit64
BoloBit64's Avatar

i want to hook up the ac unit with a transistor. It will be spliced between two wires of the postive side of the on/off switch. This will turn the ac unit on automaticly and still have the master on/ off switch hooked up. I can then keep it off, if i so choose, even if the microcontroller tells the ac unit to turn on. I would also like to know if a 50N06 N-channel MOSFET will work for this idea as the transistor? I will post the progress of the code and let me know if anything is wrong or can be put more simple terms!

February 08, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi BoloBit64,

If you're talking about putting a MOSFET directly in series with the 120VAC power line, please don't try this -- you will destroy the MOSFET and possibly other connected components.

A single transistor can't be used in this way to control an AC (alternating current) device because as soon as the drain-source connection is reverse-biased, a tremendous current will flow due to the inherent reverse-biased diode built into the MOSFET. (All that if you don't exceed the voltage limits of the MOSFET first.)

You probably need to use a relay to switch such a big load. There may in fact already be one inside the existing air conditioner unit that you can hook into in some way. Another option, which may be safest of all, would be to wire up a normal wall switch and use a servo to actuate it mechanically. But, done properly, the relay + 2N7000 + whatever isolation means are possible (optical, etc) can work. Not the MOSFET.

Working with 120VAC is dangerous. It is dangerous both to you and to your equipment. Air conditioner compressors are particularly "nasty" loads, too -- they draw tremendous inrush current, may have substantially non-unity power factors, etc.


Post a Reply

Please log in to post a reply.

Did you know that a microcontroller can measure an RC time constant? Learn more...