Expert Thermocouple & RTD &Temperature Sensor Manufacturer.

+86 13816377866    |    jimmy011@126.com

web-based pool controller w/ raspberry pi, arduino, xbee and digital thermometer

by:JVTIA     2020-10-27
This simple system allows remote control of the web-based swimming pool pump and heater or any device switched with a simple relay.
It uses Raspberry Pi as the main controller and web server.
It also uses the Arduino remote thermometer running in the pool, powered by batteries and solar panels.
Two small XBee radio units provide a data link between the pool thermometer and the master controller.
I hacked into the physical pool controller timer unit to access the relay drive circuit, low/low power Darlington transistor array that controls the high power master pump relay.
I control the heater (
Unit 2,400,000 BTU Laars Lite)
Through the \"fireman\'s switch\" control line, which allows the use of a remote cut-off switch in series with other safety fuses.
I then set the thermostat to the maximum.
This way, I can control whether the heater is on as long as the pump is on.
If you don\'t know what you\'re doing, don\'t even consider doing such a project with a pool pump circuit and heater.
You will cancel any warranty or worse service. . .
Ask professionals to install the correct remote system.
Think of this as an outline for you to do other simple and safe things.
That is, when you\'re away, it\'s a great way to control things at home through your phone or laptop.
I\'m using Raspberry Pi 2 and I\'m running the raspberry version of \"Jessie \".
It runs a web 2 web server.
By using a Wifi dongle plugged into one of the USB ports, you can connect it to your local network and control the pool pump and heater through a simple html interface.
By configuring port forwarding on your router, you can access the controller remotely via your phone.
Use ports that the ISP does not block and forward all html requests to port 80 on Raspberry Pi on the internal network.
The Raspberry Pi drives two 5 volt relays directly from two pins on the GPIO header.
These small relays have photoelectric
The isolator on the input side, so they work directly with the low power pins on the Raspberry Pi.
Temperature data (4-
Number string with decimal point)
Receive by XBee installed on the USB adapter.
The thermometer is standard-Dallas DSB-20 unit.
Although it is easy to connect it directly to the Raspberry Pi (there\'s a one-
Wire library with Raspberry Pi)
It may not work if the data line is running more than 30 feet, plus, I don\'t want anything in the pool that might be short to the power cord.
You can use a photoelectric
The isolator separates the line, but there may still be a short circuit.
I prefer the safety of the battery powered thermometer in the pool.
I send data to Raspberry Pi using two small XBee radio units. A low-
Power Arduino gets data from DSB-
20 thermometer and input it into XBee transmitter.
There\'s an Arduino library-wire DSB-20.
The waterproof version of the Dallas thermometer is easy to find and all parts of this project are easy to find.
It should be noted that this is a digital device that sends a data stream through a single line.
Actually, it uses three wires. -
One for data and one for power (3 to 5. 5V)
One on the ground.
The data cable needs a 4. 7k ohm pull-
The up resistor is connected to the positive power cord.
With a USB connector, the Raspberry Pi can be connected to the display via an HDMI connector along with a mouse and keyboard.
Before setting up the Wifi, you can use the Ethernet connection to the router.
This is very important for setting up Raspberry Pi and getting updates and any software that may not be available with the initial operating system on the microcomputerSD card. (
Once configured, the device becomes \"headless \"---
No monitor. )
At this point, I assume that you have started your Raspberry Pi with the downloaded operating system (
In my case, raspberry for Raspberry Pi 2).
If you have Raspberry Pi 2, connect the Raspberry PI to the USB Wifi dongle now. (
Raspberry pie 3 built-in-in Wifi. )
Make sure you are using a later \"Jessie\" version of the OS for Raspberry Pi 2.
It\'s much better to maintain a stable Wifi connection than the earlier \"breather\" version.
Also, you may want to give it a static IP address and the router will not change it every week.
There is a good tutorial here.
After running the Wifi, you can remotely access the Pi-using SSH and commands-line interface.
There is a good tutorial here.
Now you need to run the web server on the Raspberry Pi.
This includes a group called LAMP (
Linux, Apache, MySQL, PHP)
This is easy to do.
This is a tutorial.
I use some very basic html pages to connect with simple Python and shell scripts that check the temperature and determine if the pool heater and/or pool pump should be on.
The pool thermometer uses an \"quasi-system\" Arduino made of an ATmega328P chip.
Make sure you buy a chip that has burned out the boot loader-
They sell $2 on eBay.
You can then upload the Arduino program by putting the chip into the normal Arduino Uno board and then carefully removing it, but if you just get the FTDI cable (
Sparkfun of Adafruit)
On your breadboard, you can avoid bending the chip pins.
The quasi-system Arduino has lower power consumption than the normal Arduino because it skips the on-board voltage regulator.
I use my own low
Loss voltage regulator chip, LT1529 3.
It won\'t run out of battery as quickly as it used.
Here is a tutorial.
The battery is standard 3.
7v LiPo unit with solar panel.
You can\'t simply charge these batteries by connecting solar panels-
They need a dynamic 4-
Step charging protocol.
I use the 6 V panel (
5 V not working)
The charging unit of Adafruit has a good large electrolytic buffer capacitor on the output side.
The output is arranged in the order of 3. 7-
4 V, so ensure LT1529 3.
The 3v regulator always has a higher input voltage and I use a simple step down/boost unit to jump it to 5 v.
Here is the screenshot.
It\'s simple, but it works. A few notes:--
Execute command from/usr/lib/cgi when running Apache2 web server-bin.
By default, your Apache service may point to this folder when the site address calls www. yourserver/cgi-bin/command.
But if not, you have to include a line in your Apache profile like ScriptAlias \"/cgi-
Bin/\"\"/usr/lib/cgi-
Bin/\"Also, make sure that the Apache web server has permission to execute commands from this folder with the option to execute cgi: option. . .
Details can be found here. --
Raspberry Pi uses built-in
By default, communicate with the keyboard in the serial interface.
In order to use this serial interface in XBee, you have to tell it to stop communicating with the keyboard.
There are many sometimes conflicting instructions on how to do this on the web, and they vary depending on the Raspberry Pi version you have.
On my \"Jessie\" version of Raspberry Pi 2 running the Raspbian operating system, there are two steps :(
This will only be done after a reliable SSH connection is established with Raspberry Pi :)1.
I put these lines in/etc/rc. local (
This is the script that always runs after startup)
: Systemctl ModemManager is disabled.
Service System stop serialgetty@AMA0.
Disable serial service systemgetty@AMA0.
Service System shield serialgetty@AMA0. service(
Insert the above line before the last line of the rc.
Local File, \"Exit 0 \")2.
Edit/boot/draft line. txt (
Make sure to copy the original to/boot/draft line. txt_backup )
And remove all elements related to the keyboard serial connection--
Ttyam0 on Raspberry Pi 2 is with Jessie, or ttyS0 on Raspberry Pi 3)thus \"dwc_otg.
Lpm_enable = 0 console = ttyAMA0, 115200 console = tt1 root =/dev/mmcblk0p2 root fstype = ext4 elevator = deadline roo
Lpm_enable = 0 console = tt1 root =/dev/mmcblk0p2 root fstype = ext4 elevator = deadline fsck.
Maintenance = yes rootwait \"retail price index month Jesse. --
Raspberry wall-
The power supply is often under-powered and noisy. (
In the old Raspberry Pi 1, the device restarts if you simply plug in the USB Wifi dongle. )
Here, I use a larger 6 v power supply connected to the 117 v AC waterproof socket of the pool pump, as well as an adjustable voltage controller set to 5 v, there is a large 1000 uF capacitor Raspberry Pi and relay on the output.
Even with a 3/4 HP pool motor nearby, I haven\'t had any stability issues. --
I use the radio equipment of the XBee Series 2.
These are completely different from series 1.
The unit on the Raspberry Pi is set to the coordinator and the unit on the pool thermometer is set to the router.
Router as a simple pipe through digital flow (
ASCII string of temperatureg. 78. 36)
In the absence of any other data, go to the receiver Xbee of the Raspberry Pi (no frames).
This keeps it simple and works.
A very good set of Xbee-
The Arduino tutorial can be found here. --
The Raspberry Pi has two Python daemon running, one is to check the pool temperature on a regular basis, and the other is to regularly decide which relays should be turned on or off based on the thermostat settings and the current pool temperature.
Call other scripts according to the web command to report the pool status, change the thermostat settings, or enable the heater to turn on or off.
Other scripts run regularly as cronjobs and restart the daemon if it terminates in some way. --
I also reserved two Raspberry Pi GPIO pins for the button to allow the controlled software of the Pi to turn off.
Keep in mind that if you simply unplug the plug while the plug is running, you may damage important files.
The script that checks if the button is pressed starts in/etc/rc.
An example can be found here.
Here are some software files.
They are searched and hacked from sources you may see in Arduino and elsewhere on the Raspberry Pi site.
They are not clean and not beautiful, but I am not a professional programmer and you have other more pressing work to do if you are like me.
Nevertheless, these may help if you are not a professional.
Stroll around with it.
It\'s simple, but it works for me.
Arduino sketch get temperature from DSB20: TempRemoteSend-Sleep2. inoPOOLREPORT. py, heatON. py, heatOFF.
Py and tempInText.
Py belongs to cgi-bin. (Raspberry Pi)tempInText. html, heatON.
Html and off.
Html belongs to/var/www/html or any html directory of your website.
Shell script (. sh)belong in cron.
Please. txt suffixes!
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...