Replacing the electronics in a hot tub
The previous post described the reasons for this projects. It also gave a brief description of the hot tub in which I will replace the electronics.
Since I can’t play with the existing electronics until late spring (todays temperature was -20…) I will start preparing my controller using logical thinking… call it guess work…
A hot tub does very few things:
- Keep the water temperature at a set value
- Start and stop pumps on demand
- Turn extra features On and Off (LED lighting, etc)
That’s what the existing circuit does. I also have to program safety features to…
- Keep the water temperature constant
- prevent too hot or too cold temperature (limits)
- stop any pumps after a set duration cycle (15 minutes?)
- Make sure the heater is never left ON if pump 1 is OFF
- Detect a blocked pump/pipe
- Not electrocute anybody…
To assemble a test rig, I will use a couple of simple Arduino micro-controllers, a multi relay board, a Raspberry Pi computer and various test sensors.
Raspberry Pi
The main computer will be a Raspberry Pi. The particular model that I use is a Raspberry Pi Model 4 B because I have many on hand. Any Raspberry Pi from Model 3 on should work.
A Raspberry Pi is cheap. It can be programmed using the Python language (my choice). It can connect to a network using Wifi. It can connect physically, using USB or direct pin connections to multiple micro-controllers (Arduino). They can connect using Bluetooth radio. Finally, they are reliable (and if they fail, are easy to replace).
Arduinos
The Raspberry Pi is OK when used as a direct sensor controller, as a relay controller, etc. But I prefer to use simple Arduino micro-controllers to manage the physical elements of the circuit. Arduino are simple and tough.
I will use one Arduino to attach temperature sensors, pressure sensors, display and LED lighting controllers. The sensor circuit does not need to be extra fast. The temperature will not change every second, the pressure either. The display does not need to present lots of information.
A second Arduino will be used to control relays and actuators and will also serve as a button (touch pad?) controller. This Arduino has to respond immediately to received commands from the main module. It also has to send immediate information to the main computer without any delay. So the programming will have to be more precise and optimized for speed.
Display
The whole setup will produce a simple Web page, showing all the needed information. This way, I can access the control circuit using a (smart) phone or a tablet, or even a computer. If I program the security features carefully, I could even access the control board from anywhere in the world.
The web interface of the test environment will use Node-red and Flask. I will decide later if I keep one or both.
There needs to be a display on the tub too. But this spa is outside, in Canada, so is exposed to harsh temperatures, especially in the winter. So I need a simple, tough display. Not much information needs to be displayed: the water temperature, the status of different pumps (on/off/problem), etc.
Controls (buttons, keypads)
The control panel needs to activate pumps, set temperature and turn on the lights, at a minimum. So a few buttons or switches need to be accessible.
All of this…
All of this has to resist temperature extremes, water, chemicals and user stupidity. Also, keep in mind that we are handling mains electrical voltage of 240 Volts that will kill you in a very brief instant. So SAFETY IS PRIMORDIAL!!!
Test rig

While developing the system, I found that the Raspberry Pi was quite slow as a programming interface. So I set up a test rig using an old PC and Linux Ubuntu. Programming using IDLE and connecting the Arduinos to USB ports is OK for now.
The next posts will detail each part, with code examples.
Leave a Reply