My instructions page for setting on the NodeJS Pool Controller to just control a Hayward Aquarite SWG.
Most of the examples I've seen are for complicated pool systems (by my standards), so here is how I setup a simple system.
My pool equipment is a Hayward Variable Speed Pump, Pentair cartridge filter, Raypack heater (old, doesn't work now) and recently added SWG. Spa is a completely separate system, so no attached spa, no fancy lights, nothing else.
No automation either, so no fancy pool controls. Low budget, but does everything I need.
VSP is controlled with relays and my smart home system.
I might add a temp sensor and pump control to Node JS PC at some point, but since I have the working already it would not add anything for me.
Almost everything I do is remote, in terminal SSH mode. Terminal mode is really easy for things like this because you can just copy and paste from this page into your terminal screen and run the commands.
Raspberry Pi3b. The pi 3 is fine for this application, enough horsepower and it won't get as hot as a pi4 if you leave it outside like I'm doing.
MAX3485 Module TTL To RS485 Module MCU Development Accessories To Serial UADSUS from ebay
+5VDC Power supply, 1 amp minimum should be enough
Used a LM2596HV AC/DC to DC Buck Step Down Adjustable Converter 3.3V 5V 6V 9V 12V 24V from ebay
AC transformer intended for sprinkler systems to power this power converter like an Orbit Sprinkler System Power Source Transformer 57040,Black. Puts out 24VAC at 750ma, plenty of power.
Power supply for Aquarite "7 V and 12 V and is pulling .001 amps so any small DC adapter will work"
Used a 12V, 1A walwart type supply because I had it, and it fits.
Wires to connect
Enclosure (Had one already by the pool)
Using pins on left from picture above.
TXD on converter to Pi RXD0 pin 10 (GPIO 15)
RXD on converter to Pi TXD0 pin 8 (GPIO 14)
VCC to 3.3V Pi pin 1
Gnd to gnd Pi pin 6
Aquarite grn to RS-485 GND (green wire)
Aquarite yel to RS-485 D-/B (orange wire)
Aquarite blk to RS-485 D+/A (orange striped wire)
Aquarite red to 7-12V power supply, positive lead. (green striped wire)
Negative lead of PS has to connect to gnd.
In the end, these grounds are all connected together:
aquarite gnd
485 converter gnd
Pi gnd
Used a CAT6 cable to connect aquarite to 485 converter.
Used a power adapter like one in picture below.
Sprinkler transformer connected to AC input on left.
Pi power connects to output on right. Output right was gnd, left was positive.
Connect to AC power with nothing connected, then adjust voltage to little over 5V, mine was about 5.03. After I connected the Pi and two ESP's, it was at 5.0VDC.
Picture of the entire box. Has a Pi, two ESPs and a relay board for controlling my VSP. Power supply board in upper left, above sprinkler transformer. 12V walwart is under that transformer.
NOTE: I know it looks ugly, but there is NO high voltage wire inside. Only 115VAC is in the left bottom corner, in its own compartment. It goes to an AC outlet behind the transformers.
So all the wiring you see is low voltage, most of it is 5VDC or less.
https://github.com/tagyoureit/nodejs-poolController/issues/401
"Tested today and it seems to work anywhere between 7 V and 12 V and is pulling .001 amps so any small DC adapter will work. Sticking with the 10V should be the best option as that is what the label on the chlorinator states."
http://cocoontech.com/forums/topic/13548-intelliflow-pump-rs485-protocol/page-10
AquaRite is 9600 baud,
Created a 16 gb uSD card with 64 bit bullseye lite image. I use balenetcher to make uSD cards for pi's.
If you use the lite image, you don't get the nice Pi user interface, but I don't care because I only use remote access for my Pis. It should all work with the full image too.
I inserted uSD card into a pi3, and did initial setup with terminal and keyboard.
Enabled SSH with command
sudo raspi-config
Select interface options, the SSH. Enable it.
Enable serial port
Select Interface Options -> Serial -> ... and disable login shell and enable serial port hardware
You can also select Localization Options, then Timezone and find your timezone so Pi will be in the right time.
After this, all commands are using a remote terminal program, and SSH interface. I use Terminal, New Remote Connection on my macbook. There are many terminal programs for a PC.
Make sure pi OS is up to date
sudo apt-update
sudo apt-upgrade
sudo reboot
Install Node Version Manager (NVM) and node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
close and reopen terminal,
then
nvm install 12.18.3
Install git
sudo apt update
sudo apt install git
Checking node.js version
node -v
v12.18.3
Install Relay Equipment Manager (REM).
Note that I'm not using REM now, but might in the future.
git clone https://github.com/rstrouse/relayEquipmentManager.git
cd ~/relayEquipmentManager
npm i
npm start
Install pool controller
git clone https://github.com/tagyoureit/nodejs-poolController.git
Start pool controller
cd ~/nodejs-poolController
npm i
npm start
Start another terminal
Install and start dash panel
git clone https://github.com/rstrouse/nodejs-poolController-dashPanel.git
cd ~/nodejs-poolController-dashPanel
npm i
npm start
Now install pm2.
^C in pool controller terminal to stop it
cd /
https://github.com/tagyoureit/nodejs-poolController/wiki/Automatically-start-at-boot---PM2-&-Systemd
npm install -g pm2
Used the nano editor to create a file.
sudo nano ecosystem.config.js
Insert following into this file. Then control x to save and exit
This only starts dashPanel and njsPC.
module.exports = {
apps : [
{
"name": "dashPanel",
"script": "npm",
"args": [
"start"
],
"cwd": "/home/pi/nodejs-poolController-dashPanel",
"restart_delay": 10000,
"watch": [
"pages",
"scripts",
"server",
"package.json"
],
"watch_delay": 5000,
"kill_timeout": 15000
},
{
"name": "njsPC",
"script": "npm",
"args": [
"start"
],
"cwd": "/home/pi/nodejs-poolController",
"restart_delay": 10000,
"watch": [
"config",
"controller",
"logger",
"web",
"package.json"
],
"watch_delay": 5000,
"kill_timeout": 15000
}
]
};
Run the flie now, and then save what it did.
pm2 start ecosystem.config.js
pm2 save
Check if running ok
pm2 ls
Make it startup if pi resets. Very easy to do, you don't need to use the systemd information in the link page
pm2 startup
pi@raspberrypi:~ $ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/pi/.nvm/versions/node/v12.18.3/bin /home/pi/.nvm/versions/node/v12.18.3/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
Copy the command, and just run it.
sudo env PATH=$PATH:/home/pi/.nvm/versions/node/v12.18.3/bin /home/pi/.nvm/versions/node/v12.18.3/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
Check if loaded
sudo systemctl status pm2-pi
● pm2-pi.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-pi.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: https://pm2.keymetrics.io/
Now if the pi reboots, it will come up running njsPC and dashPanel
Find ip address, and set to a static ip address so it won't change
In a browser, open
http://192.168.xxx.xxx:5150/ where xxx.xxx is the rest of the ip address for the pi.
You can type ifconfig on terminal in the pi to get its ip address. If you are using wifi connection, find wlan0 section. In this section the 2nd line starts with "inet". IP Address is after that.
Set server address to 192.168.xxx.xxx and click apply
Nixie Single Body window should appear
Click on gear symbol in upper right corner
Click Controller, Model if you want to change from Nixie Single Body. I left if alone.
Click on Controller, RS485 Port
Click Add RS485 Port
Port pulldown to /dev/ttyS0. This is if using the GPIO pins as shown above for connecting.
Baud rate is 9600 for Hayward Aquarite.
Select Enabled if connected, otherwise wait to enable.
Save Port
After its been running for a while, I have these stats:
Select Chemistry
Select + Add Controller
Chlorinator then Nixie, then click on Chlorinator box
Model: select Aquarite T15 (or what you have) as
Port: select Aux1
Change other settings as you would like, then Save
Press house shaped icon in top right to go back to normal menu.
Click on the large circle under "Pool". Will start things, including the SWG.
You can click on IntelliChlor01 to change setpoint.
Go back to Settings menu to change anything else
That's it.
Can now control my SWG setting from a browser.
Adding njsPC to HA
Click gear icon in upper right, then Controller and Interfaces
Select Home Assistant then enter address of MQTT broker, with type MQTT and enable and save
I also enabled MQTT, but not sure it it was required.
In HA, I used HACS, then Integrations, then search for "njspc-ha". Click three dots in upper right, and install as a custom repository.
Need to provide the repository web address, think I used
https://github.com/Crewski/njsPC-HA
After its installed, reset HA
Go to Settings, Devices and Services, Integrations. Click Add Integrations in bottom right corner
Search for njspc-ha and add it. Then you will see what entities are available to use with HA.
If using REM
pm2 stop njsPC
cd ~/nodejs-poolController
sudo nano config.json
Set enabled to true for REM
"rem": {
"name": "Relay Equipment Manager",
"type": "rem",
"enabled": true,
"options": {
"protocol": "http://",
"host": "raspberrypi",
"port": 8080,
"headers": {
"content-type": "application/json"
pm2 start njsPC