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.

30 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
  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
  11. Great project.
    Is there any plan for expanding it with more pumps, ozone generator and led light control?

    ReplyDelete
    Replies
    1. It would be pointless to expand it to more pumps than the hot tub already has and the ozone generator still works fine without my help. I have thought about LED lighting, but 99% of the time I prefer it to be dark.

      Delete
    2. Oki. See your piont.
      My pool have 3 pumps so i just have to figure out how to solve that.

      Delete
  12. Hi Ted. There is no need for the external controller if you just use a Web interface to control the hot tub, correct?

    ReplyDelete
  13. Controlling pool equipment with smart phone
    I bought the smart pool timer from Thermomart in the following link,
    http://www.thermomart.com/cellphone-wifi-app-google-alexa/Timer-Pool-Spa-Hot-Tub-Sauna
    The product works. It’s good quality. It is easy to download the app and I paired it in 15 minutes.
    This timer saves me $30-$50 a month and also I do everything on my cellphone or by voice (by Amazon Alexa, Google Assistant) from anywhere!
    The Timer can be programmed as scheduled (24 hours 7 days with 8 events) or loop timers if you want to use more event every day. It has a countdown timer too.
    It has a waterproof box and it is suitable for outside. I use the sharing system and now my wife can control the pool pump too.
    Would definitely recommend purchasing.

    ReplyDelete
  14. Are you powering all pumps and the heater from a single 40amp 240volt gfci circuit?

    ReplyDelete