Digital Thermostatic Beer Refreshment Regulator




About: Jack of all trades, master of none, Sigh...... how does one get good at something when there are so many things in this world to learn?

This is my work in building an Arduino based digital thermostat for controlling my DIY kegerator.

The project is based around the Arduino and uses a LM35 sensor for temperature measurement, a solid state relay for turning on/off the refrigerator, and a serial LCD panel for displaying the temperature inside the fridge and a handy-dandy button to turn the back-light on for reading beer temperature in the dark! WoW!! .

I consider this v1.0 and plan to update this instructable as I add new and fun things that make beer drinking more pleasurable... as if that can really happen!

Special thanks to Brutus @ from his proof of concept work, Sean Coates for his advanced work with beer brewing and Arduinos, and an Extra Special thanks to Mikal Hart @ the Arduino Forums who helped me through my coding nightmares!...( I owe him a few beers).

Step 1: Getting the Goods.....

Things we will need to get this project off the ground:

-An Arduino or a variant of ...
I used a spare Freeduino SB that I had, I like the miniUSB port.
-A serial LCD panel.
I used a SLCD162 MeLabs
Serial LCD is important since it uses only 1 pin on the Arduino!!
-A Solid State Relay:
I used a NTE RS1-1D4-21,( 15 bucks a piece..) it is circuit board mounted type and I designed my own circuit board to support it.
You can use any similar relay but it must have a trigger voltage of at least 5 volts on the DC side, and can handle around 3 amps or what ever amperage your refrigerator or freeze draws plus extra for head room. You will have to use a bread board or design your own circuit board if you use any other type.
-A LM35DZ temperature sensor.
I bought a few off of Ebay from Thailand for super super cheap, like 5 bucks including shipping... did I mention they were from Thailand? crazy!
-A couple of resistors:
10k and 100k, 1/4 or 1/2 watt will work fine.
-Project Box:
if you want to protect your circuits from the elements (or drunks) Mine is a standard Radio Shack box, but you can be more creative.
-22 Gauge stranded wire:
The more colors the better. Makes it easy to know what goes where.
if you want to make a cool LCD stand like me
for the cool LCD stand and project box
-Header Pins and Connectors:
for easily connecting the wires to the Arduino, not necessary but makes things look nice.
-Momentary Push Button:
for the LCD backlight function. This is a "normally off" button and is only "ON" when it is held down
-Terminal blocks , 2 position type, PCB mounting
-Heavy gauge extension cord (14 gauge or so)
-Cat5 cable for LCD connection + Cat5 jack

Soldering iron
Heat gun
PCB board and etchant
Gerber Multi-tool
....more Beer

Step 2: Building a Box...

I didn't take any many pictures during construction so I'll just piece together the "need to know" stuff the best I can.....

If you don't have the time or energy to etch you own board you can easily do this with a pre-drilled board from radioshack or just use a bread-board to hold everything together, there is no wrong or right way... just what works best for you.

I won't do a "How to etch a circuit board" tutorial in this instructable since I already did one in my last instructable on how to make a guitar Distortion pedal which you can read here Dead Rat Pedal .

I mocked up the circuit board design in Adobe Illustrator based on the data sheets of the components, it isn't perfect but it works for my purpose. (See the PDF for the actually layout).

In the future I will do a revision of this board since I wasn't planning to use a LCD panel originally. I had to make some extra solder connections to the Ground and 5 Volt lines for the lcd panel so it is a bit messy.

This is really as simple as following the pin-out on the last step and connecting everything to their correct place... nothing too complicated that I remember.(Use the pictures as reference and they will guide you well!!)

The only difficult part I ran into was soldering the tiny pins on the ethernet jack for the connection of the LCD panel. You don't have to go the Cat5 cable route but it just makes it easier to connect and disconnect the lcd panel for future upgrades.... like for maybe a 4 line panel!!!

Step 3: The Cracking the Code!!!

This was definitely the most difficult part for me..... writing the code. There are a few similar projects out there that I originally borrowed some code from to get me started. Most of it was fairly easy to understand, but some I had no idea what it did or said. I'm an entry level Arduino programmer so I spent a lot of time banging my head against the wall trying to figure out everything. Software is not my strong point so I had a bit of help from the Arduino community to finally get something that works well and was still easy to understand.

Just open up the text file with the code, copy it into the Sketch software and upload it to your Arduino!
I made a lot of comments in the code for me to understand what is doing what, feel free to mod it to make it better if you can.... I dare you!! (then send me the code.. hehe!)

You might want to adjust the turning ON/OFF lines depending on how warm or cold you would like your beer to be. I have it set between 1 and 4 Celsius... which is between 35 and 40 degrees Fahrenheit, because the beer inside the keg is about 5 degrees Far. warmer than the fridge.

If you are adventurous and good with C than you could write a neat Celsius to Fahrenheit conversion for me since my formula is not the greatest.

- I plan to rewrite the temperature reading section to take an average of readings over a few second range to get a more accurate temperature output, but for now it works fine.

Step 4: Beer Has Food Value, But Food Has No Beer Value....

Nothing left to do now but pull the handle, relax and have a beer!

Here are some pictures of the internals of my DIY Kegerator for your viewing pleasure.

I acquired a GE min-fridge and thought it would be a good kegerator, it took a bit of modding but I finally got it up and running.
-The cooling coils inside were originally at the top of the refrigerator which made a little freezer area but a 1/6 barrel keg wouldn't fit inside. So, I had to carefully bend the unit so it sat nearly flush with the back wall of the fridge.
-Another modification I made was removing the molded plastic inside the front door which holds can sodas and such. There were about 20 screws to remove under the door seal, then I added a then panel of sheet metal to cover up the insulation.
-Drilling through the top of the fridge was a bit nerve racking since I couldn't determine where the compressor lines were running. But everything went well and attaching the tower was quite easy.
I rigged up a computer case fan to an old 12V wall wort that blows cold air into the tower to keep the lines cold and help combat any foaming issues.

Any question, comments or suggestion are most welcome. I will update this with any modification when they are completed.

Thanks for looking, and keep drinking!



    • Frozen Treats Challenge

      Frozen Treats Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Classroom Science Contest

      Classroom Science Contest

    21 Discussions


    7 years ago on Introduction

    Awesome job. Bonus points for etching your own board too! Glad to see it's in a nice display case.

    A word of warning to anyone who tries to replicate the push button portion based on the picture. Is that a mistake with the pull resistor for the push button? This looks like pushing the button would short '5v' to 'gnd', which wouldn't be great. Instead of the the switch connecting to the 5V side of the resistor, instead connect it to the digital_pin3 side of the resistor. That way, it will pull the digital pin3 to gnd when pushed, and the resistor will pull D3 up to 5V when button is released.

    I'm sure the real design is correct, and the focus of the attention isn't on the pushbutton, but hope no one shorts out their arduino's 5V to gnd with this. :)

    5 replies

    Reply 7 years ago on Introduction

    I'll investigate your observations more closely,as it was a few years ago I made this project and haven't had any issues during this time. Pulling a pin high or low can be done on either leg of the switch.. the current flowing to Dig_pin3 is 5volts which is not a problem for the pin to handle... the amperage is only .0005 through the 10k resistor. If the resistor was on the Grd side of the switch and the button was pushed, then the same amount of current (5v) will still flow to the pin 3. The Arduino chip is designed to read data in the form of 0v -5v on the digital and analog pins... so I'm not sure what your concern is?
    Thanks for the comment, I love feedback as it helps me to continue to learn and grow!


    Reply 7 years ago on Introduction

    Hi. I hope I'm not looking at the pic wrong.
    I'm talking about the pic in Step 1.
    It looks like the backlight button is connected to 5V and Gnd.
    That doesn't threaten Dig_pin3, but if it shorts 5V and Gnd together when pushed, that sounds bad for the 5V power. A short-circuit to gnd will pull as much current from 5V as the possible (assuming the wires & pushed-switch are all quite low resistance).
    Well, I'm also assuming this switch works like mine... open circuit normally, and short circuit when pushed.
    So, no concern about arduino data pins. Concern is that pushing switch will connect the red & green wires (5v & gnd) together.


    Reply 7 years ago on Introduction

    Just remember that we are talking about DC power here, electrons flowing from positive to neg. Let me explain that part of the circuit a little clearer... the 5v current is flowing to the switch and to digpin3 through the 10k resistor. Because the switch is normally closed the current just flows to the arduino pin3 and it is read by the software a HIGH (5V's), but when the button is pressed, the current flows the path of least resistance and flows straight to ground, causing the digpin3 to have 0 V's which the arduino reads as LOW (which signals an event to turn the backlight on in the code).
    DC current flows from + to - ... what you would refer to as "shorting out".... (that is more of an AC term). Think of this... as a kid I would wrap a big nail in a length of wire and then attach one end of the wire to each side of a battery (+ & -), thus creating a homemade electromagnet. The wire connects the + and - sides together, straight through... and because Electrons flow from high concentrations to low concentrations we have current!
    If you cross AC wires then you can get a big mess! (15A's of power compared to 50Ma's with DC) ... DC only works when you cross the wires because current has to flow to be useful!!
    But back to the Aurduino... if I had the same circuit with 12V's instead of 5V then I would blow out the pins of the aurduino and short the board out... other than that its okay! I hope this helps...


    Reply 7 years ago on Introduction

    Thanks for taking the time to explain, it's very cool & generous of you.
    But, this stuff is actually my profession, so I'm just trying to help since you took the time to make a good instructable, and so I want to pay back since I've been too lazy to make instructables myself (yet). Plus, I'm a fellow new homebrewer! :)

    First, don't take my word for it.
    Ask a friend you trust, or check out the web, like:

    Thanks again for the good instructable & cool responses.  -Brian

    PS: BTW, if you are planning to revisit, I'd recommend referring to Figures 3 & 7 in the LM35.pdf spec.
    Figure 7 shows how to get accurate measurements under 2 deg C without a V- (negative voltage) available, and
    Figure 3 is good insurance since you're putting the LM35 at the end of a longish wire or cable.

    PPS: if you want to know more about what is probably happening in your ckt, or the magnet you describe, or other circuit equations, I can explain more. But perhaps you'd like to see for yourself first.
       If so, start by using a volt meter and measuring the voltage of your 5V while pushing the switch. Arduino would like it's 5V to stay 5V, but I'd bet the voltage drops, a lot, but it depends on how much current/power your 5V supply can produce, and how much resistance your particular switch has when pushed.
       (I wondered if maybe you have a switch with a relatively large resistance when pushed, but as you describe, in order for the dig_pin3 to see a 'low' voltage, the 5V attached to it's resistor must go 'low'. So that 5V supply wants to take the easy route, thru your switch, instead of going thru the arduino & other ckts. The switch draws SO much current from the source that your source can't keep up the 5V, and droops to a lower voltage.
       If it didn't, then something is probably getting hot (the switch?) and providing enough resistance to keep things from actually going worse.) Another way to describe that you don't have a (normal & safe) pullup ckt... the dig_pin3 never has current going thru it, so current never goes thru the R attached in your ckt, so the R has no effect (ignoring transient effects). i.e. it's not acting as a pullup resistor.

    PPPS: Check out .  It's a sweet (& cheap!) way to make real boards with finer geometries, vias, etc, without having to etch blanks yourself.
    You can use eagle design software (free) for smallish 2-layer boards.  There's a lot of tutorials & etc for the Eagle (like on, but the dorkbotpdx dude running the board program is doing something awesome.  I've got a lot of 50 5V relays (10A at 125V) that I'm planning to make a simple board for.  Just enough for screw-connections (for the AC), the switch, and a transistor so that the arduino digital out isn't trying to drive the relay by itself (the relay coil needs a lot of current to switch on).  If I find a cheap optocoupler, might use that too, for extra safety.  Hope to use these like you did, but use 2: 1 for heating pad (now that winter's coming) and 1 for the freezer I found that I can fit my fermenter in.

    Happy brewing!  Cheers!


    Reply 7 years ago on Introduction

    Thanks for all the links, seems I have a bit of reading to catch up on. I found this tutorial about implementing a proper pull-up resistor in my circuit.. PULL-UP (see figure 5.6), seems as though I should have a 100 ohm in place of the 10K and move the 10k in between the 5v and 100ohm resistor going to the digpin. Makes more sense to me seeing the schematic now.. what I currently have works but isn't as accurate and reliable as how it's explained in the tutorial. 

    I've been considering ditching the LM35 in favor of either the LM36(TMP36) because of its -50 to 125 C range or maybe even the Dallas DS18B20 1 wire version. has both, but has a waterproof version of the DS18B20 that might hold up better in an environment that has condensation and possible beer spills.

    Thanks again for all the comments... this isn't my profession, just a long time hobby built out of love for electricity.

    One of my friends designs and builds temp controllers which he sells as kits. I've thought about scraping my project and picking up one of his kits since they are so simple to program and use.... and best of all.. they just work!


    7 years ago on Step 3

    For Fahrenheit, try changing:
    temp = lm35_val;
    temp = (lm35_val*1.8)+32;

    1 reply

    Reply 7 years ago on Step 3

    Thanks for the tip!
    I recently pulled out this project and started rewriting the code for better temp sampling and stability. I started home brewing recently and have need to have my beer fermenting at precise temperatures....I hope to have the updated code posted soon.


    8 years ago on Step 4

    Only slightly off topic; how exactly did you bend down the cooler? Is the tube metal or some type plastic? I have a very similar fridge that I use for a home-brew kegerator but have to use 3 gal cornys because of the restricted height. Thanks


    9 years ago on Step 4

    do you have any photos on how you attached the LM35 to the beer line?

    2 replies

    Reply 9 years ago on Step 4

    I didn't attach the LM35 to the beer line. I just experimented with different placements in the fridge to find the best equilibrium for the internal temperature. Too close to the coil would give a colder reading, so I opted for nearer towards the front by the door... it's kind of trial and error I think....


    Reply 9 years ago on Step 4

    ah.  cool.  I was thinking about adding a T-connector to my beer line and dangle out a bit of tubing that I could then have the LM35 sitting in.  that way, as the beer flowed out, it would hit the LM35 on the way by the t-connector.  I would have it secured in the tubbing (dongle) with some food safe silicon.

    that would give me the actual temp of the beer.


    10 years ago on Introduction

    Looks good! Glad to be of help to somebody out there. Now If I can just get someone to send me a free mini-fridge I can pull that project out again ;-)

    1 reply

    Reply 10 years ago on Introduction

    Cruise by your local college near the end of the semester. You should be able to pick up a mini-fridge for $10!


    10 years ago on Introduction

    Hi, Great circuit. I will definalty build one for my kegalator. What I am also looking for is a similar controller for my fridge that I ferment my home brew beer in. I require temperatures ranging from 0 C to 30 C. This means I need to controll a heater mat in the fridge as well. Any Ideas on this?

    1 reply

    Reply 10 years ago on Introduction

    Repeat the code with and output for an SSR connected to the heater mat. Just make sure that you build in a few degrees of deadband so the two aren't fighting each other. You may also want to add a couple of additional buttons to increase and decrease the temperature setpoint so you don't have to recode every time that you want a new temp set. Another way to do it would be to pick up a digital thermostat and wire it into an SSR or control relay. But, it might be tough to find one with the range that you need.


    10 years ago on Introduction

    Awesome. This is exactly what I need as I'm adapting a deep freeze as a 3 corney kegorator as well as a fermenting fridge that will also need better a better thermostat. My question is, do you feel you need the LCD readout once everything is tested and running properly? For aethstetic and simplicity's sake, I'd prefer to not have a temp readout, unless I'm connected to a computer. Does your system work consistently, once set up?


    10 years ago on Introduction

    In reading through your code, I'm not sure if there's a "time delay" feature for the compressor or if you're simply bypassing the thermostat contacts (which should cover it...maybe). Refrigerator compressors typically shouldn't be restarted immediately after they've shut down (too much current draw) and there is a built -in delay of a minute or two in case the unit is unplugged/power outage etc. An internal "wait" plus an initial "wait" loop would cover it if you think it's necessary.

    2 replies

    Reply 10 years ago on Introduction

    This is good you mentioned this up front here!

    I built a functionally near-identical (but messier) fridge unit using a chest freezer, PIC, SSR and an I2C thermometer chip.

    I tried to figure out for ages why the compressor would periodically lock up and fail to start. I thought the $0 freezer was just a piece of junk.
    One day I had a chat with a fridge guy and he said I needed a time delay for the pressure to dissipate in the compressor.

    He said it needs a wait of at least 15 minutes to be safe. Unfortunately, I lazily didn't socket the PIC, and can't update the code, so what I do is slowly ramp the temperature down by hand after adding a new keg.

    However I'm going to build a new setup soon using some one-wire sensors to track the temperature of the fridge as well as both kegs of beer. I had a few issues with beer freezing on the bottoms of the kegs, so I'm going to add a "beer about to freeze override" system, as well as a compressor start delay.

    Also maybe some strain gauges from a dead scale to measure the weight of the remaining beer? 1L beer = ~1kg...

    I got 2 5-gallon kegs of local stout in there right now, yum! Enjoy your fridge, silverhalo!


    Reply 10 years ago on Introduction

    This is good information to know. I'll definitely take a look into this and see what I can come up with to fix this. Thanks!