element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Raspberry Pi Wine Fermentation Temperature Controller
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: oneleggedredcow
  • Date Created: 1 Mar 2015 5:42 AM Date Created
  • Views 2085 views
  • Likes 1 like
  • Comments 7 comments
Related
Recommended
  • rpi_intermediate
  • rpiintermediate
  • wine_making

Raspberry Pi Wine Fermentation Temperature Controller

oneleggedredcow
oneleggedredcow
1 Mar 2015

In this article, I’m going to build a simple temperature controller using the Raspberry Pi.  This will use a DS18B20 temperature sensor to determine the current temperature and then use a relay to turn on/off a heater. With this set up, I should be able to keep the temperature in a room constant over a long period of time.

 

Background

Wine needs to be fermented at a fairly high temperature (72 degrees Fahrenheit) for a fairly long time (2-3 weeks).  Since it is the middle of the winter and I like to keep my house fairly cold, the indoor temperature is not that high.  So, I’m going to hook a heater up to the Raspberry Pi and hold one room of my house at the desired temperature.

 

Temperature Measurement

Measuring the temperature of the room with a DS18B20 temperature sensor is pretty easy, and there is already a great tutorial that covers how to do this in detail.  So, if you haven’t read that, check it out.  We’ll assume that you have and followed that to get a temperature sensor up and running on the Raspberry Pi.

 

Turning On/Off an Electrical Device

The next challenge is to turn on/off an electrical device with the Raspberry Pi.  To do this, we use a relay.  Since I’m a little scared of electricity, I prefer to cut an extension cord in half and wire the relay into the center.  This makes the solution more reusable since I can plug anything into the extension cord and it helps with my nerves because it lets me plug the electrical device into an outlet like I’m used to.

 

When wiring up the relay use the circuit shown below.

image

I used GPIO port 11, but there are many others that will work.

 

Once that is wired up, you can practice turning on/off the electrical device with the following code:

 

 

This will turn on/off the relay every two seconds and print out a message to the screen stating that the device was turned on/off.  Also, my relay is a bit bizarre in that sending it False turns the relay on and sending it True turns the relay off.

 

Putting It Together

Now all that is left is to tie the two parts of the application together into one python script:

 

 

The only new addition to that file is a small feature to turn off the heater when the program is exited. Other than that, it is a pretty straight forward merge of the two previous code snippets.

 

Video

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply

Top Comments

  • peterjcs23
    peterjcs23 over 10 years ago +1
    Hi Shaun, you say... "Then wire up the relay to the Raspberry Pi. There should be three wires: +5V, ground, and a data wire. The data wire tells the relay when to turn on/off. I connected my data wire…
  • oneleggedredcow
    oneleggedredcow over 10 years ago in reply to peterjcs23 +1
    Good point. The relay that I'm using has the diode built in. However, you're right that most don't. I just updated the article with more information on how to wire up the relay. Thanks for the feedback…
  • DAB
    DAB over 10 years ago +1
    Good post, Simple, strait forward and easy to implement. I do worry about your relay handling the current of the heater though, but hopefully you made sure it was rated for the current. DAB
  • oneleggedredcow
    oneleggedredcow over 10 years ago in reply to peterjcs23

    Yeah, the code is python.  Python has recently been one of the most popular teaching languages, so there should be plenty of tutorials out there for it.  Unfortunately, I don't have a favorite book or website.

     

    Python is standard across all of the platforms.  So, the version on the Raspberry Pi is the same as what you would get in Windows.  (Like C, there are some slightly different libraries that are possible with each platform, but overall, they do a very good job making libraries cross platform as well.)

     

    When I started with Python, my biggest hang up was that whitespace (indenting) was significant.  It took me awhile to accept that.  Once I got past that, I really started liking the language.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • peterjcs23
    peterjcs23 over 10 years ago

    oneleggedredcow

     

    I'm just trying out the mention function, is that you shaun?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • peterjcs23
    peterjcs23 over 10 years ago

    Hi Shaun, I read your blog to find out a bit about Raspberry pi and ended up asking about the relay.

     

    The software is python I believe. I've used C quite a bit for embedded processors but never python. Is there a book you would recommend or a web tutorial? Is there a standard to python or is raspberry Pi a unique version. With C you get a core standard and each implementation has a set of functions.

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • oneleggedredcow
    oneleggedredcow over 10 years ago in reply to DAB

    Good idea.  Luckily, my heater is pretty whimpy, so it is within the rated current for the relay.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 10 years ago

    Good post,

     

    Simple, strait forward and easy to implement.

     

    I do worry about your relay handling the current of the heater though, but hopefully you made sure it was rated for the current.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube