Open Source Hot Tub Controller

About: We make IoT open source. Connected products have a huge impact in our daily life: In a few months IoT generates much more data than social media. Furthermore, there are millions of products out there, which ...

I found a used hot tub online, that's a couple of years old and I decided I can make a cool project out of it. The built-in controls were already annoying and time-consuming, so that gave me further reason to tinker with it. In order to save energy, I lower the pool temperature when not used, but if I wanted to use the hot tub, I had to turn the temperature up 4 hours in advance. As an example of what I mean by saying annoying: In order to save energy, I had to lower the pool temperature when not used, but if I wanted to use the hot tub, I had to turn the temperature up 4 hours in advance. Another thing that happened was that somehow the circulation pump decided to turn on randomly during the night - that would probably have gotten under control if I had read the manual, but as a tinker I prefer to tear out the controls and use a Raspberry Pi instead - so here's my article "Open source hot tub controller."

Step 1: Safety Warning

If you also plan to tinker with your hot tub you should be aware of the risks. While high voltage systems are interesting experimentally, they can be dangerous, and if not treated with care, respect and intelligence, they can result in fatal injuring. There are a bunch of guides online on how to work safely with high voltage. If you are not certain on what you are doing, stop now and go educate yourself.

Step 2: Components

In this project I'm using an UniPi 1.1, but it doesn't have to be one, you could also use the Raspberry GPIOs with a relay board, the UniPi comes in handy to have a 1-Wire connection as well. The terminals, mounting rails and cable canals I use are not necessary but makes the cabinet look clean, one can simplify that by wiring it directly. The UniPi needs a 5V power supply, I use a DIN rail mounted one with 3A output current.

Step 3: Tidy Up the Cabinet

I am not reusing any of the built-in controller electronics, therefore I am removing them all. My hot tub has the following wires:

  1. Circulation Pump
  2. Jets Pump
  3. Blower
  4. Heater
  5. Ozonator
  6. Temperature sensor
  7. Flow sensor
  8. Supply
  9. 2x Display cable

The clamps on the PCB are labelled. It's a good idea to mark the cables so you would know the purpose of each cable later on. To make the wiring easier, I took the whole cabinet out. Then I removed all the components, cleaned the ole thing and started with the installation.

Step 4: Installation and Wiring

I am not reusing the original display. It could probably be integrated somehow, but since it only shows the temperature, it's not worth the effort. I also thought about installing a touch display, but they kinda do not work if your fingers are all wet.

The built-in temperature sensor is a temperature-dependent resistor (PT100). Although the UniPi has an analog input with which I could measure the resistance, I thought I'd make my life easier by using a 1-Wire temperature sensor instead.

First, I installed the cable ducts, left, right, on the top and in the middle of the cabinet.

Next I installed two DIN rails, one in the middle between the cable ducts, and one 75 mm below the middle cable duct. I use self-tapping screws to mount all of the components.

On the lower DIN rail I mounted the terminals, the relays, and the 5V power supply. As clamps I used rail mounted terminals with tension springs. On the left are the terminals for the supply line
- 3x Gray for the 3 phases
- 1x Blue for the neutral
- 1x Yellow / Green for the ground.

Then for every other cable I added a gray, a blue and a yellow/green clamp. Some of the cables in the hot tub are somewhat thick. I am in Europe and there we have different standards on cable thickness than the US. The terminals have to be able to accommodate 6mm^2 for all connections.

To the right of the clamps are the relays. The UniPi internal relays can only switch 5A, so they cannot be used to switch the load directly. I used power relays with 230V AC control voltage and now the installation is able to handle power of up to 4kVA.

On the left end side of the upper DIN rail, I mounted 2 potential distributors, one for GND and one for 12V+. The 12V+ is provided by the UniPi. Next to it, I placed the UniPi 1.1, with a mounting plate for DIN rails.

I got lucky with the size of the cabinet, everything fits just right. Now the fun starts - let's do the wiring. The wire colors are not standard. I use the colors in the following way:

  • Black: 230V Power
  • Red: 230V Switched
  • Blue: Neutral Conductor
  • Dark Blue: 5V or 12V+
  • Dark Blue/White: 5/12V GND
  • Green/Yellow: Earth/Ground

I use ferrules for every wire end, they are not necessary for this kind of clamp, but it makes it look pretty. I have 3 phases available, the main fuse is 16A Typ C. The heater has 10A, the pumps will have around 6A each. So I distribute the load to all 3 phases. I use the first one to power the control unit, the ozone and the blower, the second phase for the heater and the third one for the 2 pumps.

The magnetic and flow sensors are digital, so I connected 1 end to the 12V and the other to one of the digital inputs.To improve the WiFi connection, I do no longer use the original metal lid, but replace it with a acrylic one.

The cover of the hot tub has secure clips attached, so the wind would not accidentally open it. I, of course, forget to close those clips, so I installed a magnetic switch that notifies me when the cover opens. So far so good, it's time to prepare the brains of the operation.

Step 5: Operating System

I used nymea to control the UniPi and BerryLan for the WiFi setup. There is a Raspberry Pi image that supports UniPi and includes both components available here: https://downloads.nymea.io/images/rpi3/nymea-debi...

I flashed the SD Card using Etcher.io, inserted it in the UniPi and I powered the hot tub on. I needed to do some small changes on the operating system, so I had to connect the UniPi to my WiFi network. Here's what I did:

$ ssh nymea@YOUR-IP-ADDRESS-GIVEN-BY-BERRYLAN <br>#password is nymea 
$ sudo su
$ apt-get update
$ apt-get install unzip nymea-plugin-unipi
$ wget https://github.com/UniPiTechnology/evok/archive/v...
$ unzip v.2.0.7c.zip
$ cd evok-v.2.0.7c
$ bash install-evok.sh
$ >     Website Port to use: >1040
$ >     API Port to use: >8080
$ >     Your model: >3
$ >     (Install WiFi?) [y/n] n
$ sudo reboot now <br>

The default modus for BerryLan is "offline", so the BT server starts when the Raspberry Pi is not connected to any network.

BTW.: With BerryLan someone could set the Raspberry also in the access point mode, so the client could connect directly to the hot tub without a router. Alright, now the OS is good to go, and we can continue with the final steps.

Step 6: Setup

I am using the desktop app for nymea:app. You can also install it for Android & iOS devices, and control your UniPi just the same.

AddDevice

I added the relay outputs, nymea discovers how many IOs are available:Add Device -> UniPi -> Relay Output -> Select relay one and named it "Heater" I repeated those steps for all the relays and I set up the controls as follows:

Go to Add Device -> UniPi -> Relay Output -> Select `"Relay 1"` and name it “Heater”

  • Relay 2: Jets Pump
  • Relay 3: Circulation Pump
  • Relay 4: Blower
  • Relay 5: Ozonator

Then I added the inputs:Add Device -> UniPi -> Digital Input -> Select "Input 1" and name it "Flow Sensor"I repeated those steps for all the inputs I have:

  • Input 1: Flow Sensor
  • Input 2: Cover Sensor

The 1-Wire temperature sensor:
Add Device -> UniPi -> Temperature Sensor -> Name to Temperature

Last, but not least, I added 2 Toggle Buttons. They are not really devices, but more close to "states". This helps me to use them later on in my "Favorites" list, so that I can quickly toggle everything on or off.
Add Device -> guh GmbH -> Toggle Switch -> Name: Summer Mode

The "Summer Mode" is to deactivate the heater completely during the summer months.Add Device -> guh GmbH -> Toggle Switch -> Name: Ready Mode The "Ready Mode" is to switch the target temperature between 37°C (ready) and 29°C (not ready).

Add some Magic

Magic is basically a ruleset which commands nymea to do stuff automatically. If "Ready Mode" is on and "Summer Mode" off and temperature is below 37°C the heater and circulation pump will get activated, else they will get deactivated.If "Ready Mode" is off and "Summer Mode" is off and temperature is below 29°C the heater and circulation pump will get activated, else they will get deactivated.If circulation pump is on and flow sensor is not on then send an alert.If water temperature drops below 3°C then send an alert.If water temperature reaches 37°C send notification "Hot tub ready"If magnetic sensor is off then send notification "Hot tub cover is open".Between 9:00 and 10:00 turn on the jets pump.Setup Remote Connection I don't use the hot tub every day, so I didn't set a "Heat Up" rule. Sometimes, when I come home from work, I just want to jump in as soon as possible, so I use the remote connection to turn the heater on in advance. My hot tub heats up in the speed of about 2 degrees per hour. I usually keep the temperature at 29° in idle mode, so I have to turn the heater on 4 hours in advance. PS.: Some people think that heating the tub up needs more energy, than keeping the temperature ready at all times, but I've checked, and this is not the case on my side. The remote connection setup enables push notifications too, so you can get cool notifications.

Now I can turn on/off each pump, set the hot tub mode "Ready" or "Summer", check the temperature and switch the blower.

That's it, the hot tub is ready - I love to switch the pool on right from the comfort of my couch, or on my way back from work. For those lazy Sunday mornings, I set specific timers, so I can enjoy a dip before breakfast. My next project will be removing the built-in LEDs and replace them with WS2812 LEDs. Hope you liked my article and I would love to hear your opinion on the project.

Share

    Recommendations

    • Faux-Real Contest

      Faux-Real Contest
    • Build a Tool Contest

      Build a Tool Contest
    • Paper Contest

      Paper Contest

    Discussions

    0
    None
    serimi89

    Question 21 days ago on Step 6

    Hey!
    I stumbled upon this while researching for my DIY hot tub controller. I played around with nymea and tried some things, seems pretty straight forward with regards to GPIO control, i can easily control my relay, etc.
    Since i planned to do this without the UniPi (great device, but i didn't find it earlier and already purchased everything i need) i have a question:

    I have a DS18B20 temperature sensor from adafruit and i was wondering if there is any way to include it into nymea? It is a value read through the GPIOs so in theory it must be possible, its just a matter of building an interface, right?

    Thanks!
    Seb