Tuesday, February 2, 2016

Improved Hot Tub Controller

Hot Tub Controller Circuit Board
The original version of my hot tub controller starting having some problems which ended up being caused by an animal chewing through the control cables. I never liked having that huge bundle of cables running all the way across the back of the house, so I now have a new controller in a waterproof enclosure mounted right next to the hot tub.

The controller is built to mount on top of a Raspberry Pi and does the following:
   ●  Monitor the water temperature
   ●  Turn a circulation pump and heater on to heat the water as needed
   ●  Respond to buttons that increase/decrease the desired temperature
   ●  Respond to buttons that turn the water jets on and off
   ●  Display the current temperature
   ●  Detect various failure modes and place system in safe mode
   ●  Listen for commands from a smart phone app to control hot tub
   ●  Upload data periodically to an Internet of Things service

Temperature monitoring is performed by a waterproof DS18B20 from Adafruit. It uses a simple 1-wire bus to read the data.

The display, also from Adafruit, is a 7-segment LED display and is controlled using an I2C bus.

The device is powered by a 24V DC power supply since the relays on the hot tub are controlled by a 24V signal. A 5V step down regulator provides power to the Raspberry Pi.

Relay Control with LED Indicator
Transistors are used to control the relays and screw terminals provide the connections for all the wires.

The push buttons are connected to GPIO inputs which drive interrupts. These require "debounce" conditioning and this is explained in this post.


Smart Phone app for Hot Tub


The Internet of Things support is using ThingSpeak and the method is described in this post. You can see the live data at this URL.


The system also listens on a network socket for incoming commands from a smart phone app that allows me to monitor and control the hot tub remotely. It's actually not an app, rather just a web page designed for a mobile screen. This way it can easily be used by my Android, my wife or son's iPhone, or from any web browser.

Here is a video showing the completed controller in action. 










And, yes, I really do keep my hot tub that hot. One advantage of making my own controller is that I am not limited to 104 degrees max.

25 comments:

  1. I uild something similar, perhaps u can use my code?

    See:
    http://www.instructables.com/id/Hottub-Pool-Controller-Web-Interface/

    ReplyDelete
    Replies
    1. Thanks, but I already have a system that works fine. Yours only controls one pump. Mine uses 3 and the heater relay must handle 220V 40A which is way more than relay board you use.
      I do like that style relay board and use it in my home automation system.

      Delete
  2. Hey Ted! Perfect timing! I am resurrecting a hot tub. just got the power in and the fuses replaced and nada. I have put together a few pi projects but never any wiring projects so this would be perfect!

    Can you post your materials list?

    I will probably need some guidance along the way so hopefully your up answering a few questions (or many...).

    thanks!

    ReplyDelete
    Replies
    1. Link to code and material list should be in a new post soon.

      Delete
    2. Clint, If your hot tub has an IQ2020 controller, the heater controller card with 3 black relay's has a known problem with burning out the relay. You might take it off and look at the back to see if there is a burned spot. My circulation pump, jets and light in the tub still worked though, as did the power light. But none of the buttons worked on main controller just the one inside the tub.

      Delete
  3. Ted, Hi. I have a similar problem with my hot tub and decided to have a go with a pi. It is many years since I did any programming or electronics, however I have managed to write a simple program in Python, to read temperatures (DS7B20) and operate relays, it's clunky but works. Is your program available for viewing or downloading. It might save me lots of time.
    Thanks
    Steve from England

    ReplyDelete
    Replies
    1. Look for a new post soon with more details of my hot tub project.

      Delete
  4. good work, I may look to mod this to do differential temperature for solar heating

    ReplyDelete
  5. Brilliant! I have an older Morgan hot tub that was given to me. I don't have an extensive electrical background, but have a Pi sitting on the shelf needing a job and I would love to be able to figure this out. The transistors, regulators, and resistors are where I'm going to get lost. Are you open to questions?

    ReplyDelete
    Replies
    1. I can always answer questions. Well, almost always. And look for a new post soon with more details of my hot tub project.

      Delete
    2. Awesome! I'm going to start ordering some parts, but will hold off on the questions til I see the new post. Thanks!

      Delete
  6. Has anyone considered using a touch screen as the GUI? If so can I have your code please?

    ReplyDelete
  7. Curious, has the parts list been posted?

    ReplyDelete
  8. Hi, this looks awesome and I'm looking at it for my first PI project. I've started with a lite raspberry pi install and worked out that I needed to install

    sudo apt-get install npm
    sudo apt-get install python-pip
    sudo pip install cherrypy
    sudo pip install twilio

    Running startup.py I get missing file errors. What is supposed to be in the following files?

    /home/pi/alerts.json
    /home/pi/filter.json
    /home/pi/users.json

    Thanks in advance

    ReplyDelete
    Replies
    1. I have no idea. I have never used any of those packages. search Google or ask on https://www.raspberrypi.org/forums/

      Delete
    2. Also, a hot tub controller is not a beginner project. The Pi programming is intermediate level but the actual wiring of the relays to control the hot tub, while straightforward, involves high voltage and high current (40 amps at 220V in my case) so it can be quite dangerous. If you do it, be sure to use relays that can handle that high a load.

      Delete
  9. Very well done. This is what I need. I've forked your GitHub and started to make some changes that will suit my requirements(Mostly single 2 speed pump verses you 2 2-speed jets and circulation pump) I was wondering if you would be able to provide the web page coding. I can get through C, PHP and HTML not so well...

    Thanks...

    ReplyDelete
  10. Hi! What is the original control panel used in the spa? Mine has a Balboa GS100 and I had the idea replacing it with my own.

    ReplyDelete
    Replies
    1. I don't know the controller model. The hot tub is a Dimension One Californian.

      Delete
    2. Any chance you can share your Web page coding? I'm having difficulties getting the communication between the C and Web page

      Delete
    3. Yes. I just haven't had time to write up a blog post explaining how it's done. Whn I p[ut the code on github, I will let you know.

      Basically, I use Apache and PHP for the web pages and communicate via TCPIP sockets. I use PHP functions to connect to a C program that is listening on a socket. That allows me to have the web server on a different system.

      Delete
    4. The code for the Hot Tub Controller was already on github
      https://github.com/tedhale/hottub

      Now I have added the web interface
      https://github.com/tedhale/hottub-web-interface

      The magic happens in "command.php"

      Delete