author

neilroeth

8
Inbox View Profile
1Instructables17,036Views65Comments

Tell us about yourself!

Achievements

10K+ Views Earned a bronze medal
Fix It! Contest
Contest Winner Runner Up in the Fix It! Contest
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I share your concern that if you don't disable the keypad then you might not be able to turn off the heater, but you could test it. Set the pool temp to above the current temp, then turn on pool heat with the membrane keypad. It should go on. Then turn off the pool heat with the membrane keypad (while the water temp is still below the setting). That just ensures the settings are correct for the real test, which is to put a jumper across the Pool and Common terminals of the 3 pin connector. The pool heat should come on. Then remove the jumper and it should go off. There might be delays built in to the system, so don't expect things to turn on or off immediately, wait a couple of minutes to see if it has an effect. If that works, you don't need to solder anything, you just need to re…

    see more »

    I share your concern that if you don't disable the keypad then you might not be able to turn off the heater, but you could test it. Set the pool temp to above the current temp, then turn on pool heat with the membrane keypad. It should go on. Then turn off the pool heat with the membrane keypad (while the water temp is still below the setting). That just ensures the settings are correct for the real test, which is to put a jumper across the Pool and Common terminals of the 3 pin connector. The pool heat should come on. Then remove the jumper and it should go off. There might be delays built in to the system, so don't expect things to turn on or off immediately, wait a couple of minutes to see if it has an effect. If that works, you don't need to solder anything, you just need to remember not to use the membrane keypad because you will effectively have dual controls where either the membrane keypad or your Raspberry Pi can turn it on and both have to be off for it to be off.

    Great! Good luck. You can work on setting up the relays and corresponding code to operate them while waiting. :-)

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    The numbering usually is for the whole component, so JMP1 would be one jumper with several pins, JMP2 another jumper somewhere else on the board, JMP3 yet another. Not pin numbers. I have serious doubts that JMP1 is the jumper you need but I do not see JMP3 where expected on the board. A long shot: since the jumper is to disable the keypad, maybe they moved it there? Can you get at the circuit board for the keypad easily?Also, what are the labels on the six pin header labeled J8? That header is not on the diagrams.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I'd test the heater by cutting power, setting the jumper for three wire mode, not connecting anything to the pool and spa connection, then giving it power. I expect it will not turn on. Check the voltage between Pool and Common and between Spa and Common, I expect it to be a low voltage like 3.3V or 5V. My guess is you turn on the heater by pulling either Pool or Spa to the same level as Common. If that is true, then a jumper between Pool and Common on the three wire connector should make the LEDs on the keypad show something and the heater go on (if the water temp is below the Pool temp setting). Same with Spa and Common. I'm not sure, though. Also, caution: there's high voltage in there, so be careful!

    I do not think you would need to install another 240V line for any configuration. When the pump is on, 240V is also supplied to the heater, but the heater will not turn on until there is an explicit action taken to turn it on via the keypad, or the two or three wire connections.If you want to control the heater like pressing buttons on the panel, then you will use the three wire mode and you won't need thermistors and all that. It also means you will not need the temperature measuring or setting in the interface because you will not use those, you will use the panel on the heater to set the temperature. Logic level switching means a relatively low voltage, like 5V or 3.3V (Raspberry Pi is 3.3V, Arduino Nano like I used is 5V) and it's either low (zero volts) or high (5 or 3.3V). See i…

    see more »

    I do not think you would need to install another 240V line for any configuration. When the pump is on, 240V is also supplied to the heater, but the heater will not turn on until there is an explicit action taken to turn it on via the keypad, or the two or three wire connections.If you want to control the heater like pressing buttons on the panel, then you will use the three wire mode and you won't need thermistors and all that. It also means you will not need the temperature measuring or setting in the interface because you will not use those, you will use the panel on the heater to set the temperature. Logic level switching means a relatively low voltage, like 5V or 3.3V (Raspberry Pi is 3.3V, Arduino Nano like I used is 5V) and it's either low (zero volts) or high (5 or 3.3V). See if you can find a mention of a low voltage like this in the manual. If it's 3.3V then you could literally control it directly from a Raspberry Pi pin. If it's 5V, then you can use a logic level converter.It's possible that as you suggest, connecting Pool or Spa to Common would turn it on, but it could be the opposite (Common is off and High is on). See if you can find a mention of which way it is in the manual, too.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I looked at the manual for your Pentair pool heater. It (and many others) have two basic modes of operation. The first basic mode is you can set a pool temperature and a spa temperature at the heater, then turn on pool or spa mode and the heater will handle measuring the temperature and heating until it reaches the preset temperature. Your heater lets you get into that mode either via the pool or spa buttons on the heater, or remotely with the three wire mode. The second basic mode is where a remote device handles measuring the temperature and deciding when to turn on and off the heater. That mode for your heater is called two-wire mode. This second mode is what my article described. That's why my setup included thermistors and a Node Red interface to set the temperatures, and also…

    see more »

    I looked at the manual for your Pentair pool heater. It (and many others) have two basic modes of operation. The first basic mode is you can set a pool temperature and a spa temperature at the heater, then turn on pool or spa mode and the heater will handle measuring the temperature and heating until it reaches the preset temperature. Your heater lets you get into that mode either via the pool or spa buttons on the heater, or remotely with the three wire mode. The second basic mode is where a remote device handles measuring the temperature and deciding when to turn on and off the heater. That mode for your heater is called two-wire mode. This second mode is what my article described. That's why my setup included thermistors and a Node Red interface to set the temperatures, and also why the connection to the heater was a simple 24VAC two wire connection. If you've set up your system similar to my article, then you want to use two wire mode on your heater. From looking at the manual for your heater, it appears that instead of supplying 24VAC, you just need to close the circuit. You could do that by connecting two wires from the Fireman's Switch connections on your heater to the relay (using the two connections which connect when the relay closes). You can test it beforehand by connecting a jumper across the two Fireman's Switch connections. If the heater turns on after a bit, then that's how it works. At least, that's how I read the manual, you need to make sure you understand how it works to avoid frying your heater, or getting a shock, or worse! Note that you do need a relay because the current will be too much for direct connection to a Raspberry Pi. I don't think you need or can use the USB RS485 adapter at all.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I assume you added the WaterfallOnOff flow to NodeRed? Maybe double check the spelling/case? Also, look into using a debug node to display the output of the relay setter node in the debug section of the NodeRed interface. It will show the value of the byte.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    The arduino side labels that pin "unused" but the code should work with no changes if you use pin 4 for the relay. Can you measure that pin to see if it changes when in schedule vs. out of schedule? Also, your schedule has the waterfall on for only six minutes, is that for testing only?

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    From a quick look it seems OK. Is it not working?

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Removing the jumper on the relay board and using a separate power source on those pins helps protect your Arduino. Imagine two separate electrical circuits, one which is controlling the relays and another which is just powering the relays. The circuit which is powering the relays can have spikes in voltage when the relays turn on and off. If that circuit is connected to the Arduino (which it will be if you leave the jumper and power the board from the Arduino), then those spike can get back to the Arduino and damage it. If you remove the jumper and supply 5VDC separately from another power source, then the relay power circuit will be disconnected from the Arduino and any spikes which occur cannot damage your Arduino.I found my relays worked with much less than the nominal voltage, so …

    see more »

    Removing the jumper on the relay board and using a separate power source on those pins helps protect your Arduino. Imagine two separate electrical circuits, one which is controlling the relays and another which is just powering the relays. The circuit which is powering the relays can have spikes in voltage when the relays turn on and off. If that circuit is connected to the Arduino (which it will be if you leave the jumper and power the board from the Arduino), then those spike can get back to the Arduino and damage it. If you remove the jumper and supply 5VDC separately from another power source, then the relay power circuit will be disconnected from the Arduino and any spikes which occur cannot damage your Arduino.I found my relays worked with much less than the nominal voltage, so go ahead and try it with 20VDC, it very well might work.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Sorry, I don't have a video! Maybe someday.

    The voltage rating is a maximum. You must never exceed that voltage or the capacitor will likely be destroyed. In general, the higher the maximum voltge for a given capacitance, the larger the capacitor. So, you want capacitors with a voltage rating somewhat MORE than the voltage that will be applied, but beyond that, higher voltage ratings just mean more bulk.As for the capacitance, in this application more capacitance means better smoothing, but it's not terribly critical.I happened to have three AC voltage sources from the transformer and needed three DC voltages, so it worked nicely. I could have run all three off the 24VAC source, but as mentioned in the article, there is an advantage to running the relay board (5VDC) off its own power source which is separate from the power supp…

    see more »

    The voltage rating is a maximum. You must never exceed that voltage or the capacitor will likely be destroyed. In general, the higher the maximum voltge for a given capacitance, the larger the capacitor. So, you want capacitors with a voltage rating somewhat MORE than the voltage that will be applied, but beyond that, higher voltage ratings just mean more bulk.As for the capacitance, in this application more capacitance means better smoothing, but it's not terribly critical.I happened to have three AC voltage sources from the transformer and needed three DC voltages, so it worked nicely. I could have run all three off the 24VAC source, but as mentioned in the article, there is an advantage to running the relay board (5VDC) off its own power source which is separate from the power supplying the Arduino.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    My Compool controller had three sets of leads from the transformer providing 24VAC, 18VAC and 10VAC. I routed the 10VAC into a rectifier and buck converter to provide 5VDC for the relay board. I routed the 18VAC into a rectifier and buck converter to provide 9VDC for the Arduino. I used the 24VAC direclty for the devices that require 24VAC and also routed it into a rectifier and buck converter to provide 20VDC to operate the heavier relays. I don't recall how I determined which pairs of wires were providing each of these voltages. I think there was a circuit diagram on the inside of the Compool cover, that might have shown the different voltages. Otherwise, use a multimeter set to AC to measure each possible combination and see which show nonzero voltage.I don't have a patreon acco…

    see more »

    My Compool controller had three sets of leads from the transformer providing 24VAC, 18VAC and 10VAC. I routed the 10VAC into a rectifier and buck converter to provide 5VDC for the relay board. I routed the 18VAC into a rectifier and buck converter to provide 9VDC for the Arduino. I used the 24VAC direclty for the devices that require 24VAC and also routed it into a rectifier and buck converter to provide 20VDC to operate the heavier relays. I don't recall how I determined which pairs of wires were providing each of these voltages. I think there was a circuit diagram on the inside of the Compool cover, that might have shown the different voltages. Otherwise, use a multimeter set to AC to measure each possible combination and see which show nonzero voltage.I don't have a patreon account but thanks for the offer! And do share your UI code - I am obviously far from a UI/UX designer myself!

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Hi. I used DB107 full wave rectifiers. Very simple, two pins in for AC, two pins out for DC, then into the 1mF (1000 microfarad) electrolytic capacitor to smooth the output and finally into the buck converter. Pretty much any full wave rectifier should work, not critical at all!

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    That's a good point, you probably want to turn on the dump solenoid only if the high water switch has been on for a while. You could create a function for the Arduino that is called each time through the main loop to check it. There is an Arduino function millis() that returns the elapsed time since the program started running that you can use to measure time for the delay. You could do that on the Arduino side and then either send a message to the Raspberry Pi to handle it, or turn on the dump solenoid directly from the Arduino.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    You would indeed need more than one byte. It appears the function Serial.readBytes() would be what you want. Instead of this:char ch = Serial.read();you would do this:char buf[2];size_t num = Serial.readBytes(buf, 2);i.e., create a 2 byte array called "buf" to read into, then try to read two bytes into it and return the number of bytes read in the variable "num". You should check num is equal to 2 because if it is not, you don't know which byte you've read.Then you can modify the code which reads bits to do one byte at a time (notice the array index in [] brackets).digitalWrite(P_PUMP, bitRead(ch[0], B_PUMP)); digitalWrite(P_LIGHT, bitRead(ch[0], B_LIGHT)); digitalWrite(P_BLOWER, bitRead(ch[0], B_BLOWER)); digitalWrite(P_INTAKE, bitRead(ch[0], B_INTAKE)); digita…

    see more »

    You would indeed need more than one byte. It appears the function Serial.readBytes() would be what you want. Instead of this:char ch = Serial.read();you would do this:char buf[2];size_t num = Serial.readBytes(buf, 2);i.e., create a 2 byte array called "buf" to read into, then try to read two bytes into it and return the number of bytes read in the variable "num". You should check num is equal to 2 because if it is not, you don't know which byte you've read.Then you can modify the code which reads bits to do one byte at a time (notice the array index in [] brackets).digitalWrite(P_PUMP, bitRead(ch[0], B_PUMP)); digitalWrite(P_LIGHT, bitRead(ch[0], B_LIGHT)); digitalWrite(P_BLOWER, bitRead(ch[0], B_BLOWER)); digitalWrite(P_INTAKE, bitRead(ch[0], B_INTAKE)); digitalWrite(P_RETURN, bitRead(ch[0], B_RETURN)); digitalWrite(P_CLEANER, bitRead(ch[0], B_CLEANER)); digitalWrite(P_HEATER, bitRead(ch[0], B_HEATER)); digitalWrite(P_UNUSED7, bitRead(ch[0], B_UNUSED7));digitalWrite(P_HIGH_WATER, bitRead(ch[1], B_HIGH_WATER));digitalWrite(P_LOW_WATER, bitRead(ch[1], B_LOW_WATER));In this case, you would define the new bits like this:#define B_HIGH_WATER 0#define B_LOW_WATER 1i.e., as the first two bits in the second byte. There are eight bits in a byte numbered from 0 to 7, so if you try to access bit 8 of a byte, you will get nothing. You need to access bits 0 through 7 of the first byte, then bits 0 through 7 of the second byte.On the Raspberry Pi side, you have to do similar. There is this code:var buf = Buffer.alloc(1);buf[0] = 0;Change that tovar buf = Buffer.alloc(2);buf[0] = 0;buf[1] = 0;and define the bits on the Raspberry Pi side to match the Arduino. For example, I used bits zero and one for high water and low water on the Arduino, so the corresponding definition on the R Pi side would be:const bHighWater = 0;const bLowWater = 1;and you would use those to set the bits in buf[1].

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    It sounds like it would essentially be two parallel circuits (one for high water level, one for low water level) with three parts to each: (1) detect if the switch is closed, (2) trigger a relay, (3) operate a solenoid based on the relay setting.(1) For detecting if the switch is closed, you can use a free input on the Arduino. It would be similar to the thermistor, but simpler because instead of reading a voltage level, you're just detecting high or low. You'll probably just connect one wire to a free pin and the other to ground. Set the pin to be high when the switch is open, then when the switch is closed it will pull that pin low which you can detect. (2) The main loop of the Arduino program basically just checks several things repeatedly, so you can add a check of the pin for th…

    see more »

    It sounds like it would essentially be two parallel circuits (one for high water level, one for low water level) with three parts to each: (1) detect if the switch is closed, (2) trigger a relay, (3) operate a solenoid based on the relay setting.(1) For detecting if the switch is closed, you can use a free input on the Arduino. It would be similar to the thermistor, but simpler because instead of reading a voltage level, you're just detecting high or low. You'll probably just connect one wire to a free pin and the other to ground. Set the pin to be high when the switch is open, then when the switch is closed it will pull that pin low which you can detect. (2) The main loop of the Arduino program basically just checks several things repeatedly, so you can add a check of the pin for the water level switch to the main loop and add that to the data sent to the Pi. Then the Node Red code on the Pi can interpret that and send a message to the Arduino to trigger the relay for the solenoid and for the pump (since you mentioned that has to be turned on).(3) The load side of the relay needs to be supplied with whatever voltage it takes to operate the solenoid. Do all that for the high water level circuit and then the low level circuit should be almost identical.Does that help?

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    OK. Are you still getting that same error about receiving type string instead of binary? In the serial port settings, can you change from delivering a string to delivering binary buffers and see if the error changes?

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I think you will have trouble with your code. The way the communication works is it uses the 8 bits in a byte to correspond to the 8 relays on the board. The bits are numbered 0 through 7. The Raspberry Pi code sets them, the Arduino reads them. Imagine the 8 bits like this:{{{-----------------| | | | | |x| |x|----------------- 7 6 5 4 3 2 1 0}}}where the 'x' in bits 0 and 2 means the corresponding two relays should be on and the other bits blank mean the other relays should off. The bitRead functions in the Arduino code read the bits and set the relays by setting the pins to high or low to turn on or off the relays.The type 'char' is used because it is one byte in size, but the byte cannot be interpreted as a printable character like '1' or '2' as your code assumes. For example, set…

    see more »

    I think you will have trouble with your code. The way the communication works is it uses the 8 bits in a byte to correspond to the 8 relays on the board. The bits are numbered 0 through 7. The Raspberry Pi code sets them, the Arduino reads them. Imagine the 8 bits like this:{{{-----------------| | | | | |x| |x|----------------- 7 6 5 4 3 2 1 0}}}where the 'x' in bits 0 and 2 means the corresponding two relays should be on and the other bits blank mean the other relays should off. The bitRead functions in the Arduino code read the bits and set the relays by setting the pins to high or low to turn on or off the relays.The type 'char' is used because it is one byte in size, but the byte cannot be interpreted as a printable character like '1' or '2' as your code assumes. For example, setting bit 0 in a byte with all others off is not the printable character '1', it's actually Ctrl-A; the ASCII code for '1' is 49. The second issue is your code looks like it will only set one relay at a time rather than all the bits that should be set.I suggest you revert to the bitRead code. How about putting some debug code in the loop() function to set two of the relays on for three seconds, then off for three seconds (see below). If that works, then you know the Arduino can successfully control the relays. Then you can try debugging the serialEvent() function which will require the Raspberry Pi to send some data over the serial line to the Arduino. On the Raspberry Pi side, you can add a debug node to the output of RelaySetter so you can see what byte values are being sent to the Arduino. On the Arduino side, you could add a Serial.println(ch) to the serialEvent() function to see what the value is before the relays are set.{{{void loop() { // Read water temp and air temp in turn and write status // of each to serial port. int8_t val; //val = getTemp(P_H2O); //Serial.print("H2O:");Serial.println(val); //val = getTemp(P_AIR); //Serial.print("AIR:");Serial.println(val); //delay(2000); // DEBUGGING CODE digitalWrite(P_INTAKE, 0); digitalWrite(P_POOLLIGHT, 0); delay(3000); digitalWrite(P_INTAKE, 1); digitalWrite(P_POOLLIGHT, 1); delay(3000);}}}}

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I'm not sure what you mean by a "manual file" but it sounds like you are working backwards from the relays which is a good approach. You could create a program for the Arduino that just cycles a relay on and off every five seconds to make sure the Arduino is working OK, then test the connection from Raspberry Pi to Arduino, etc. Also, can you set up a test like Step 9? The Micro seems very similar to the Nano, so I don't expect any issues due to that difference.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I see, thanks for checking. It looks like that additional field wouldn't impact this, but it is good to know we are talking about different versions.Seeing this image reminds me of one more thing to check: there are several choices for the serial port. Can you check that it is set to the one that is actually being used by your Raspberry Pi to communicate with the Arduino? On mine, it lists AMA0, S0 and USB0 and mine works with USB0.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Please check the following in Node Red. There is a node called ArduinoSerialSet in the flow. Double click on it, then it will bring up a screen with two fields, SerialPort and Name. To the right of SerialPort is an edit button (picture of a pencil). Click that to open up a screen with all the settings for the serial port. It should look like the attached. I'm thinking the "deliver ascii strings" might be set to "deliver binary buffers". Let me know what you find. It's possible something changed about the default settings for the serial port in node red compared to what they were when I wrote this Instructable.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Step 6: Arduino and Thermistors has an Arduino sketch attached called PoolControl.ino which you can download.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    I'm sorry you're having trouble! Did you modify the code at all? If so, can you post it so we can take a look?

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Both of those ideas seem like they would work electronically. One of the temp sensors is in the water, so you'd have to figure out how to submerge the ds18b20. The analog temp sensor I used was designed to fit into a hole in one of the water pipes.One of my goals in writing this Instructable was to describe how the pool components work in detail so readers can consider alternatives for controlling the components. Have fun with your project!

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    It's possible to use only the Raspberry Pi, but converting analog thermistor output to the digital Raspberry Pi inputs and converting the Raspberry Pi 3V3 output to 5V for the relay board isn't any simpler than just using an Arduino which has 5V pins to do those tasks. See my reply to a comment by tgvoss a while ago.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Very nice! The "Heater Target Time" is a cool feature!It seems your setup is simpler than mine, just three relays, so the buttons on the controller will work fine. If you have a more complicated setup, the relays might not be independent (my setup described in the article is an example). If you don't set two or more in a coordinated fashion, you could end up emptying the spa and making the pump suck air, or similar. That was one reason I decided to use the web interface only and not add manual overrides.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Yes, you could power it from the USB rather than the VIN pin. To clarify, if you have voltage connected to the VIN pin, it will use that in preference to the USB power and it will regulate it to 5VDC. The regulation causes a voltage drop so VIN has to be 7VDC or better. If you do not have voltage connected to the VIN pin, it it uses the 5V directly from the USB port, i.e., it depends on the device supplying the USB power to regulate it, i.e., the Raspberry Pi.One reason to use a separate power supply is what rjmal mentioned in another comment - using serial lines rather than USB for serial communication (which would be necessary over longer distances). If you do that, then you will lose the 5V through the USB and have to power it through VIN.

    The temperature sensors need 5VDC from the Nano's 5VDC output. That output pin will only supply 5V if the input voltage for the Nano is at least 7VDC, so no, you cannot power the Nano with 5VDC. The recommended range is 7-12VDC, and the transformer input I used supplies 18VAC, so I could have used anything in the recommended range. I just picked 9VDC as a value in the middle of the range but it's not critical.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    Below is a super slimmed down version of RelaySetter.js. All it does is handle the light and blower switch in the Node-Red flow. The Node-Red Dashboard switch node sets the flow to on or off, this code reads it and sends it to the Arduino. This is about the simplest code possible to send messages from Node-Red to the Arduino.const setBit = (num, position) => { let mask = 1 << position; return num | mask;};const clearBit = (num, position) => { let mask = 1 << position; return num & ~mask;};const bLight = 1;const bBlower = 2;var buf = Buffer.alloc(1);buf[0] = 0;buf[0] = (flow.get("LightOnOff") ? setBit(buf[0], bLight) : clearBit(buf[0], bLight));buf[0] = (flow.get("BlowerOnOff") ? setBit(buf[0], bBlower) : clearBit(buf[0], bBlower));msg.pay…

    see more »

    Below is a super slimmed down version of RelaySetter.js. All it does is handle the light and blower switch in the Node-Red flow. The Node-Red Dashboard switch node sets the flow to on or off, this code reads it and sends it to the Arduino. This is about the simplest code possible to send messages from Node-Red to the Arduino.const setBit = (num, position) => { let mask = 1 << position; return num | mask;};const clearBit = (num, position) => { let mask = 1 << position; return num & ~mask;};const bLight = 1;const bBlower = 2;var buf = Buffer.alloc(1);buf[0] = 0;buf[0] = (flow.get("LightOnOff") ? setBit(buf[0], bLight) : clearBit(buf[0], bLight));buf[0] = (flow.get("BlowerOnOff") ? setBit(buf[0], bBlower) : clearBit(buf[0], bBlower));msg.payload = buf;return msg;

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    The variables that begin with a lower case 'b' in the RelaySetter node, e.g., bPump, bLight have number that correspond to the constants in the Arduino sketch PoolControl.ino that start with "B_", e.g., B_PUMP, B_LIGHT. The constants in PoolControl.ino that start with "P_" are pin numbers on the Arduino. I named them to correspond. So, make sure bPump and B_PUMP have the same number, then set P_PUMP to the pin number on the Arduino that is connected to the pump relay, then your flow will control that relay. Similar for all the others. That should help with your always turning on/off the same relay issue.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    The mechanism used for sending messages is the serial connection, so Serial.read() is the main function on the Arduino side and ArduinoSerialSet is the flow node that sends messages from the Pi to the Arduino.The Nano is already pretty dumb, it mostly just sets pins to high or low. The exception is the temperature sensors which read analog voltages, convert them to temperatures, then send them over the serial line to the Pi. To see what is needed to just accept commands, try this: delete the function getTemp() and remove all code from the loop() function except "delay(2000)". What will be left is just code that sets the pins to whatever is sent from the Pi. On the Pi side, the flow connected to ArduinoSerialGet is what reads that temperature info, so removing that will leave…

    see more »

    The mechanism used for sending messages is the serial connection, so Serial.read() is the main function on the Arduino side and ArduinoSerialSet is the flow node that sends messages from the Pi to the Arduino.The Nano is already pretty dumb, it mostly just sets pins to high or low. The exception is the temperature sensors which read analog voltages, convert them to temperatures, then send them over the serial line to the Pi. To see what is needed to just accept commands, try this: delete the function getTemp() and remove all code from the loop() function except "delay(2000)". What will be left is just code that sets the pins to whatever is sent from the Pi. On the Pi side, the flow connected to ArduinoSerialGet is what reads that temperature info, so removing that will leave you with flows that send commands from Node-Red to the Nano to turn on and off various things.

    View Instructable »
  • Replace Your Pool and Spa Controller With Raspberry Pi, Arduino, Node Red

    You could modify the Node-Red flow to write the current state to a file (see the File node in the Storage section), then read it upon startup. I didn't bother doing that because it's fairly easy to modify the default values to be what you want and I rarely need to restart or re-deploy. The same applies to the schedule - rather than implement something to read the schedule config from somewhere, I just change the code and redeploy if I want a different schedule (e.g., summer vs. winter).In my article, I said you can access the flow by using a browser on the Pi set to http://localhost:1880, but you can also access it from another computer by substituting the hostname or the IP address for "localhost". That means you can modify the code and redeploy without shutting down or disc…

    see more »

    You could modify the Node-Red flow to write the current state to a file (see the File node in the Storage section), then read it upon startup. I didn't bother doing that because it's fairly easy to modify the default values to be what you want and I rarely need to restart or re-deploy. The same applies to the schedule - rather than implement something to read the schedule config from somewhere, I just change the code and redeploy if I want a different schedule (e.g., summer vs. winter).In my article, I said you can access the flow by using a browser on the Pi set to http://localhost:1880, but you can also access it from another computer by substituting the hostname or the IP address for "localhost". That means you can modify the code and redeploy without shutting down or disconnecting the Pi. Easy!

    I still think this is a bug in Node-Red Dashboard. I tested it by pulling up the page and setting it to Schedule. The blower and cleaner controls were disabled. I let it go through the whole schedule, which starts with the spa on, then the pool and cleaner. The blower and cleaner controls stayed disabled and I could not make them turn on. However, if I refresh the page, those controls become enabled even though they have been set in the code to disabled. The same occurs if you pull up the web page on another device. I will see if anybody has reported such a bug in Node-Red Dashboard. Nothing in the code enables (or disables) any controls, so it is not a logic problem there.

    View Instructable »
  • Thanks for the update. I can reproduce that. I'll take a look at the flow and figure out how to lock it out in schedule mode. Good catch!

    View Instructable »
  • The blower is locked out in pool mode. There are two templates triggered when the mode is set to Pool. One is called msgpayloadfalse and that turns off the blower if it happens to be on. The other is called msgenabledfalse and that disables the blower so it cannot be turned on again. A template called msgenabledtrue is triggered when the mode is set to Spa.I have noticed a bug in Node-Red Dashboard where if you have it running on two devices, then it doesn't always update both dashboards when you change state on one. You could change the setting on one dashboard from Spa to Pool and it would not show the blower as disabled on the other dashboard. Is it possible that is what you saw?

    View Instructable »
  • Thanks, that's a very detailed and thorough article!

    View Instructable »
  • Thanks for the update, that's good to know. As mentioned in the article, my Pi is inside and the Arduino in the pool controller box. I'm sure it gets over 100F in that box and the Arduino seems to work fine in such temperatures.

    View Instructable »
  • Try switching the thermistors (assuming the air temp sensor is working). If the behavior follows the thermistor, then it's bad, otherwise there is something wrong with the rest of the circuitry. Double check the three connections (5V, GND and Arduino pin) and how the 10k resistor and thermistor are connected together.

    View Instructable »
  • The Arduino documentation says, "All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB." So it sounds like no code modification would be required.My cable is right at 15' and it has not had a similar problem while running continuously since prior to publishing this Instructable. I did consider using the RX/TX/GND pins on the Arduino. I read somewhere that someone was able to communicate 40m this way. Some considerations:* The Arduino is 5V, the Pi is 3.3V. You need to do something to convert the levels. You could use an FTDI USB to TTL on the Raspberry Pi side set to 5V to accomplish this.* You could use Cat5 cable for the RX/TX connection, but I rea…

    see more »

    The Arduino documentation says, "All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB." So it sounds like no code modification would be required.My cable is right at 15' and it has not had a similar problem while running continuously since prior to publishing this Instructable. I did consider using the RX/TX/GND pins on the Arduino. I read somewhere that someone was able to communicate 40m this way. Some considerations:* The Arduino is 5V, the Pi is 3.3V. You need to do something to convert the levels. You could use an FTDI USB to TTL on the Raspberry Pi side set to 5V to accomplish this.* You could use Cat5 cable for the RX/TX connection, but I read it would be best to run RX/GND on one pair and TX/GND on another pair to avoid interference. I also considered running 5V/GND on a third pair to power the RPi from the Arduino so I wouldn't have to have a separate power supply for the RPi.* You can use a lower baud rate to make it more reliable. There's not a lot of data being sent back and forth, so speed should not be an issue.I haven't done the above since my setup with USB doesn't have any issues, but if you get it working, please let me know!

    View Instructable »
  • I suggest you double check the relay and actuator connections. One leg of 24VAC should go directly to the black wire of the actuators. The other leg of 24VAC should go to the middle connection of each relay. The outer two connections of each relay should go to the red and white wires of the valve actuators. I misconnected my relays initially because something about the labeling confused me. On my relay board, the middle is the common connection and the two outer connections are the O/C connections, but your relay board might differ.Regarding debugging in general, you could disconnect all voltage from the outputs of the relays and use an ohmeter to check that the relays are doing what you think they should be doing. Then, after connecting the outputs, you can use a voltmeter to see …

    see more »

    I suggest you double check the relay and actuator connections. One leg of 24VAC should go directly to the black wire of the actuators. The other leg of 24VAC should go to the middle connection of each relay. The outer two connections of each relay should go to the red and white wires of the valve actuators. I misconnected my relays initially because something about the labeling confused me. On my relay board, the middle is the common connection and the two outer connections are the O/C connections, but your relay board might differ.Regarding debugging in general, you could disconnect all voltage from the outputs of the relays and use an ohmeter to check that the relays are doing what you think they should be doing. Then, after connecting the outputs, you can use a voltmeter to see if 24/28 VAC is being delivered across the expected outputs (black&red on the actuator when the relay is in one state and black&white when in the other state).I don't know why the power would cycle on and off.

    Yes, the temperature sensors are wired as voltage dividers and will generate an analog input, so you will need to use an analog to digital converter (ADC) with a Raspberry Pi. You will also need to write the equivalent of the Arduino code that converts the voltage (i.e., the digital equivalent that the ADC generates) to a temperature. I had experience with Arduinos before this project so I found it simpler to just grab the code online and effectively use an Arduino as the ADC for the temperature sensors as well as be the relay controller.

    Did you mean Pentair 520272 rather than 502272? The 520272 is actually what I purchased and used in this project as the water temperature sensor, so the circuitry in the article is exactly what you would use for that.

    View Instructable »
  • I updated the schematic, it was showing pins D6-D12 connected to the relays, but the article and Arduino code all reference pins D5-D11 for the relays so that is what the schematic shows now.

    The Arduino code has a setup() function that explicitly sets all relays off and the NodeRed flow should start in Off mode as well, so the behavior you are seeing is unexpected. Maybe still some issues with NO/NC?

    View Instructable »
  • I updated the article with an explanation of how the times in the code are interpreted in schedule mode (bottom line - you guessed right). My pool also has a single pump and uses valve changes for the different modes. If the original code worked with your pool and spa, then the new code will, too. In fact, I would suggest you make sure everything works with the simpler original code and then update to use the new code.

    View Instructable »
  • I just updated the article with an additional step where I describe the schedule and freeze modes which I added and also attached the corresponding NodeRed flow. Enjoy!

    View Instructable »
  • The sensors (thermistors) are just variable resistors and the circuit for each sensor is a voltage divider. First, make sure the ground connection on each thermistor is electrically connected to the ground of the Arduino. Then, I recommend you check two voltages: (1) between the end of the 10K resistor not attached to the thermistor and ground, and (2) between the other end of the resistor attached the thermistor and ground. You should get 5V for (1) and something less than 5V and greater than zero for (2). If that works, then dunk the thermistor in a cup of ice water and take measurement (2) again; it should show a different voltage because the change in temperature should change the resistance of the thermistor and therefore the voltage across it. If all that works, then the thermi…

    see more »

    The sensors (thermistors) are just variable resistors and the circuit for each sensor is a voltage divider. First, make sure the ground connection on each thermistor is electrically connected to the ground of the Arduino. Then, I recommend you check two voltages: (1) between the end of the 10K resistor not attached to the thermistor and ground, and (2) between the other end of the resistor attached the thermistor and ground. You should get 5V for (1) and something less than 5V and greater than zero for (2). If that works, then dunk the thermistor in a cup of ice water and take measurement (2) again; it should show a different voltage because the change in temperature should change the resistance of the thermistor and therefore the voltage across it. If all that works, then the thermistor and voltage divider circuit is fine and it is something about the coding or wiring to pin A0 or A1 that is the problem. i hope that helps!

    View Instructable »
  • I have not implemented it yet (because it got warmer!). The basic idea is to turn on at 36 and turn off at 38, so as it gets colder and possibly fluctuates between 36 and 37, it will turn on and stay on, then as it gets warmer and fluctuates between 37 and 38, it will turn off and stay off.

    View Instructable »
  • Debugging electronics is a lot like debugging a program. Break it down to the simplest possible test case, check the inputs, test each component separately, etc. I highly recommend you build the test setup described in the article. You can pull the Pi and Nano from the working test setup and plug it into the actual setup with literally no changes.

    View Instructable »
  • The relays will be off if (1) there is power to the board and the control pins are supplied with 5V, (2) there is power to the board and the control pins are disconnected, (3) there is no power to the board. The relays only go on if there is power to the board and the pins are pulled low (to 0V). Note that disconnecting a pin is not the same as pulling it low to 0V (from your question it sounds like perhaps you thought it was). I tested a spare relay board before writing the above to confirm it works as described.In this project, I connected all the relays such that if they are all off, it is a safe configuration, i.e., the pump and all motors are off, the actuators are in a sensible state, etc., even if all those devices have mains power.Actually, "off" and "on" is…

    see more »

    The relays will be off if (1) there is power to the board and the control pins are supplied with 5V, (2) there is power to the board and the control pins are disconnected, (3) there is no power to the board. The relays only go on if there is power to the board and the pins are pulled low (to 0V). Note that disconnecting a pin is not the same as pulling it low to 0V (from your question it sounds like perhaps you thought it was). I tested a spare relay board before writing the above to confirm it works as described.In this project, I connected all the relays such that if they are all off, it is a safe configuration, i.e., the pump and all motors are off, the actuators are in a sensible state, etc., even if all those devices have mains power.Actually, "off" and "on" is a bit inaccurate, these are single pole double throw relays, so one side or the other is always connected. "Off" in this context means the state it is in when there is no power applied to the board.Hope that helps!

    View Instructable »
  • Yes, it is still working and reliable. I added a schedule mode and a freeze mode to the Node Red program since the article. I also switched to a Pi Zero W which was completely seamless and it is cheaper ($10 vs. $35). For added reliability, I have backups - several extra Arduinos that I could flash with the sketches and substitute if the current one broke, and I have extra SD cards for the Pi with identical images to the one running the system as well as a spare Pi 3 I could use in case those components got corrupted or broke. I replaced a Compool LX3400 controller.

    View Instructable »
  • I'm glad you're building your own controller based on my guide! I actually did add a freeze mode and schedule since I wrote the article. I set it to turn on when the air temperature is 37 or below. I ran into an issue where when the temperature is right at 37, it seems to fluctuate so that the pump turns on, then off, then on, etc. I want to figure out how to fix that and then I'll post the result.

    View Instructable »
  • Thanks!

    Nice project, great pics. Step 7 mentions a schematic but I don't see one anywhere in the 'ible. Can you add it?

    View Instructable »
  • I see it on my profile now, but it didn't show up immediately after I clicked favorite on an Instructable for the first time. I spent quite a while looking up posts like this and searching every possible menu item on the site trying to find it.

    View Topic »
  • I can get to the "you" page by clicking the link below, but how do you get to that page from the home page, https://www.instructables.com ?

    View Topic »
  • A Pi could certainly handle the logic; it is not necessary to use an Arduino. An earlier comment by nessiemack talked about using just a Raspberry Pi. The reasons I used an Arduino/Pi combo instead of just a Pi are:1) The Arduino has analog inputs, the Pi does not, and I wanted to use analog thermistors. Options include using a digital thermistor, or getting an ADC for the Pi. I had about 10 Arduino Nanos that I bought for approximately $3 each, and I found multiple sketches online for the Arduino to convert the analog voltage from a thermistor to a number, so using an Arduino for this project made sense for me.2) I wanted the Pi inside my house because access to my home wifi is better inside and also because putting the Pi outside meant someone could take it, or use it to hack into m…

    see more »

    A Pi could certainly handle the logic; it is not necessary to use an Arduino. An earlier comment by nessiemack talked about using just a Raspberry Pi. The reasons I used an Arduino/Pi combo instead of just a Pi are:1) The Arduino has analog inputs, the Pi does not, and I wanted to use analog thermistors. Options include using a digital thermistor, or getting an ADC for the Pi. I had about 10 Arduino Nanos that I bought for approximately $3 each, and I found multiple sketches online for the Arduino to convert the analog voltage from a thermistor to a number, so using an Arduino for this project made sense for me.2) I wanted the Pi inside my house because access to my home wifi is better inside and also because putting the Pi outside meant someone could take it, or use it to hack into my home network. If it is inside, then communicating to the devices outside means either running a whole bunch of wires between the relay board and thermistors outside to the Pi inside, or having the Arduino outside and running just one USB cable from there to the Pi.One of my reasons for explaining how everything works was so readers would have the knowledge to explore alternatives methods of accomplishing the same goals, or apply the ideas to different situations - like using a Pi only instead of a Pi/Arduino combo if it makes more sense in your situation, or if you are more comfortable programming a Pi than an Arduino.

    View Instructable »
  • Hi, Steve. I updated the section that describes how a heater works with more details and added a paragraph in the troubleshooting section about service and installation manuals as well. I hope that helps!

    View Instructable »
  • Fixed the schematic.

    Good catch, thanks! I'll fix the schematic. In the meantime, for anyone building this, the two '~' symbols on the rectifier are the AC input and the '+' and '-' outputs should be connected to the '+' and '-' of the capacitor and buck converter inputs.

    View Instructable »
  • Go for it! Node-RED has a couple of node types that might be helpful to you. A Timestamp node can perform a task at regular intervals and an Inject node can perform an action at a specific time (turn on at time A and turn off at time B). The valve actuators on my system are add-ons to otherwise manual valves - maybe there is some kind of add-on electric actuator for your type of valve.

    View Instructable »
  • The valve actuators and heater are 24VAC, not 24VDC. In the picture where I showed the three position switch on the actuator, you can see the label which says 24VAC. I've had two different brands of valve actuators and two different brands of heaters over the years that worked with the old controller board. That board provided 24VAC for each and there was no way to switch it to any other voltage, so I do believe 24VAC is normal for pool systems.

    I did use an actual USB cable and you are absolutely correct about the length limitation. The maximum is about 16ft and I have a 15ft cable. An alternative would be to use the serial pins on the Arduino for serial communication; I ran an extra cable which I could use for that purpose.

    View Instructable »