Waterheater control



  • Hi everyone,

    After quite a bit of delay I have restarted my water heater project to connect my Paloma Waterheater to Vera.

    The waterheater has 1x on/off push button, 1x temp up push button and 1x temp down push button.
    In addition the heater has a status LED which shows whether the heater is on or off.

    I have hacked the control panel of the heater and wired a 5v reed relay to each of the buttons.
    High on the relay will bridge the push button and "simulate" a button press.

    Arduino Pins 3, 4 and 5 are used for each of the relays with the other end of the spool connected to ground.
    The LED is wired to Pin 6 which I want to use as an input - high >2V = ON state, low <2V = Off state. The LED voltage I get from the board looks like it is stepped down (If I connect a reed relay the relay flip flops very fast).

    I tried around to get the code working based on the relay example posted on this page but I can't figure out how to adapt it as the relay code only would allow for m

    Issues I have:

    1. The relay code switches does not simulate a push button. As I only need the relay to pull for a short period of time - else the control panel will freaks out - how do I send a high impulse only on the respective pins (3-5)?

    2. I would need the state - high or low - of Pin6 to update the button status in Vera for Pin 3 only. High - state = on, low - state = off without triggering the relay itself. This is to indicate in vera whether the heater is on or off in case someone pushed the button on the panel itself.

    3. Each button will show up as a separate light switch in Vera - I assume that a new "type" and vera plugin would be required to have the on/off, temp up and down buttons all on one single device?

    Could someone help me with the code for this?
    Here is what I have so far (which is not much at all...):

     // Paloma Waterheater Control based on mysensors.org Relay exmaple
    
       #include <MySensor.h>
       #include <SPI.h>
    
       #define RELAY_1  3  // Arduino Digital I/O pin number for Water Heater On/Off push Button
       #define RELAY_2  4  // Arduino Digital I/O pin number for Water Temp Up push Button
      #define RELAY_3  5  // Arduino Digital I/O pin number for Water Temp Down push Button
      #define NUMBER_OF_RELAYS 3 // Total number of attached relays
     #define LED_PIN  6  // Arduino Digital I/O pin number for Heater LED On/Off State
     #define RELAY_ON 1  // GPIO value to write to turn on attached relay
     #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
     MySensor gw;
    
     void setup()  
     {    
          // Initialize library and add callback for incoming messages
          gw.begin(incomingMessage, AUTO, true);
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("Relay", "1.0");
    
          // Setup the LED
          pinMode(LED_PIN,INPUT);
          // Activate internal pull-up
          digitalWrite(LED_PIN,HIGH);
    
         // Fetch relay status
         for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
         // Register all sensors to gw (they will be created as child devices)
        gw.present(sensor, S_LIGHT);
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
     } 
     }
    
    
    void loop() 
    {
       // Alway process incoming messages whenever possible
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
    // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         gw.saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
         } 
     }
    

    Thanks !


  • Admin

    To create a pulse you could do something like this.

    
    void pulsePin (uint8_t pin, int pulseLength) {
         pinMode(pin,OUTPUT);
         digitalWrite(pin,HIGH);
         delay(pulseLength);
         digitalWrite(pin,LOW);
    }
    
    
    ```

  • Hero Member

    @idefix said:

    Hi everyone,

    After quite a bit of delay I have restarted my water heater project to connect my Paloma Waterheater to Vera.

    The waterheater has 1x on/off push button, 1x temp up push button and 1x temp down push button.
    In addition the heater has a status LED which shows whether the heater is on or off.

    I have hacked the control panel of the heater and wired a 5v reed relay to each of the buttons.
    High on the relay will bridge the push button and "simulate" a button press.

    Arduino Pins 3, 4 and 5 are used for each of the relays with the other end of the spool connected to ground.
    The LED is wired to Pin 6 which I want to use as an input - high >2V = ON state, low <2V = Off state. The LED voltage I get from the board looks like it is stepped down (If I connect a reed relay the relay flip flops very fast).

    I tried around to get the code working based on the relay example posted on this page but I can't figure out how to adapt it as the relay code only would allow for m

    Issues I have:

    1. The relay code switches does not simulate a push button. As I only need the relay to pull for a short period of time - else the control panel will freaks out - how do I send a high impulse only on the respective pins (3-5)?

    2. I would need the state - high or low - of Pin6 to update the button status in Vera for Pin 3 only. High - state = on, low - state = off without triggering the relay itself. This is to indicate in vera whether the heater is on or off in case someone pushed the button on the panel itself.

    3. Each button will show up as a separate light switch in Vera - I assume that a new "type" and vera plugin would be required to have the on/off, temp up and down buttons all on one single device?

    Could someone help me with the code for this?
    Here is what I have so far (which is not much at all...):
    Thanks !

    1. How are the reed relays wired into the WH control exactly.
    2. Have you determined why the WH control 'freeks out' on long relay activations? (#1 answer may answer this one)
    3. Do you have a volt meter to do some measurements on the control?


  • Hi Hek & ServiceXP,

    thanks for your replies.
    I will try - as soon as I have figured out how to get the basic script to work as I have very little Arduino expertise nor have I created a sensor from scratch before - the pulse code above.

    I believe the panel goes into some sort of programming mode if the power button is pressed continuously.
    In addition if I would keep it pressed via the relay, local input on the button itself would not work anymore as it is shorted out continuously. I'm basically simulating a button press by bridging the button with a relay in parallel to the original button.

    I will try and write some code up now (I found a heater example in the forum here but it was based on 1.3 so no idea how to get this to work with 1.4). Fingers crossed 🙂



  • Some hour later I have a "half baked" code ready.

    What it does:

    • Heater On/Off relay works
    • Temp UP relay works
    • Temp Down relay works

    What does not work:

    • I can't figure out how to read the LED voltage on the control panel and send the status heater on or off back to vera.

    Some more info on this:

    • The control panel is powered by 12V. I will use the same supply to power the Arduino so I should have shared ground and therefore - I think - I should be able to read the voltage of the power LED pin on the control panel directly, correct?
      The idea is to read the voltage (the control uses a pulse to step down the main voltage to power the LED I believe as a reed relay will flip flop if connected directly to the LED) at the LED pin on the panel and, depending on the reading (>2v = on, <2v = off) send vera the on/off status.
      This will allow correct representation of the status on vera's side in case someone uses the push button on the panel to control the heater instead of vera and should avoid unknown toggle states.

    Below is my code. I have commented the voltage reading out of the loop. if it is enabled the board will not respond anymore.

    Quite dirt programming I'm afraid 😞

    Any help with this is highly appreciated !!
    Thanks !

          // Paloma Tankless Water Heater Script
          // Direct interface to control panel push buttons with reed relays as well as status check of panel power LED
          
          #include <MySensor.h>
          #include <SPI.h>
          #include <Bounce2.h>
          
          #define ID 1         // Set Sensor ID
          #define PWR_RLY  3   // Arduino Digital I/O pin number for the Power Button
          #define UP_RLY  4    // Arduino Digital I/O pin number for the Temp Up Button
          #define DWN_RLY  5   // Arduino Digital I/O pin number for the Temp Down Button
          
          #define PWR_LED  A0  // Arduino Analogue pin number for the Power LED
          
          #define RELAY_ON 1  // GPIO value to write to turn on attached relay
          #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
          
          MySensor gw;
          MyMessage msg(ID, V_HEATER_SW);
          
          int saveheatLvl = 0;   // save heat level data
          
          void setup()  
          {   
            // Initialize library and add callback for incoming messages
            gw.begin(incomingMessage,AUTO,true);
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("Water Heater", "1.0");
          
            // Register all sensors to gw (they will be created as child devices)
            gw.present(ID, S_HEATER);
            
            // Then set pins
              digitalWrite(PWR_RLY,RELAY_OFF);
              pinMode(PWR_RLY, OUTPUT);   
          
              digitalWrite(UP_RLY,RELAY_OFF);
              pinMode(UP_RLY, OUTPUT);   
              
              digitalWrite(DWN_RLY,RELAY_OFF);
              pinMode(DWN_RLY, OUTPUT);   
          }
          
          void loop ()
          {
           // Always process incoming messages whenever possible
           gw.process(); 
          
            // voltage ();    // if included will create a loop? and relays are not responding anymore
          }
          
          void voltage(){
            // Read LED voltage 
           int sensorValue = analogRead(PWR_LED);
           float voltage = sensorValue * (5.0 / 1023.0);
           delay (1);
           if (voltage == 5) {
               gw.send(msg.set("HeatOn"),true);    // check LED voltage and set Heat on if 5V detected
           }else{
               gw.send(msg.set("Off"),true);    // check LED voltage and set Off if <5V detected   
           }
          }
          
          void incomingMessage(const MyMessage &message) {
            // Check for Heater Switch Message
            if (message.type==V_HEATER_SW) {
              // Switch Heater On
              if (strncmp (message.data,"HeatOn",6) == 0){
                Serial.println("Switching Heater ON");
                digitalWrite(PWR_RLY,RELAY_ON);
                delay(500);
                digitalWrite(PWR_RLY,RELAY_OFF);
                gw.send(msg.set("HeatOn"),true);
              }
              
              // Switch Heater Off
              if (strncmp (message.data,"Off",3) == 0){
                Serial.println("Switching Heater OFF");
                digitalWrite(PWR_RLY,RELAY_ON);
                delay(500);
                digitalWrite(PWR_RLY,RELAY_OFF);
                gw.send(msg.set("Off"),true);
              }   
             } 
             
             if (message.type==V_HEATER) {
              // Check for Temperature Up/Down Message
              int heatLvl = atoi(message.data);
              
              // Check if new Temperature is higher than previous set point
              if ( heatLvl > saveheatLvl) {
                Serial.println("Increase Temperature");
                digitalWrite(UP_RLY,RELAY_ON);
                delay(500);
                digitalWrite(UP_RLY,RELAY_OFF);
                saveheatLvl = heatLvl;
                gw.send(msg.set(saveheatLvl),true); 
              }
              
              // Check if new Temperature is lower than previous set point
              if ( heatLvl < saveheatLvl) {
                Serial.println("Reduce Temperature");
                digitalWrite(DWN_RLY,RELAY_ON);
                delay(500);
                digitalWrite(DWN_RLY,RELAY_OFF);
                saveheatLvl = heatLvl;
                gw.send(msg.set(saveheatLvl),true); 
              }
             } 
             
          }

  • Hero Member

    @idefix

    Couple of thoughts:

    1. On the voltage function, I would incorporate a time component to only check that voltage every x minutes, and a value check (don't send if not changed) on the voltage reading. The way I see it written, you will end up spamming the gateway an locking up the Arduino in that function.

    2. Is there any way to incorporate a light sensor and place it on the back of the existing LED, that way you don't have to actually read the control voltage at all?

    3. I see the heat level synchronization being a problem.

    4. I would work on a design to isolate the two controls as much as possible. I would actually look to completely isolate them, again if possible. I don't know how expensive the control is for the water heater but if anything goes wrong with your Arduino hardware, it could take out your controller. If isolation is not possible, make sure you add plenty of protection.



  • Thanks,

    I was thinking of using a photo resistor as well but I think the LED does not shine through the board. Will give this another try on the weekend.

    As for the send info to gw code i used, any comments? Is it correct in the first place?

    Thanks


Log in to reply
 

Suggested Topics

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts