Hot Tub / Pool Controller Web Interface




The ulimate webbased hottub / pool controller.

Step 1: Step 1: Intro

About 2 years ago i bought myself a raspberry pi and just playing around with it.. After a while i decided to make something useful instead of playing around with it.. So i decided to make a hottub controller with it. I'am running the controller over a year now and decided to share it with you :)

For all the functions see:

So in this tutorial we will see how to make a hottob / pool controller.

The controller is written in PHP with GPIO control

The following packages should be installed.
- Apache 2
- PHP5
- MySQL Database
- PhpMyAdmin
- GPIO Control

In case you don't want to install everything. You can download and install my Image / OS.
You can download my raspbian image HERE
--> Automatic Control does not work in the ready to use image. Please download files in the link below. Working on a new ready to use image.

Version 1.1 is available -> installed on raspbian jessie lite and updated a few bugs.
Download the image 1.1 HERE

Needed Hardware:
- Raspberry PI
- SD card ( 8 GB )
- 5V 4 Channel Relay Module ( or 8 channel is you wish )
- DS18B20 Temperature Sensors - Waterproof.
- Jumper Wires.

Step 2: STEP 2: Hardware Setup

Connect the DS18B20 sensors
Red Wire --> To 3.3v
Black Wire--> GND
Grew Wire (Data) --> GPIO pin 4
Also see Attachment

Contact the relai block as follow:
5v to 5v

See Attachment PDF for the right pin no. (or board overview, blue circles)

Pin 1 (relay) to WiringPi Pin 8
Pin 2 (relay) to WiringPi Pin 9
Pin 3 (relay) to WiringPi Pin 2
Pin 4 (relay) to WiringPi Pin 3

Be Aware ! The relay can switch a maximum of 10A

Step 3: Steps 3: Installing OS

First we will install a new fresh image of raspian.

I installed RASPBIAN JESSIE LITE, because we don't need all other stuff like desktop environment. But all other Raspian versions should be fine as well.

Flash your selected image with Win32DiskManager to the SD Card

Step 4: STEP 4: Install Packages

Download the program "putty" and "advanced port scanner" (both free software).

Scan with "advanced port scanner" and find your raspberry pi IP adress.

Go to Putty insert the IP of the raspberry and login with user "Pi" and password "raspberry".

First we need to expend filesysteem

sudo raspi-config 

Select expend file system en finish installation. The raspberry will restart now.

Wait a minute and connect again with putty to the raspberry and login.

Second we will update the PI

  sudo apt-get update 


 sudo apt-get upgrade 

Type "Y" to update (and upgrade the pi as necessary)

Install Apache2 with the following command:

sudo apt-get install apache2 

Install PHP5

sudo apt-get install php5 libapache2-mod-php5 -y 

Install MySQL

 sudo apt-get install mysql-server 

During installing mysql-server will ask for a password. This is to connect to the mysql server.. choose a password anything you like.. But don't forget this password. Write it down somewhere!! ( i choose "raspberry" )

Install PhpMyAdmin

sudo apt-get install phpmyadmin

Configure Apache to work with PhpMyAdmin

sudo nano /etc/apache2/apache2.conf 

Add the following line at the end of apache2.conf:
Include /etc/phpmyadmin/apache.conf
Control + X to save, type "Y" to overwrite.
Also See:

Install GPIO

sudo apt-get install git-core 
git clone git://

cd wiringPi


To get the DS18B20 sensors working use the follow commands:


 sudo nano /boot/config.txt

Add the following line


Control + X to save, type "Y" to overwrite.

sudo nano /etc/modules 

Add these 2 lines at the and:

Control + X to save, type "Y" to overwrite.

run the gpio command to check the installation:

gpio -v 

gpio readall

Yeah finally all packages installed :)

Step 5: Step 5: Setting Up Scripts...

Before we can upload the files to the raspberry we need to change a few settings

Add the pi user to the group
type: sudo gpasswd -a pi www-data
Change the group for the directory and allow the pi user to update the directory
type: sudo chown www-data:www-data /var/www
type: sudo chmod 775 /var/www

I've you have downloaded debian jessie you need to change the root directory of apache.
type: sudo nano /etc/apache2/sites-available/000-default.conf
Change /var/www/html to /var/www CTRL + X to save "Y" to overwrite.

To have access to control GPIO pins with a webpage.

Type: sudo visudo
Add this line to the end of the file:

Press CTRL + X to save and exit.

Download all the files from here

Download the program Filezilla Client (or other FTP program )
Connect to you're raspberry pi with following details:
SFTP://IpOfYourPi ( port 22 )
User: pi
Password: raspberry

Upload the files to /var/www ( - Just type /var/www in the right screen. )

In case you have another mysql password then "raspberry" you need to change to php configuration of the controller:
Edit the config.php file.
Change mysql_pass to the right password you have set during mysql-server installation.

Next step is to import the SQL file in the database.

Go to http://IP-Raspberry/phpmyadmin
Login with root and you're password (raspberry default)
Add a database with the name "controller"

Click on controller in the left area of the page and then click Import.
Select controller.sql from all controller files and upload by pressing start.

Setting up Cronjobs
type: crontab -e
Add this text to the end of the file.

* * * * * wget -q -O - "" 1,11,21,31,41,51 * * * * wget -q -O - ""

CTRL + X to save. Done !

Step 6: Step 6: Controller Page

Go to: http://raspberryIP

Welcome to the login screen :)..

Login with username: admin password: 123456

There is also a tablet page. special writtin for my tablet :).
See http://raspberryIP/tablet

4 People Made This Project!


  • Arduino Contest 2019

    Arduino Contest 2019
  • Fandom Contest

    Fandom Contest
  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest

82 Discussions


9 months ago on Introduction

Thanks for the inspiration and code and instructions for this very useful project. I got a raspberry pi kit from work as an award, and this is the perfect application for it. I have a 90s vintage Z101 2-person Jacuzzi, on a 20 A 120V circuit, and the mechanical electrical components of the control box had gone really flaky.

The controller is now functional, using the Raspberry Pi, a 4 relay board mentioned in the project (burned out 2 of the relays so far, because they can't handle the pump and heater, even though they each draw less than 10 amps) They worked fine for a while, then the pump one shorted closed and the heater one opened up. I moved to the other two good relays on the board, and from them drove one relay I salvaged from the old controller and one new one I bought.

I had to install php7 because php5 seems to be no longer available. That meant I had to upgrade all the code from mysql_ to mysqli_ calls.

I used the OS that came with the kit, which has the graphical GUI. At first I had a monitor, keyboard and mouse out by the hot tub for the needed tweaking, but then I got the VNC server working, so I can connect from my PC in the house and edit the Pi's software, reboot, etc.

I found that the timed events provided by this design were overridden by the heater control. To solve this, I hardcoded timing into cron_min.php, having the heating start at noon and shut off at 2:00 AM.

Next step is to get the jets working. To do this I have to energize the high current pump winding, and simultaneously turn off the heater and low pump winding. I have a push button switch and high current dual-pole contactor on order from Amazon.

Thanks again!

7 replies

Reply 5 weeks ago

oh and @cdnlong.. I want to update the php as well on my setup. What steps did you use? I'm having issues after updating the sqli_ and then doing a a2dismod /a2enmod.


Reply 5 weeks ago

hey for anyone reading this.. I put way too much time into this too. My version of this project is called Oasis-Spa and can be found here:

There are some issues atm, and I've run into a place where i'm stuck. Maybe we can collaborate? I've done a bunch of documentation work and added new features, such as translating GPIO on/off events into MQTT. This enables us to use IoT switches to control relays and read IoT MQTT published temperatures.


Reply 9 months ago

Oh, and as a safely measure, I plan to add an over-temp sensor, which would turn the heat off at maybe 120F. (in case the main sensor failed) But what if the software or the Pi fails and leaves the heat on? Anyone think about that? Also, anyone worry about water damage in case of a leak?


Reply 9 months ago


Do you think you can post the php7 version of your code?

Mayby we can create a Github for this project and post the code updates there?


Reply 9 months ago


If you are still reading this, is it OK for me to put my modified version of your code on github? I would give you full credit.



Reply 9 months ago

Sounds like a good idea. I will put that on my list. And I do need to back up the code for my own purposes.


11 months ago

Hi, I'm trying to use your project as a basis for my own hot tub project. I bought one of those inflatable hot tubs but it was having issues with it's controller so I'm trying to build a controller with the Pi.

I'm working through your steps but I can't seem to get the files to copy over to /var/www as it says I don't have write permissions so I'm trying to figure that.

I'm going to have to add/modify some things though, the pump unit for the inflatable tub already has several sensors in it and the temp sensors are analog, so I have an ADS1115 ADC which I will have to get working with your code. Also there are 2 flow sensors that are just magnetic reed switches but I'd like to implement those as a fail safe for the heater as well.

So I'm just curious if you have any advice on adding the ADC stuff and what not? There are 2 temp sensors on the unit, an intake water temp and an out water temp.

1 reply

Question 1 year ago on Step 1

I am trying to run off the image you have to download now(ver 1.1). It is asking for a domoticz login. What should that be? I tried to use admin and Pi as the logins but when I try to type in the password nothing can be writen.

5 answers

Answer 1 year ago

Username: admin
Password: 123456

Please let me know if this works.


Reply 6 weeks ago

Hi Rickie!
I got the same Problem with your image.
It ask me for the domoticz login.

I Tryed







Nothing of that works.
Can you try to help out please?


Answer 1 year ago

That did not work. I can input the username but the password doesn't display when I try to type that in.


4 months ago

Been using this for months now and its amazing! Thanks so much. I've been trying to get the API to work with I have multiple temp sensors connected (out door temp, Hot Tub Temp, Pool Temp ect.. I want to create a dashboard on Freeboard I have the web app up and live through dataplicity. Via http requests I can access the API data as shown in the API examples you provided but I don't think I understand JSON strings and parameters well enough. I can't get freeboard to parse the response. If anyone smarter than me has an interest in using freeboard I love to hear how you did it.



Question 7 months ago on Introduction

Hi Rickie,
First and foremost, I would like to congratulate you and thank you for the quality of your application that I've easily implemented thanks to the image you provided.

However, I have a problem: when the temperature control is done correctly, if what the pump
remains in operation once the temperature is reached and the heating cuts off.

Looking at the code, I saw that this was due to the fact that in "cron_min" off the pump is conditioned by "pump_control" which must not be equal to 1. Can you tell me when and where "pump_control" is it changed and what must I do so that the pump stops when the temperature is reached.

In addition, I missed what is the part 'Automatic Temperature Control' of the menu 'Configuration/Controller' that seems to duplicate the part 'Heater Control' of the same menu (I enclose you copy my setup screen).

Finally, be lenient on my English because I'm French.



9 months ago


If you are still reading this, is it OK for me to put my modified version of your code on github? I would give you full credit.


1 reply

Reply 8 months ago

Hi cdnlong,

Did you get a chance to put the code on github?