itub / hot-tub-controller

Raspberry Pi web enabled hot tub controller, supporting a heater, air and water temperature thermistors, and two pumps (with hardware schematic)
MIT License
24 stars 7 forks source link

Using your code for inflatable hot tub pump unit controller. #4

Open Hdale85 opened 6 years ago

Hdale85 commented 6 years ago

I bought an inflatable hot tub for cheap that had issues with the built in controller. I pulled the unit apart and found that the on board controller was pretty similar to standard hot tubs, everything was marked and laid out so I could use them all independently. So I'm trying to use a RaspberryPi to control it now. Your project seems to have pretty much everything I need I'm just curious if a few difference will require any coding changes as coding isn't really my cup of tea lol.

I'm currently using a Raspberry Pi B v2.1 although after I get this running I'm pretty sure I'm going to move it over to a Raspberry Pi Zero W since it has onboard wifi and such. Now the pump setup has 2 temp sensors on board which are analog, there are also 2 flow sensors that are just magnetic reed switches but it'd be awesome to implement them at some point for a safety so the heater can't turn on if there's no flow. For ADC I already purchased an ADS1115 16Bit I2C ADC+PGA board and I also purchased a 4 channel relay board that can do 120v 15amps each. Now the unit I'm converting only used 120v 12amp to start with so that should be plenty. The one thing I'm unsure of is if the ADC controller I got is going to make a difference with your code, would I need to change things? It just uses 3.3v, SDA, SCL and ground connections. This is the ADC I got https://www.adafruit.com/product/1085 for reference.

As for the connections on the pump/filter unit. There are 4 connections for 2 heaters, one connection to a transformer which provides 12v and provides 12V AC to the DC filter pump. Then there's a 120v air pump for the bubble jets. Also there's some sort of weird descaling wire that it had, it's just 2 layers of wire wrapped around the output side pipe. I'm not sure if I can ever do anything with that. Anyways that should give you the gist of what I'm dealing with here lol. Control wise I can't imagine much would be different as it's pretty much the same as a standard hot tub minus some extra pumps and stuff, and it's all 120v which that should only matter for the relays.

Hdale85 commented 6 years ago

I just tested the thermistors with my sousvide setup, and they are indeed 10k ohm at 77 degree just like yours. So that shouldn't be an issue. Just a matter of getting the ADC to work then. Since it's a different chip I'm just not sure it'll drop in place of what you used.

itub commented 6 years ago

If you are a using a different ADC chip I'm sure you'll have to make code changes. The chip I used was only about $1.50 I think (...I think I added a parts list?) so that might be an easier route. It worked great for me (I've built about 4 of these setups). My setup was all 220V for the pumps, but that was all handled by just 5V control signals from the Pi and two relays per pump (one for each hot lead). If you have appropriate 110V relays you should be able to turn them on the same way.

Your probably going to have to have make some slight Python changes to get everything how you want.

I'm super busy at the moment so don't have much time to help out, but wish you luck.

On Mon, Jun 4, 2018 at 10:43 AM, Hdale85 notifications@github.com wrote:

I just tested the thermistors with my sousvide setup, and they are indeed 10k ohm at 77 degree just like yours. So that shouldn't be an issue. Just a matter of getting the ADC to work then. Since it's a different chip I'm just not sure it'll drop in place of what you used.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-394439283, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ojKRIyeF7Rhv2nI8IqAQLbpFm14jks5t5XHPgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Yeah those chips are like 4 bucks these days, I'm probably just going to order one I just liked this one because it was all included on a nice little PCB. If I use the same chip I shouldn't really have to change anything should I? Well other than trying to add in code for the flow sensors I suppose.

itub commented 6 years ago

If you use the same chip and you wire up the (4?) pins the same, it should be fine. I think it has 8 analog inputs (I used three myself -- water in/out and air).

It was pretty easy to do the I/O with the Raspberry Pi and Python. My first attempt at this was years earlier with an Arduino an "C" and it was 50 times harder (it has terrible networking too, and you couldn't host a web server like CherryPy so easily).

I don't have a flow sensor because my heater automatically includes that.

On Wed, Jun 6, 2018 at 9:32 AM, Hdale85 notifications@github.com wrote:

Yeah those chips are like 4 bucks these days, I'm probably just going to order one I just liked this one because it was all included on a nice little PCB. If I use the same chip I shouldn't really have to change anything should I? Well other than trying to add in code for the flow sensors I suppose.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-395132499, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7oheLZSe8riXkQX2N3fFxrYEO5UGHks5t6AQpgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Ok, last thing. I don't think I need the transistors or anything as I'm just using standard relays because all my stuff is 120v. So I should just need the MCP3008, Raspberry PI, and Relay board right?

itub commented 6 years ago

Depends on the spec for your relays -- you have to see how much current draw there is, and whether it exceeds what the Pi can put out on each pin. My high voltage relays for pumps were fine, so your 100V relays will be fine if similar to what I used, but the heater "on/off" SPDT relay I used (basically to switch one wire between two other wires) could not be drive without a transistor. You may not need that relay if all you are controlling are pumps.

I think I put the part number in for what I used. The pump relays I used looked like this one -- 3 to 32V DC control with very little current draw so can be directly controlled by the Pi - they are expensive in the US but I found them really cheap online from China (less than $5 each I think - took like 8 weeks though):

http://www.radwell.com/Shop?source=GoogleShopping&IgnoreRedirect=true&ItemSingleId=88773338&utm_source=google&utm_medium=cpc&adpos=1o4&scid=scplp88773338&sc_intid=88773338&gclid=EAIaIQobChMIgKKg4ojA2wIVhaDsCh3xFARlEAYYBCABEgLfQPD_BwE

On Wed, Jun 6, 2018 at 2:34 PM, Hdale85 notifications@github.com wrote:

Ok, last thing. I don't think I need the transistors or anything as I'm just using standard relays because all my stuff is 120v. So I should just need the MCP3008, Raspberry PI, and Relay board right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-395221252, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ooWksvT6dCZwxb-QnvQpNIQxZ0zGks5t6ErUgaJpZM4UZZvT .

Hdale85 commented 6 years ago

My relays take 5v, they also do 15a 120v for the high power side. It just says 5vdc for the input. I doubt they draw anymore than yours, but they also aren't solid state. My heaters are 120v as well so I don't really need the SPDT I don't think. The stock controller didn't use one anyways lol. I've been running the relays on my old PI for a couple days just playing with them and it doesn't seem to have any issues.

Hdale85 commented 6 years ago

I've almost got most of this setup, but I'm trying to figure out what pins to use for the relays. Is the layout in the controller.py the pins you used? Just trying to use the same pins so I don't have to change anything, but those kind of look like sensors since the file description says adc setup or something like that.

Hdale85 commented 6 years ago

Actually I think I figured it out. The only thing I'm not sure how to make work is the Bubbler thing, did you just leave the massage jets on all the time?

itub commented 6 years ago

No - my system has two separate pumps (one 1.5/0.75 HP two-speed and one 1HP), and no bubbler. It's an old-style cedar wooden tub, 900 gallons. Two swimming pool pumps and a 100k BTU swimming pool heater. You're probably the first person to try doing this with more of an all-in-one tub. Sounds like it is going okay...

On Mon, Jun 11, 2018 at 10:27 AM, Hdale85 notifications@github.com wrote:

Actually I think I figured it out. The only thing I'm not sure how to make work is the Bubbler thing, did you just leave the massage jets on all the time?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396321102, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ogOLOE5Bpc42OwddsTYdeC_O-gE0ks5t7qiEgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Yeah it's going somewhat ok lol. If my pump is single speed should I just connect it to the pump 1 high? or will it run the low on high if it's configured for single speed pump?

And yes I do believe I am the first as I looked all over the net trying to find someone that had done it since apparently the controller issue with these all in ones are pretty flaky and to my surprise no one had lol.

Your web interface is it all just auto control? Or are there buttons for turning things on and off? If there are buttons I could just connect the bubbler to the Pump 2 at that point. But kind of looks like it's all automatic. The bubbler in these are basically like the massage jets in traditional hot tubs lol. You generally don't want them running while heating as they cool the water significantly.

itub commented 6 years ago

I don't have any physical buttons - I just log in with a browser. If you don't have a second pump, then by all means just use one of the pump 2 pins and just change the text on the web page.

If your pump is single speed the main thing is to check the specs to see if they want you to switch just one wire. If it's 110V I imagine you just switch the hot (black or red). For single speed 220V pumps those typically want you to switch both hots together.

On Mon, Jun 11, 2018 at 10:37 AM, Hdale85 notifications@github.com wrote:

Yeah it's going somewhat ok lol. If my pump is single speed should I just connect it to the pump 1 high? or will it run the low on high if it's configured for single speed pump?

And yes I do believe I am the first as I looked all over the net trying to find someone that had done it since apparently the controller issue with these all in ones are pretty flaky and to my surprise no one had lol.

Your web interface is it all just auto control? Or are there buttons for turning things on and off? If there are buttons I could just connect the bubbler to the Pump 2 at that point. But kind of looks like it's all automatic. The bubbler in these are basically like the massage jets in traditional hot tubs lol. You generally don't want them running while heating as they cool the water significantly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396324307, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7olSkJ-baGJdk8WbUFfFziMtzpYLMks5t7qrQgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Ah yeah it should just be the one wire then. So then the high speed is just adding power to the second hot wire on the pump?

And yeah I meant on the web interface when you login can you control the pumps and what not individually.

itub commented 6 years ago

On my pump, low vs high speed is switched based on which terminal the hot wire goes to on the pump (you turn ONE of two hots on, and the opposite polarity hot of the 220V is always on). It's totally dependent on your pump. (Mine are Pentair Superflo). You should probably find a manual for the pump if possible...

On Mon, Jun 11, 2018 at 10:44 AM, Hdale85 notifications@github.com wrote:

Ah yeah it should just be the one wire then. So then the high speed is just adding power to the second hot wire on the pump?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396326507, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7oip-kvJ_uoa3pPooUUmov_rYxkcMks5t7qx1gaJpZM4UZZvT .

Hdale85 commented 6 years ago

It's just a low voltage ac pump has only 2 wires. I doubt I'll find a manual but I'll have to look into it.

itub commented 6 years ago

I'm sure one is neutral and one is hot, and you'll switch the hot (black or red) if it's just 110V.

Dan

On Mon, Jun 11, 2018 at 11:50 AM, Hdale85 notifications@github.com wrote:

It's just a low voltage ac pump has only 2 wires. I doubt I'll find a manual but I'll have to look into it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396347090, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7olXWxMY3FKJfxHDn2NX0HYu7Chi1ks5t7rvngaJpZM4UZZvT .

Hdale85 commented 6 years ago

Actually it runs off a transformer it's 12v 60hz ac from what I wrote down here lol.

itub commented 6 years ago

Gotcha. I'm pretty sure you could just switch the hot lead into the transformer.

On Mon, Jun 11, 2018 at 12:59 PM, Hdale85 notifications@github.com wrote:

Actually it runs off a transformer it's 12v 60hz ac from what I wrote down here lol.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396367359, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ohRkikwLOyc6oaZhh_ltJCOj72Beks5t7swHgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Well it also supplies 12V dc out of the transformer which I plan to use for the Pi, so I'm going to switch the pump itself likely.

itub commented 6 years ago

Ok - the Pi is 5V I believe. You could just plug it in separately with it's own supply - up to you.

On Mon, Jun 11, 2018 at 1:21 PM, Hdale85 notifications@github.com wrote:

Well it also supplies 12V dc out of the transformer which I plan to use for the Pi, so I'm going to switch the pump itself likely.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396373908, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ooO1nyJT-C7JHDKVcyYjtBIobqiaks5t7tFZgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Yeah I have a buck converter for it. Trying to keep everything contained in the pump unit. Eventually my brother in law might help me start from scratch code wise so we can add a bunch of stuff specific to this setup.

Hdale85 commented 6 years ago

Are there any packages I need to install for your code? I tried to run startup.py and it's complaining about a cherrypy import line.

itub commented 6 years ago

Yeah, definitely need cherrypy and maybe also the GPIO raspberry pi package. I think you can just "sudo pip install cherrypy".

On Mon, Jun 11, 2018 at 1:58 PM, Hdale85 notifications@github.com wrote:

Are there any packages I need to install for your code? I tried to run startup.py and it's complaining about a cherrypy import line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396384957, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ovbKXvzaHgPv9ITJ6sLPlBy2wmTUks5t7tnagaJpZM4UZZvT .

Hdale85 commented 6 years ago

Ah now I found it, it's python-cherrypy

Hdale85 commented 6 years ago

Ok so guessing the other package is pigpio, there are some python gpio packages as well though.

itub commented 6 years ago

That doesn't ring a bell. The import statement imports "RPi.GPIO"

On Mon, Jun 11, 2018 at 2:05 PM, Hdale85 notifications@github.com wrote:

Ok so guessing the other package is pigpio, there are some python gpio packages as well though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396387078, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ogfAGk8sOELWl8TYksEZHpr6gNUwks5t7tuYgaJpZM4UZZvT .

itub commented 6 years ago

https://pypi.org/project/RPi.GPIO/

On Mon, Jun 11, 2018 at 2:07 PM, Dan Hardy hardydb@gmail.com wrote:

That doesn't ring a bell. The import statement imports "RPi.GPIO"

On Mon, Jun 11, 2018 at 2:05 PM, Hdale85 notifications@github.com wrote:

Ok so guessing the other package is pigpio, there are some python gpio packages as well though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396387078, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ogfAGk8sOELWl8TYksEZHpr6gNUwks5t7tuYgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Ah ok, found that one too

Hdale85 commented 6 years ago

Hmm, now it's looking for something called twilio? i searched the database and the only result coming back is python-django-social-auth

itub commented 6 years ago

https://www.twilio.com/

That's for SMS notifications (freeze warnings in my case). You can rip that code out if you don't want it to send you texts (Twilio charges a fee too).

On Mon, Jun 11, 2018 at 2:12 PM, Hdale85 notifications@github.com wrote:

Hmm, now it's looking for something called twilio? i searched the database and the only result coming back is python-django-social-auth

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396388979, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7opaSfilyYg_icyZh7w0c9o-pzWFzks5t7t1DgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Just this line? from twilio.rest import TwilioRestClient Or does the authentication stuff below it go with it?

Hdale85 commented 6 years ago

Nevermind was a couple parts it seems.

Hdale85 commented 6 years ago

Ok, so do I need to define pins somewhere? lol

https://pastebin.com/zn79TfBC

It popped on all the relays and then said that.

Hdale85 commented 6 years ago

Oh I see it's looking for pyopenssl, might be one issue.

Hdale85 commented 6 years ago

And some new issues, https://pastebin.com/w4y77cAF I'm probably doing something wrong.

itub commented 6 years ago

The HTTP server startup failure has something to do with a private key setup for SSL, I think. Looks like maybe it wants a passphrase? I don't recall having to set anything up for that... Not sure about the GPIO warnings - I don't get them. Maybe the RPi.GPIO package changed. And maybe those warnings can be ignored safely...

On Mon, Jun 11, 2018 at 2:33 PM, Hdale85 notifications@github.com wrote:

And some new issues, https://pastebin.com/w4y77cAF I'm probably doing something wrong.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396394382, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7oswZnqMtGScUcnjyix27asVFZoEMks5t7uIcgaJpZM4UZZvT .

itub commented 6 years ago

I’d try changing the code to get http working first (you may not care about SSL anyway, and certificates can be tricky to configure).

On Jun 11, 2018, at 2:33 PM, Hdale85 notifications@github.com wrote:

And some new issues, https://pastebin.com/w4y77cAF I'm probably doing something wrong.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Hdale85 commented 6 years ago

I don't plan on using it outside my network, at least not anytime soon lol.

Hdale85 commented 6 years ago

Ok, apparently it may be looking for a config.json file for configuration.

itub commented 6 years ago

Yeah, it wants a config.json in /home/pi, and also a users.json, filters.json, and alerts.json. Probably not difficult to see what properties it expects in each from the code.

On Mon, Jun 11, 2018 at 3:58 PM, Hdale85 notifications@github.com wrote:

Ok, apparently it may be looking for a config.json file for configuration.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itub/hot-tub-controller/issues/4#issuecomment-396412921, or mute the thread https://github.com/notifications/unsubscribe-auth/APU7ooj8bZRIFRaXs43qY54LRVRKFi4vks5t7vYlgaJpZM4UZZvT .

Hdale85 commented 6 years ago

Yeah, I got past the SSL issue with the help of somebody. But now it needs the jsons for the login info I guess. did you not need those to login to yours?

itub commented 6 years ago

You’ll need to add one. Should be a simple map of user to password ( I think plain text, maybe base 64, I forget).

On Jun 11, 2018, at 4:47 PM, Hdale85 notifications@github.com wrote:

Yeah, I got past the SSL issue with the help of somebody. But now it needs the jsons for the login info I guess. did you not need those to login to yours?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.