Control your Jandy equipment from your PC with a $15 adapter

Re: Control your Jandy equipment from your PC with a $15 ada

I fixed the transmit problem. It wasn't hardware after all. After reading this forum http://forums.whirlpool.net.au/archive/1966464 I removed a diode from the adapter that supposedly causes problems and it didn't help. Then I added termination resistors as described here http://en.wikipedia.org/wiki/RS-485 and that didn't make a difference either. Finally I noticed that agent-P was specifying 8 data bits on the serial port and I was specifying 7. I changed it to 8 and now the controller responds to me. It didn't seem to matter whether it was 7 or 8 for reading, but apparently it matters on the other end.

I realized that I have the One Touch control panel, whereas agent-P's program is emulating the All Button panel. I'm going to do some reverse engineering today to figure out the commands and buttons my panel uses.
 
Re: Control your Jandy equipment from your PC with a $15 ada

jbuehl said:
Thanks jkurl - uncommenting the en-US line in locale.gen and running locale-gen got rid of the locale errors. Unfortunately autogen.sh is still crashing later on in the same way it did before. I ran it with the --verbose option and it's complaining that the ./m4 directory is missing. I ran it on a Fedora 14 system and it succeeded. The ./m4 directory isn't part of the distribution, it's something that autogen.sh should have created earlier, which it did on Fedora.

agent-P - I got your code built on Fedora 14 after building libwebsockets. When I run it, it daemonizes itself, and I can bring up the html page, but nothing is happening. I don't see a log file or lock file anywhere, and /var/www/html/log/ is empty. Should the log file be created in the working directory that I ran aqualinkd from?

I'm pretty convinced that the inability to transmit is an issue with the adapter hardware. I put an oscilloscope on the RS485 transmit lines and I could see data going out when I wrote to the device with a test program. I found some posts where others have had the same problem and they indicate that particular device may have termination problems. I did try ACKing a probe on a couple of different device IDs and never got a response from the controller. Obviously I need to get this resolved before your software can work.


jbuehl,

Did you put a copy of aqualinkd.conf in /etc? Logging gets its log level from the config file. I never tested what log level you get without the .conf file. I don't remember what the defaults for log level are, but it throws a warning out to syslog (/var/logs/messages) if the .conf file is missing. The daemon also gets the file locations from the .conf file. They are derived from the "running_directory" parameter. It is /tmp in the example .conf file. The default is also /tmp if the .conf file is missing. By default the lock file will be in /tmp and the log file will be in /tmp/log. See the test comments in the header of aqualinkd.c.

Note that the daemon also gets the serial interface device to connect to from the .conf file. Connection success or failure will show up in /var/logs/messages.

If you are looking for a cheap interface that works, someone posted earlier in this thread a link for one from monoprice.com. I haven't tried a really inexpensive one since my initial bad experience. I just ordered an RS232-RS485 interface (actually a couple of different ones just in case for $0.90 and $1.56 respectively). I got a good USB-RS485 interface (see one of my earlier posts for details of my hardware), but the USB hardware on my mother board isn't the best (locks up on me every once in a while, and I have been getting a lot of missed transmits). So, going to try to use the mother board's serial interface to see if I can get a rock solid interface. Definitely the motherboard. It is much more stable on my development system. I will let you know if they work any better.

agent-P
 
Re: Control your Jandy equipment from your PC with a $15 ada

jbuehl said:
I fixed the transmit problem. It wasn't hardware after all. After reading this forum http://forums.whirlpool.net.au/archive/1966464 I removed a diode from the adapter that supposedly causes problems and it didn't help. Then I added termination resistors as described here http://en.wikipedia.org/wiki/RS-485 and that didn't make a difference either. Finally I noticed that agent-P was specifying 8 data bits on the serial port and I was specifying 7. I changed it to 8 and now the controller responds to me. It didn't seem to matter whether it was 7 or 8 for reading, but apparently it matters on the other end.

I realized that I have the One Touch control panel, whereas agent-P's program is emulating the All Button panel. I'm going to do some reverse engineering today to figure out the commands and buttons my panel uses.

jbuehl,

Glad you got your transmit problem sorted out. I forgot what a pain it was to figure out the correct serial parameters. Tried quite a few variations before I got it right. I wonder if I should put them in the .conf file. What do you think?

Question about the one-touch. Why should it matter? Does the master device (Power Center) require a different rev of the firmware to use the one-touch. Mine is running 6520 rev E. what is yours running? I remember the folks at Jandy told me I would need to upgrade the firmware if I wanted to control and monitor a salt water system with it. So, there are newer versions.

I always assumed that the one-touch functionality was actually in the one-touch device, and the protocol with the Power Center was the same as the RS8. Please publish your reverse engineering. I would like to check and see if my rev has anything I haven't discovered. Thanks.

agent-P
 
Re: Control your Jandy equipment from your PC with a $15 ada

I missed the step about putting aqualinkd.conf in /etc. I did that and it created the lock file, but was not able to create the log file, even though the permissions were OK. I eventually created an empty log file and it was happy. Now I can see it's getting good data and logging it, but the web interface is still showing all zeros. That's OK, though because running Fedora isn't an option that I want to pursue because I want to stick with Arch linux on the RPi for this project.

I have the python program doing 90% of what I want at this point. Whether it emulates the One Touch or the All Button doesn't really matter unless there's some cool function that one can do that the other one can't. My pool is 10 years old and the manuals that I have describe both control panels and imply you can have both kinds in the same system. The One Touch device address is in the 0x40 range. I don't remember why I chose the one I did. The diagnostic info says Model: 8156, Type: RS-8 Combo, Firmware JJ. I'm going to continue with the One Touch so I can document it and add that to the knowledge base.

I don't know that having the serial port parameters in the config file is useful unless different controllers have different parameters, but it couldn't hurt either.
 
Re: Control your Jandy equipment from your PC with a $15 ada

Makes sense. Lots of versions between my 6520 rev E and your version JJ. The zeros make sense also. All of the temperature values and the time and date are derived from the text messages the Power Center sends. If you step through my code (the process_packet() and process_long_message()) you will see the message fragments that it uses to parse the messages. You version has probably changed the message text somewhat. Not a problem for human readability, but a machine needs to be more exact. The low level processing will all work for you, but process_packet() and above will all have to be significantly modified or rewritten. Hopefully, you can use it as a template for your project.

Just thought of something you could try. I can't address any device address as high as 0x40. You can try the device range (08-0b, 10-13, 18-1b, 20-23) I specify in aqualink.h. It might respond to an RS8 multi-button device.

agent-P
 
Re: Control your Jandy equipment from your PC with a $15 ada

Agent and jb I had a thought about both of your projects and code. Like I said I am not a software guy but I do understand what you two are talking about. Would it be possible to maybe merge your code into github and make it have the ability to repo sync and compile using ccache. Where am I going W/ this? I am an Electronic Tech so I have the ability to test this stuff if we have the ability to compile it and maybe get a simulator from jandy. I got the raspberry pi, a lcd screen for it and various test equipment at my disposal. I want to help you guys and not ride on your work when you are done. Testing w/ my actual pool will be sporadic due to I live and work in Seattle and my wife & pool r in norcal. Military life. Please let me know what it can do to help you guys.

Jerry

Sent from my HTC One X using Tapatalk 2
 
Re: Control your Jandy equipment from your PC with a $15 ada

jkurl said:
Agent and jb I had a thought about both of your projects and code. Like I said I am not a software guy but I do understand what you two are talking about. Would it be possible to maybe merge your code into github and make it have the ability to repo sync and compile using ccache. Where am I going W/ this? I am an Electronic Tech so I have the ability to test this stuff if we have the ability to compile it and maybe get a simulator from jandy. I got the raspberry pi, a lcd screen for it and various test equipment at my disposal. I want to help you guys and not ride on your work when you are done. Testing w/ my actual pool will be sporadic due to I live and work in Seattle and my wife & pool r in norcal. Military life. Please let me know what it can do to help you guys.

I definitely intend to make my code available once it's reasonably working, either on github or my own repository. Hopefully that will be very soon. I'll also document what I did to get it working on the RPi. As far as merging with Agent-P's code, we are writing in very different languages, so anything like that would have to be done by hand.
 
Re: Control your Jandy equipment from your PC with a $15 ada

Agree with jbuehl. A merge is not practical. As far as using github, I did think about it, but I don't think it is practical with my code in its current form. In many ways, my code is a one-off as an entire entity, and it is not complete. I have a full interface to complete with lots of esoteric behaviors that most users wouldn't want or care about, and as this thread has shown processing the data packets is not consistent through all of the versions of the Power Center firmware.

There is, however, a base set of code that should be practical to have every one collaborate on. Say, basic data packet processing down to the serial interface that will daemonize and provide an API so that apps could connect to it easily. My first test version was very much like that with a simple socket interface. It should be fairly easy to set it up like a command and data relay, keeping all of the sophisticated logic in a java or other service running on the server or even at the remote application itself. Keeping all the logic on the server is better I think because it is more autonomous with less hardware, but that can be left up to the user.

In any case, I will take a look at what I have, and see what is practical. In the mean time, I will periodically zip up my client and server source and post here so you can use it.

agent-P
 
Re: Control your Jandy equipment from your PC with a $15 ada

Guys thank you so much for replying. Let me know how I can help you. I did notice you guys were running the one touch. I am running the pda. I might be able to adapt to your code but might have to change it up.

Jerry

Sent from my HTC One X using Tapatalk 2
 
Re: Control your Jandy equipment from your PC with a $15 ada

jkurl said:
Guys thank you so much for replying. Let me know how I can help you. I did notice you guys were running the one touch. I am running the pda. I might be able to adapt to your code but might have to change it up.

Oh, that's good. Actually I have a One Touch and a SpaLink and Agent-P has the All Button. Right now I'm working on having my code be able to monitor and record the messages to another device so it's easy to figure out what the messages do. When emulating a panel, it doesn't matter so much which one it is as long as your controller supports it, but some may have better capabilities than others.
 

Enjoying this content?

Support TFP with a donation.

Give Support
Re: Control your Jandy equipment from your PC with a $15 ada

I have been monitoring a thread on a forum for the indigo server so we might be able to pull some stuff from that. It is for Mac is but we may be able to adapt some of it. Like u said I am a hardware guy but I can help you where I can.

Sent from my HTC One X using Tapatalk 2
 
Re: Control your Jandy equipment from your PC with a $15 ada

jkurl said:
I have been monitoring a thread on a forum for the indigo server so we might be able to pull some stuff from that. It is for Mac is but we may be able to adapt some of it. Like u said I am a hardware guy but I can help you where I can.

Can you post a link to that thread?
 
Re: Control your Jandy equipment from your PC with a $15 ada

Here's what I have so far. I put it on github at https://github.com/ericbuehl/pyaqualink. This is just a snapshot of what I'm working on which will be changing a lot. At this point I am able to monitor the state of the pool from any web device and turn the spa on and off. The UI is very primitive at this point.

I have the One Touch panel pretty well figured out. It's good for displaying stuff, but not very good for controlling things. The SpaLink is better for controlling things so I may wind up with something that's a hybrid.

Here is what I know about the One Touch protocol:

Code:
    Aqualink One Touch Control Panel

    The One Touch control panel has a 16 character by 12 line LCD display,  6 buttons, and one 
    tri-state (green/red) LED.

    The buttons are:

       1. OneTouch1
       2. OneTouch2/Back
       3. OneTouch3
       4. Select
       5. Down
       6. Up

    The device address for Aqualink serial interface is 0x40-0x43. The address is set with jumpers.
    
    The following basic Aqualink serial commands are supported:

    Probe
        command: 0x00
        args: none
        
    Ack
        command: 0x01
        args: 2 bytes
            byte 0: 0x8b (unknown)
            byte 1: button number that was pressed
                OneTouch1          0x03
                OneTouch2/Back     0x02
                OneTouch3          0x01
                Select             0x04
                Down               0x05
                Up                 0x06
            
    Status
        command: 0x02
        args: 5 bytes
            bytes 0-4: 0x7e5a500b10 if device address is 0x40 (unknown)
                       0x0000000000 turns LED off
                       0x0000001001 turns LED red
                       0x0000004004 turns LED green

    The Long Message command is used to put a line of text on the display
        command: 0x04
        args: 17 bytes
            byte 0: Line number on display (0-11)
            bytes 1:16: display text
            
    In addition to the basic Aqualink serial commands, it also responds to the following commands:

    Unknown command sent periodically if panel sends 0x0b as the first byte of the Ack message args.
        command: 0x05
        args: none
        
    Highlight (invert) Display Line
        command: 0x08 
        args: 3 bytes
            byte 0: Line to highlight (0-11) or 255 to clear highlight
            bytes 1-2: 0x0000 (unknown)

    Clear Display
        command: 0x09 
        args: 2 bytes
            bytes 0:1: same as first 2 bytes of status command (unknown)

    Highlight (invert) Display Characters
        command: 0x10 
        args: 4 bytes
            byte 0: Line to highlight (0-11)
            byte 1: Starting character to highlight (0-15)
            byte 2: Ending character to highlight (0-15)
            byte 3: 1 to set highlight, 0 to clear highlight
 
Re: Control your Jandy equipment from your PC with a $15 ada

I thought my pda was primitive. I just looked up the one touch and man that this is old. Though it has to be faster than the pda. I wouldn't say your code is primitive.

I ended up just springing for the autelis controller. I am not giving up on the raspberrypi project. I still want to help you out. I have Raspbmc on my pi right now until all my parts come in. I have several so cards so I can boot to another os to help you out.

The link I posted was for using indigo server w/ the autelis controller but I think there could be some useful code in his plugin to use. I will look at your github and see if I can compare your w/ his plugin. Probably was off base but worth a shot.

Sent from my HTC One X using Tapatalk 2
 
Re: Control your Jandy equipment from your PC with a $15 ada

jkurl said:
I thought my pda was primitive. I just looked up the one touch and man that this is old. Though it has to be faster than the pda. I wouldn't say your code is primitive.
Yeah, I have had this equipment for 10 years, and they weren't new products then. I don't know how long this set of products have been around. The serial protocol looks it was designed in the 1970s.

I figured out enough of the SpaLink panel to be able to use its commands to turn things on and off. Much easier than hassling with menus using the One Touch commands. I have been updating github continuously with my code changes. Here's what I know about the SpaLink:

Code:
    Aqualink SpaLink Control Panel

    The SpaLink control panel has a 3 digit 7 segment LED display,  9 buttons, and 3 LEDs.

    The buttons are:

       1-8. turn equipment on and off
       9.   cycle display (local function)

    The 7 segment display shows 3 temperatures: water, air, and spa target.  The display button cycles through
    these when pressed.  The 3 LEDs are associated with buttons 1-3.

    The device address for Aqualink serial interface is 0x20-0x22. The address is set by tying a 5th wire
    in the serial interface low (0x20), high (0x21), or open (0x22).
    
    The following basic Aqualink serial commands are supported:

    Probe
        command: 0x00
        args: none
        
    Ack
        command: 0x01
        args: 2 bytes
            byte 0: 0x00
            byte 1: button number that was pressed
                btn1 = 0x09
                btn2 = 0x06
                btn3 = 0x03
                btn4 = 0x08
                btn5 = 0x02
                btn6 = 0x07
                btn7 = 0x04
                btn8 = 0x01
            
    Status
        command: 0x02
        args: 5 bytes
            bytes 0-4:  (unknown)


    Message
        command: 0x03
        args: 17 bytes
            bytes 0-16: (unknown)
 
Re: Control your Jandy equipment from your PC with a $15 ada

I went back and read this thread from the beginning and the original topic was how to come up with a low cost alternative to the $400 Jandy RS232 adapter to be able to control the pool from a program running on a PC or some HA controller. It occurred to me that adding a second USB adapter that does RS232 to my Raspberry Pi setup would accomplish just that. A Raspberry Pi with case, power supply, and SD card is available for $60, so the total cost with the adapters would be $90. All I would need to do is to add the RS232 protocol to my software, which is pretty easy. I'm not particularly interested in this configuration because I want a web based interface, but if this would be useful to anyone, please let me know.
 
Re: Control your Jandy equipment from your PC with a $15 ada

jbuehl said:
I went back and read this thread from the beginning and the original topic was how to come up with a low cost alternative to the $400 Jandy RS232 adapter to be able to control the pool from a program running on a PC or some HA controller. It occurred to me that adding a second USB adapter that does RS232 to my Raspberry Pi setup would accomplish just that. A Raspberry Pi with case, power supply, and SD card is available for $60, so the total cost with the adapters would be $90. All I would need to do is to add the RS232 protocol to my software, which is pretty easy. I'm not particularly interested in this configuration because I want a web based interface, but if this would be useful to anyone, please let me know.

Not sure why you say you are not particularly interested in the Raspberry Pi configuration you describe. I think your hardware selection was spot on, and I believe it is completely compatible with a web based interface. I will have to look at the version of Arch linux that runs on it, but I expect there are at least half a dozen ways to serve a web based interface from the RPi. In fact, if I didn't have that mini-itx motherboard gathering dust in my closet (my total cost was under $100), I would have used an RPi to deploy my project. Adding a mini web server to a daemon that reads the RS485 data stream is actually pretty trivial. I have posted two separate versions of it on this thread alone. The first one I wrote, pretty much from scratch using some demo code I found, to provide a REST interface. You can see my earlier postings for why it wasn't viable. My latest is the libwebsockets version, and it is bullet-proof. Can't be happier with it. I will do some research. I am sure we can find someone who has it building in your target environment, or we can figure it out.

If Arch Linux supports Apache there are a number of other, albeit more complex, options for serving a web interface that will give you what you want. The mini web server integrated into a daemon really is the best way. Trust me on this. I have tried three others. They all worked, but they were either not quite stable, or they were horribly inefficient (not very friendly to your LAN).

One comment on the original topic of this thread. I think these discussions have been compatible with the original intent, and I believe that was "Control your Jandy equipment from a PC with a $15 adapter." My implementation does that, but I made some choices about where I put some of the control logic. I could have simply coded a daemon that relayed data and command packets to and from one or more clients, but I chose to decode/encode the Jandy data stream in the server daemon. This simplified the control and display logic on the web client, and it allowed me to create automated tasks that would execute without the web client being active. Keeping the PowerCenter clock accurate is a good example, and there are others. This is especially important because I wanted a single client to run on as many devices as possible with minimal or no development effort. Note I only have to change my CSS file to have an iPhone perfect interface. Also, I expected to have more than one device monitoring the pool at any given time and I didn't want them to attempt to control the same feature at the same time. :rant: Sorry, little bit of a rant there.

Let me know what you are thinking. Maybe I can help.

agent-P
 
Re: Control your Jandy equipment from your PC with a $15 ada

I probably wasn't too clear in what I said. What I'm not interested in is needing another device in addition to the RPi, so just using it as a bridge to something else isn't what I want. Some people, however, might want to do that so I was offering to help if someone is interested. I want to have the interface and control all provided by one device. I don't know if you looked at the code I posted on github, but what I have is a daemon running on the RPi that interfaces to the pool controller and also provides the web server, so I don't need Apache or any other services. Right now my web interface is primitive and just uses javascript to refresh the data. I plan to make it better and I may use websockets, but I would use a Python library, of which there are more than one. Right now I'm still working on finishing up the backend functionality.

The version of your software that I downloaded and got sort of working on Fedora seems to require a web server in addition to your daemon. Do I have the latest one?

I want to say that even though I abandoned the effort to get your code working on the RPi, seeing how you have done some things has been helpful and has saved me some time. Thanks. I'm sure I could have gotten the C websockets library working on Arch, but going off and writing my own code in Python was a lot more fun. I have been writing software for a living for over 40 years, including a lot of C, and Python is the first language I have used that I actually enjoy writing stuff in :-D My long term goal is to control other things in the house like HVAC, recirculating hot water, etc. so I'll be building a lot more functionality.

I did actually start implementing the RS232 interface since I made that last post and I'm about halfway through the command set. It should be working soon.
 
Re: Control your Jandy equipment from your PC with a $15 ada

jbuehl,

Oh, sorry, I misunderstood.

My code, even the version I uploaded, doesn't require a web server. That is built into the daemon using the websockets library. I have apache (httpd) disabled on the server, and my daemon uses port 80, just so I don't have to specify a port in the URL to access it. I also keep the client code in /var/www/html for convenience. If apache was serving it, it wouldn't work. :) Simply a convenience. My clients do use a web browser, since I wrote them in javascript. I didn't want to write an app for every device. Though, I have been toying with writing an app that wraps a web view. I have one working in android, but didn't bother with iOS since Apple requires the $90 / year developer subscription to deploy to an actual device, even your own for testing.

Python is great, but I grew up with C and have been doing S/W development professionally for about 35 years. Used lots of languages, but always find my way back to C. I would have done this project in C++ (lots of advantages), but I started with some daemon example code in C, and I had a lot written and working as a prototype, and didn't want to go back and rewrite the whole thing. I am going back and fixing some of the more brute force parts of my design, though.

By the way, python-tornado for Arch has websockets built into the package. You might want to take a look at it if you aren't already using it. People are already using it to interface daemons to javascript in a web browser. I haven't looked, but there might be some example code out there you can look at.

I am doing lots of refinements to my code. I have a temp sensor hardware problem to fix that I might actually try to code around. The temp sensor circuitry is unstable so the freeze protection can oscillate on and off every second or two at times. I have an algorithm that can counter that if the oscillations are small enough. Designing the module to high-rate log the air temp by managing a second channel with a separate device id. I will post it in my next version. Also, I am going to finish writing a multi-page javascript interface to complete replace all of the functionality of the RS8 all-button terminal. Going to take a while. After that, I will take a look at your code. Your description has really piqued my interest.

agent-P
 

Enjoying this content?

Support TFP with a donation.

Give Support
Thread Status
Hello , This thread has been inactive for over 60 days. New postings here are unlikely to be seen or responded to by other members. For better visibility, consider Starting A New Thread.