Open Kranzy opened 5 years ago
@art0 I recently replaced the pH sensor, not sure it's a true Zodiac one or an OEM. I think they seem to follow 100mv/pH curve with a bias 0V at ph 7.0 .
But I am not gonna split the signal since it's all connected to a sensitive opamp. Messing around might also cause the Zodiac to malfunction on the pH part.
You do use the Zodiac for pH adjustment to I guess?
@art. Raspberry PI will need a ADC circuit to read voltage, It's a pain, but it can be done. Arduino or ESPxxxx would be better choice for this since they have ADC built in. As DoutchForce75 said, you'll need to be careful not to change the signal that's sent to the Zri.
Many projects out there are using a small daughter board between the ORP sensor and the Arduino
Any idea what those boards are doing? Apart of converting the BNC to a patch that can be connected to the Arduino or ESPxx board?
I believe they are doing ADC conversion and Voltage divider. If you write the software correctly you can do ADC accurately on the board, and a few resistors will do voltage dividing. All Arduinos have at least one ADC, (some models may have more), no Pi’s can do ADC.
Hi again, finally got some time with this.
I've had success with @DutchForce75 's pyZodiacTri code. It connects successfully and the webpage shows current into. But @sfeakes code doesn't work. Same error as above, no ACK.
What can I do to debug this? Success suggests that all the hardware is fine, and @DutchForce75 says his code is based to a large degree on @sfeakes code. It's great being able to control the SWG in a bit of a dodgy fashion by connecting and disconnecting, but I'd love to use MQTT. Any tips?
@tortfeaser good to hear you got it working. Would you mind posting a few things for me? What hardware are you using? (What RS485-USB device, Pi Hardware) What is your wiring diagram? What is your chlorinator setting?
@Kranzy I'm using a SN75176 based RS485 converter, from this link: https://www.aliexpress.com/item/1986666313.html I used a RaspberryPi 3B+ for initial bench testing, and have now connected it to a RaspberryPiZero wifi. The RPi (via the GPIO) and the Tri power terminals are powered by a generic DC module like https://www.aliexpress.com/item/33004374185.html, that is powered by the Tri's 15v terminals.
Wiring is A to A, B to B on the Tri to the RS485 module. 5v and GND to the Pi GPIO pins 2 and 6 are shared with the pos and - terminals on the Tri and GND is also shared with the RS485 module (don't know if this is necessary, I didn't test without).
Chlorinator is set on Jandy L/M.
@tortfeaser Great to hear the connection is working. Please be aware that allthough I based the python scripts to various sources, it's not a 1 to 1 translation. It's currently very basic and has almost zero error handling. ( I haven't been able to thoughly test it myself. )
Hi again, finally got some time with this.
I've had success with @DutchForce75 's pyZodiacTri code. It connects successfully and the webpage shows current into. But @sfeakes code doesn't work. Same error as above, no ACK.
What can I do to debug this? Success suggests that all the hardware is fine, and @DutchForce75 says his code is based to a large degree on @sfeakes code. It's great being able to control the SWG in a bit of a dodgy fashion by connecting and disconnecting, but I'd love to use MQTT. Any tips?
I'm away at present, when I get back I'll unhook my SWG from the control panel and wire it back to the pi and play with it some more. I looked at DutchForce75 code and it looks identical to mind for the serial & protocol stuff.
Hi again, finally got some time with this. I've had success with @DutchForce75 's pyZodiacTri code. It connects successfully and the webpage shows current into. But @sfeakes code doesn't work. Same error as above, no ACK. What can I do to debug this? Success suggests that all the hardware is fine, and @DutchForce75 says his code is based to a large degree on @sfeakes code. It's great being able to control the SWG in a bit of a dodgy fashion by connecting and disconnecting, but I'd love to use MQTT. Any tips?
I'm away at present, when I get back I'll unhook my SWG from the control panel and wire it back to the pi and play with it some more. I looked at DutchForce75 code and it looks identical to mind for the serial & protocol stuff.
I made a small change, can't test anything yet. Please get the latest copy from the git repo and try it.
sudo ./release/aquarited -d -v -c ./release/aquarited.conf
WooHoo. I got some result, a couple of ACKs then aquarited crashed with a segmentation fault. The terminal output is available here: https://pastebin.com/CUrLX1nv
Thanks for all your help and persistence with this. Appreciate your effort.
BTW, here's the output of the test @Kranzy was asked to do:
pi@RaspiPi0pool:~/AquapureD $ echo -n -e '\x10\x02\x50\x00\x62\x10\x03' > /dev/ttyUSB0
pi@RaspiPi0pool:~/AquapureD $ od -x < /dev/ttyUSB0
0000000
OK, I edited ./release/aquarited.conf with my mqtt broker settings and to turn on the log. No more segmentation fault now, the log output is at https://pastebin.com/y2dnenUT
So success, I think. Now to see what I can do with the MQTT output.
I forgot to mention it’ll crash without MQTT enabled, but you figured that out. If this is going to be used, I’ll clean up the code and put a web api and ui to it. It will also work with apple homekit. I’ll need to document how to set it up. But with MQTT you should be able to use the endpoints with any home automation hub and control it like you would a thermostat or a dimmer switch, depending on how you configure it.
Epic. Fantastic stuff. I was wondering if I'd see the web page like AqualinkD.
So I see MQTT messages on the broker, only:
aquarited/SWG
aquarited/SWG/Percent
aquarited/SWG/Percent_f
But I try mosquitto_pub -h 192.168.1.200 -p 1883 -u mqtt -P mqtt -t 'aquarited/SWG/set' -m '2'
then aquarited/SWG stays at 0
If I try mosquitto_pub -h 192.168.1.200 -p 1883 -u mqtt -P mqtt -t 'aquarited/SWG/Percent' -m '100'
aquarited/SWG/Percent stays at 50
and mosquitto_pub -h 192.168.1.200 -p 1883 -u mqtt -P mqtt -t 'aquarited/Filter_Pump/set' -m '1'
does nothing.
Should I expect different?
All topics to change value end in set. so it should be aquarited/Persent/set To set the percent aquarited/SWG/set To turn it on / off. (I don’t think on off works without controller)
The percent_f topic is for homekit integration and shouldn’t be used
I tell a lie.
If I try mosquitto_pub -h 192.168.1.200 -p 1883 -u mqtt -P mqtt -t 'homeassistant/aquarited/SWG/Percent/set' -m '100'
then the response from AquariteD log is
Debug: MQTT: topic homeassistant/aquarited/SWG/Percent/set 100
SET PERCENT TO 100Info: MQTT: Published id=19: homeassistant/aquarited/SWG/Percent 100
Info: MQTT: Published id=20: homeassistant/aquarited/SWG/Percent_f 37.777779
Info: MQTT: Published id=21: homeassistant/aquarited/SWG 0
Info: MQTT: Message publishing acknowledged (msg_id: 19)
Debug: MQTT: topic homeassistant/aquarited/SWG/Percent 100
Info: MQTT: Message publishing acknowledged (msg_id: 20)
Debug: MQTT: received (msg_id: 20), looks like my own message, ignoring
Info: MQTT: Message publishing acknowledged (msg_id: 21)
Debug: MQTT: received (msg_id: 21), looks like my own message, ignoring
So it looks like I can set the SWG percent value, but trying to set aquarited/SWG/ to 1 or 2 does nothing. In a perfect world, I'd like to be able to turn off and on the filter pump attached to the SWG, adjust the SWG percent, read error codes (the aqualinkd/SWG/fullstatus topic) and read temp, salt PPM and pH values. MQTT is great for all this, I'm using Home Assistant.
Success then, I can set the SWG percent value successfully, and as you thought, aquarited/SWG/set 1 (or 0 or 2) doesn't do anything.
(I changed the topic in aquarited.conf to homeassistant/aquarited to try and get Home Assistant to discover the MQTT topic.)
You can’t actually turn the SWG on or off from RS485, that’s why the on off doesn’t do anything. What I can do is use an off command to set the percent to 0, that’s all a controller does. I’ll look and implementing this in a meaningful manner and cleaning up the code when I’m back home. (Away on business at the moment)
BTW, a typo in my previous post it’s
If you pull the HomeKit integration template from AqualinkD and delete everything but the SWG stuff, you should be good to go.
On and yes, fulltopic is only implemented for Domotiz integration. I’ll add the generic Fulltopic to aquarited as well now someone is going to be using it
Thanks @sfeakes. I'll look at the HomeKit stuff as you suggest.
I'm not clear what setting /SWG/Percent/Set 0 does to the SWG. My SWG (Zodiac Tri pH) has terminals for the electrolysis cell, a connector to plug the filter pump power into, and a pH sensor input. Will setting /SWG/Percent/Set 0 turn off the electrolysis cell and turn off the filter pump power?
the set off topic was for a control panel, the control panel simply sets the percent to 0. It can’t physically turn the SWG on or off over RS485 like you can with something like a RS485 pump or heater. So the actual on or off is still controlled by the mains power, which sounds like it’s tied to the filter pump in your setup.
Yeah, I think we're misunderstanding each other. My filter pump is connected to the SWG at the port circled in the image below. When I use a timer in the SWG the SWG turns the filter pump on and enables the cell. Does /SWG/Percent/set (anything greater than 0) power that circled port and enable the cell? Does /SWG/Percent/set 0 remove power from the circled port and disable the cell?
I’m sure the miss understanding is my side. I’m, tired and had a few, in a hotel. I’ll have to spend some time going over documents / circuits to fully answer your question. But I believe it simply reduces power to the cell. How I’m not sure, if it’s physical power or PWM. But I don’t believe SWG 0 will remove all power to the cell. I believe the only true 0 power to your cell will be through the timer, which I can’t access over RS485. Above is not 100% accurate just what I think is happening.
Work travel sucks.
In the end it might not matter. The cell won't be enabled if there's no flow, so if necessary I can control the pump by some other method and use aquarited to control the cell.
So being connected to a controller overrides the built in timers, will we be able to set on/off timers using aquapure?
A controller physically turns the power on / off to a SWG through a relay. You can easily do that with a pi as well. All a controller really does is control relays and act as a RS485 master to all devices. So you would basically turn off the timers on the TRI and allow the controller to turn it on off through physical power. That’s how it works with a control panel.
So when your SWG is connected to a controller it physically cuts the power to the mains?
It seems strange that it wouldnt use the same process the internal timers use. I guess there is no harm in cutting the power completely to the SWG.
I'm with Kranzy. I thought the controller would use RS485 to tell the SWG to cut power to the filter pump and disable the cell.
Page 9 of the document shows an using an external timer. So It could be possible to cut the power entirely and then on turn on and after a set amount of time change the SWG% if required (would need to wait for it to get a connection again). Manual states to clear the timers and leave it on, I guess it will default back to that when power is restored. It would also restore last % as it does now.
I have a setup where the pump is controlled by my raspberry pi.
The SWG will give an error during the times when the pump is switched off, but the cell will work when the pump is on and there is water flow.
For this to work the SWG always needs to be switched on and I do this by setting the off timers to 00:01 and 00:03 and the on timers to 00:02 and 00:04.
I use the Pi as external controller so I can switch it off by connecting and disconnecting. I do this to do a chlore shock and prevent the Tri from adding pH-. The next day the SWG's timers will switch it back on.
It's actually working quite well for my situation.
Powering the whole unit off is not something I would consider solid with this unit. The memory is not really that stable in my experience
I'm with Kranzy. I thought the controller would use RS485 to tell the SWG to cut power to the filter pump and disable the cell.
I should have said, my reply about power is from how standard SWG work. The Tri Pro seems to be a different animal.
So when your SWG is connected to a controller it physically cuts the power to the mains?
Yes, All the SWG that I've come across so far are wired like this. The control panel physically cuts the power to them, usually wired to the same terminal relay as the pump. So when pump is on so is SWG. I can see this in the RS485 logs of AqualinkD that people have sent me.
Page 13 below is how I'm used to see SWG power wired. (The timer shown in the pic is a control panel) https://images.inyopools.com/cloud/documents/aquapure-ei-owners-manual.pdf
There seems to be a few versions of this Tri Chlorinator, and from what I'm reading in this thread it's powered all the time, and has timers to turn the SWG on and off, and it also powers the pump on and off. Hope I'm getting that correct?
From the manual.
When the TRi chlorinator is connected to a controller it is in slave mode and responds to requests. In this case the
Timer se^ings are ignored and the chlorine production level cannot be changed. All the other ‘MENU’ functions are
still available except for ‘BOOST’ and ‘LOW’ modes.
So when we are controlling it over RS485, it looks like we will need to set some form of timers in the Pi otherwise it'll just run 24/7. Since I don't have a unit to play with, I'm really not sure how these things are going to work / react since there is no documentation. I'll post some changed to the code soon, and and get you guys to test it.
Let me provide some info of how the Zodiac works. There is three different states:
One way to move the unit from ON->STANDBY is to stop talking Jandy to it.
Regarding the pump, i run it separately. Can anyone confirm if the 220-240V are provided from the unit or this is a ON-OFF signal to turn on the pump by means of relay?
I'm with Kranzy. I thought the controller would use RS485 to tell the SWG to cut power to the filter pump and disable the cell.
I should have said, my reply about power is from how standard SWG work. The Tri Pro seems to be a different animal.
So when your SWG is connected to a controller it physically cuts the power to the mains?
Yes, All the SWG that I've come across so far are wired like this. The control panel physically cuts the power to them, usually wired to the same terminal relay as the pump. So when pump is on so is SWG. I can see this in the RS485 logs of AqualinkD that people have sent me.
Page 13 below is how I'm used to see SWG power wired. (The timer shown in the pic is a control panel) https://images.inyopools.com/cloud/documents/aquapure-ei-owners-manual.pdf
This isn't the approach used in Australia. The couple of SWGs I've used have all had the pump connected to the SWG and controlled by it.
There seems to be a few versions of this Tri Chlorinator, and from what I'm reading in this thread it's powered all the time, and has timers to turn the SWG on and off, and it also powers the pump on and off. Hope I'm getting that correct?
Yes, that's how mine is. It has a socket for the filter pump (circled in the attached pic) and the timers turn the pump off and on and control the cell. If the boost circuit is activated, the timers are ignored and the filter pump runs for 24 hours and the cell is at 100%.
I'll post some changed to the code soon, and and get you guys to test it.
Awesome.
Regarding the pump, i run it separately. Can anyone confirm if the 220-240V are provided from the unit or this is a ON-OFF signal to turn on the pump by means of relay?
Switched 240v is provided from the SWG and turned off/on as by the timers. The circled socket on the SWG (in the pic below) is the 240v source for the pump.
I've posted an update to AquapureD
PLEASE CONSIDER THIS ALPHA SOFTWARE, it has not been fully tested.
it's had some drastic changes, so I would save a copy of your old aquapured directory/ and get the latest copy into a different directory. The binary has been renamed to aquapured.
So run edit your aquapured.conf and run
sudo ./release/aquapured -d -c ./release/aquapured.conf
MQTT is same as before, except now you should see a fullstatus
topic.
Web interface has been added.
WebSocket API is there. (not documenting that at the moment)
Web API has been added.
Web API is as follows.
http://<ip>?command=swg_percent&value=15
There are no timers, so I would use cron and the web API to start / stop at the intervals you like. The below is an example to turn on to 50% at 9am and turn off at 11am every day
0 9 * * * curl "http://localhost?command=swg_percent&value=50"
0 11 * * * curl "http://localhost?command=swg_percent&value=0"
I'm very interested to see what status you get when you set SWG to 0 on these Tri units that control the pumps, and if it does turn the pump on and off.
Tops.
I've tried this out. Here's the MQTT result:
aquapured/SWG 0
aquapured/SWG/Percent 50
aquapured/SWG/Percent_f 10.000000
aquapured/SWG/PPM 0
aquapured/SWG/PPM_f -17.777779
aquapured/SWG/fullstatus 254```
The web result is in the screenshot below:
![2019-09-30](https://user-images.githubusercontent.com/1853549/65848752-d3357a00-e38a-11e9-90d4-d61e3cd6e592.png)
When both these were recorded, the little icon like + in the top right corner of the SWG screen was there, the pump was running, and the screen showing cell at 10%. I've attached the log, the record of the aquapured run starts at 13:31pm. Might be more use if I up the log level.
[aqualinkd.log](https://github.com/sfeakes/AquapureD/files/3668797/aqualinkd.log)
So I'm not sure what's going on.
Sorry, mistake in my packet logic in the code, I'll update soon.
I've posted an update. Not sure it will completely fix it. If it doesn't work, try adding -f
to the command line.
Thanks for the fixes. Victory! I think.
Doesn't work without the -f switch, but looks like it is working. Great!
With the -f switch I get the web page - but the radio button showing on/off is inconsistent in its operation. Sometimes it shows off when the SWG is on and generating salt. I think it tracks the aquapured/SWG value, if 1 the radio button is on (blue) if 0, the button is off. The aquapured/SWG value seems to track the .../fullstatus value, if /fullstatus is 0 and the SWG is > 0 then /SWG is 1, but any other combination of /fullstatus and whatever % is /SWG 0. I need to put in a couple of bags of salt and remove the low salt error to check.
The log shows salt PPM of 2900 from the serial output, but the MQTT output calls that 4000? A test of the water (with the test strips) shows a value less than 4000 and the Tri only throws the low salt error at between 3000 and 4000PPM. Is there a floor for the MQTT salt value?
Best of all, if I change the SWG slider from 0-100% the SWG responds, the SWG screen shows the set %. And if I set the slider to 0% the pump turns off and the SWG screen shows 'OFF' (but still with the RS485 connection icon).
Here's a log.
@sfeakes, I've the RPi_Zero running AquapureD running a VNC server, and a pic available of the SWG here: http://tortfeaser.crabdance.com:8123/local/camera_latest.jpg
Email me at [myusername]@gmail.com and I'll send you the VNC login details if you're interested in testing this thing yourself.
That’s great that the set to 0 turns the pump off, that’s the main thing I was looking for. I should have said the on/off blue button will not be accurate, that from how mine works not the Tri. I’ll need to figure out how to get that working for how these Tri units are wired, without braking other units from working. The raw data from your logs, shows 4000 ppm, so the MQTT was accurate, but then 1/2 way through the PPM went to 2900 and a low salt status came up. For some reason MQTT was still posting the old 4K value and not the new 2.9k, I’ll see why that would be. 4000ppm is high BTW not low, 3200 is where is try to keep mine. I’m surprised that PPM went from 4000 to 2900 like that, I wonder how often it analyzes PPM. Do you have a PPM number shown on the Tri unit itself?
Let me fix what I can, and then find some time when I’m at home and I’ll take you up on the VNC offer to finalize this.
Thanks for all the work on this. Its really helpful.
The Tri doesn't show salt PPM, only the low salt warning when salt between 3000 and 4000. The Tri manual says keep salt at >4000, and the Australian standard (says the manual) is for between 4000 and 7000.
BTW, I just saw the display show 'cell cleaning', which is great that even when controlled externally the internal timer still takes over to control the cleaning routine.
I’ve figured out why the updated PPM didn’t get posted, I’ll fix that soon. Wow, that’s really high PPM, and with that range, probably explains how it could drop from 4000 to 2900 so quickly as it’s right at the end of the scale for the device.
Oh, that -f switch, on my SWG I have to do a check before I can control it, looking over your logs, that was failing, but also didn’t look like the Tri needed it. So the -f switch just forces AquapureD to ignore the check and go straight to trying to control the SWG.
@tortfeaser if you could post the logs of setting the percent to 0 that would be a great help. There is still one byte of the protocol I haven’t worked out yet, and maybe the way these Tri units work will answer that.
OK. Try the attached. aquapured.log
I'm not sure what people looking at this thread know about Home Assistant and MQTT. I've got 'mqtt_aq_topic' set to homeassistant/aquapure, and in HA mqtt discovery is true and the discovery_prefix is homeassistant. Any ideas why HA won't discover the AquapureD SWG devices that I can see if I sub to 'homeassistant/aquapure/#'?
https://www.home-assistant.io/docs/mqtt/discovery/
This explains the process a bit more. Not sure if anything else needs to be done in aquapure. The other option is to just add them manually.
Thanks for the logs, that helped a lot. I've posted another update, lets see if this is any better.
Hi sfeakes,
Thought I would post here to keep our discussions about AquapureD separate from AqualinkD.
My RS485 converter showed up last night. This is the one I got: https://www.amazon.com.au/gp/product/B0721BB8PQ/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
Would you might giving a bit of direction about whats involved in introducing power on the RS485? Will I need to supply power into the Tri Chlor or just the 2 data pins?
Im assuming just setting up rasbian on the pi?
I have a Pi model B (from memory) laying around not doing anything that I'll be using. Ill be running ethernet to the shed (backs onto house) and will be looking at integrating it with home assistant once its all up and running.