In the following four-part article series, we will describe step by step how to control a swimming pool using self-made IoT modules. The cost of the required electronic components is less than 100 euros.
- Control the pool and its temperature with open source and inexpensive electronic components via a solar system
- Access via WiFi and internet
- Flexible expandability
We have a swimming pool that is cleaned using a sand filter system. This sand filter system has to filter the pool water every day for a certain time.
In addition, we have a thermal solar system, which is designed to support heating and hot water. Since this produces far too much heat in the summer, the idea was obvious to use this heat in the summer to heat the pool. This is easily possible via additional connections on the heat accumulator: a circulation pump directs the warm solar water through one Heat exchangerthat heats the pool water.
The pump for the water circulation is switched by a timer. The pump for heating is switched on manually behind the timer as required. This is of course stupid if you have integrated the solar system in the morning and the weather changes during the day: In the evening the water is cold for showering and cooking, since all the energy has flowed into the pool. That should change this year!
This situation gave rise to the desire to control the pool smartly. What is basically required for this?
- Sensors for heat storage and pool water
- Switching option for the pumps
- A control system
All of this is easy to implement with an ESP microcontroller and a Raspberry Pi. The individual solutions are also available here on the blog:
- Thermometer with OLED display (https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/thermometer-mit-oled-display?ls=de)
- Raspberry Pi with OpenHab (https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/raspberry-mit-openhab2)
- What’s going on there? 433Mhz modules (https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/was-funkt-denn-da-433mhz-module-prufen?ls=de)
The trick is in the detail of the combination. We will see that in the following articles.
The following parts and components are required for the pool controller:
- 1 * ESP32
- 2 * temperature sensors DS18B20
- 1 * 433MHz radio module
- 2 * 4.7kΩ resistors
- 2 * Radio-controlled sockets
- various plug wires
- Circuit board or Breadboard
- Power supply
For the OpenHAB server:
- 1 * Raspberry Pi as server center
Basis for the pool controller
We will start with the centerpiece, the pool controller. In order not to reinvent the wheel again and again, we decided to set up the project on a basis. We have this in the project ESPBASE found. The project offers support as a template for setting up WLAN via an access point and some other functions that we no longer have to take care of ourselves. The developer has one in his project example created for the use of ESPBASE. We will build the controller on this basis.
Smart home integration
Ultimately, the pool controller becomes open source home automation openHAB integrated and thus also offers access via apps on the smartphone.
For the integration we need a protocol for the message exchange. We use MQTT for this. MQTT is a lightweight message protocol that is used very often in the IoT (Internet of Things) area. If you want to know more details about MQTT, you can find a good one at Heise Developer Overview.
We will need an MQTT broker to communicate with the pool controller. We have the broker on the Raspberry Pi Mosquitto Installed.
Install and test the MQTT Server Mosquitto
We install the MQTT broker Mosquitto on the Raspberry Pi:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mosquitto mosquitto-clients
We open a subscriber on the topic "/ topic" who is waiting for messages:
mosquitto_sub -h localhost -v -t / topic
The topic is like a radio frequency that is being listened to. Different data such as e.g. the temperatures are sent.
We can test this directly on the Raspberry with the following command, which publishes a message in another console window:
mosquitto_pub -h localhost -t / topic -m "Hello smart pool"
There are also clients for the smartphone or the Windows PC to receive or send the MQTT messages. Such a client can be useful for testing if you don't always want to open a console on the Raspberry.
Now the first prerequisites have been created. In the following article, we will introduce the pool controller based on the ESP32, which provides its data via the MQTT broker that has been set up.
We hope you enjoyed the first part of this series of articles.
We will publish the second part of the article shortly. Just drop by in the next few days.
We look forward to your feedback and comments, and say goodbye until the next post.
Your AZ delivery team
Further to:The pool controller (2/4)