Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Heatpump controller

Heatpump controller

Scheduled Pinned Locked Moved Development
55 Posts 15 Posters 26.1k Views 11 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fredrik Carlsson
    wrote on last edited by Fredrik Carlsson
    #40

    Hello
    It would be nice to make it run on batteries, maybe with 10 seconds sleep, and then wake up only to check with gateway if there is a new command and then sleep again.

    I am building a pir sensor now based on 3*aa batteris running on 4,5 volt.I will ust use an LE33 step down directly after the battery pack to provide power to both sensebender+radio+pir. Dont know if that is the optimal way to do it but it should work

    1 Reply Last reply
    0
    • BR3NDAB Offline
      BR3NDAB Offline
      BR3NDA
      wrote on last edited by
      #41

      I have my heatpump mysensor working, and hooked up to Openhab.

      Arduino code here:

      #include <MySensor.h>
      #include <SPI.h>
      #include <Arduino.h>
      
      #include <PanasonicCKPHeatpumpIR.h>
      #include <PanasonicHeatpumpIR.h>
      
      #define POWER_ID 0
      #define MODE_ID 1
      #define FAN_ID 2
      #define TEMP_ID 3
      #define VDIR_ID 4
      #define HDIR_ID 5
      
      
      MySensor gw;
      MyMessage powerMsg(POWER_ID, V_STATUS); 
      MyMessage modeMsg(MODE_ID, V_HVAC_FLOW_STATE);
      MyMessage fanMsg(FAN_ID, V_PERCENTAGE);
      MyMessage tempMsg(TEMP_ID, V_TEMP);
      MyMessage vdirMsg(VDIR_ID, V_VAR1); 
      MyMessage hdirMsg(HDIR_ID, V_VAR2); 
      
      IRSenderPWM irSender(3);       // IR led on Arduino digital pin 3, using Arduino PWM
      
      HeatpumpIR *heatpumpIR = new PanasonicNKEHeatpumpIR();
      
      //Some global variables to hold the states
      int POWER_STATE;
      int TEMP_STATE;
      int FAN_STATE;
      int MODE_STATE;
      
      void setup()  
      {  
        gw.begin(incomingMessage, AUTO, false);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Heatpump", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        gw.present(POWER_ID, S_BINARY);
        gw.present(MODE_ID, S_HVAC);
        gw.present(FAN_ID, S_HVAC);
        gw.present(TEMP_ID, S_HVAC);
        gw.present(VDIR_ID, S_CUSTOM);
        gw.present(HDIR_ID, S_CUSTOM);
           
        // Load our values on start
        POWER_STATE = gw.loadState(POWER_ID);
        TEMP_STATE = gw.loadState(TEMP_ID);
        FAN_STATE = gw.loadState(FAN_ID);
        MODE_STATE = gw.loadState(MODE_ID);
        
        sendHeatpumpCommand();
      }
      
      void loop() {
        gw.process();
      } 
      
      void handlePowerMessage(bool newState) {
        if (newState) {
          POWER_STATE = POWER_ON;
        }
        else {
          POWER_STATE = POWER_OFF;
        }
        gw.saveState(POWER_ID, newState);
      }
      
      void handleModeMessge(int newMode) {
        switch(newMode) {    
          case 0:
            MODE_STATE = MODE_HEAT; break;
          case 1:
            MODE_STATE = MODE_COOL; break;
          case 2:
            MODE_STATE = MODE_AUTO; break;
          case 3:
            MODE_STATE = MODE_FAN; break;
           case 4:
            MODE_STATE = MODE_DRY; break;
        }
        MODE_STATE = newMode;
        gw.saveState(MODE_ID, newMode);
      }
      
      void handleFanMessage(int newFan) {
        if (newFan > 5) newFan=5;
        switch(newFan) {
          case 0:
            FAN_STATE = FAN_AUTO; break;
          case 1:
            FAN_STATE = FAN_1; break;
          case 2:
            FAN_STATE = FAN_2; break;
          case 3:
            FAN_STATE = FAN_3; break;
          case 4:
            FAN_STATE = FAN_4; break;
          case 5:
            FAN_STATE = FAN_5; break;
          default:
            FAN_STATE = FAN_AUTO; break;
        }
        FAN_STATE = newFan;
        gw.saveState(FAN_ID, newFan);
      }
      
      void handleTempMessage(int newTemp) {
        TEMP_STATE = newTemp;
        gw.saveState(TEMP_ID, newTemp);
      }
      
      void sendHeatpumpCommand() {
        Serial.println("Power = " + (String)POWER_STATE);
        Serial.println("Mode = " + (String)MODE_STATE);
        Serial.println("Fan = " + (String)FAN_STATE);
        Serial.println("Temp = " + (String)TEMP_STATE);
        heatpumpIR->send(irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO, HDIR_AUTO);
      }
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
      
         switch(message.sensor) {
          case POWER_ID: {
            bool newState = message.getBool();
            handlePowerMessage(newState);
            break;
          }
          case MODE_ID: {
            int newMode = message.getInt();
            handleModeMessge(newMode);
            break;
          }
          case FAN_ID: {
            int newFan = message.getInt();
            handleFanMessage(newFan);
            break;
          }
          case TEMP_ID: {
            int newTemp = message.getInt();
            handleTempMessage(newTemp);
            break;
          }
         }
        sendHeatpumpCommand();
      }
      

      Openhab items

      Switch	Power_HeatPump	"Heatpump on/off" <aircon>
      Number	Mode_HeatPump	"Heatpump mode"
      Number	Fan_HeatPump	"Heatpump fan" <airing>
      Number	Temp_HeatPump	"Heatpump temperature [%d C]"	<temperature>
      String	VDir_HeatPump	"vertical"
      String	HDir_HeatPump	"horizontal"
      

      Openhab sitemap

      sitemap heatpump label="Heatpump" {
        Frame {
          Switch item=Power_HeatPump
          Selection item=Mode_HeatPump mappings=[0="heat", 1="cool", 2="auto", 3="fan", 4="dry"]
          Selection item=Fan_HeatPump mappings=[0="auto", 1="Level 1", 2="Level 2", 3="Level 3", 4="Level 4", 5="Level 5"]
          Setpoint item=Temp_HeatPump minValue=10 maxValue=30 step=1
          Text item=VDir_HeatPump
          Text item=HDir_HeatPump
        }
      }
      

      Openhab rules

      val org.eclipse.xtext.xbase.lib.Functions$Function4 numberOperation = [
          org.openhab.core.library.items.NumberItem numberItem, 
          org.openhab.core.library.items.StringItem arduinoItem, 
          String arduinoDevMap,
          Integer subType|
          logInfo("number", "Sending number message to mysensors node")
          var Integer state = numberItem.state
          logInfo("mysensors", "Function: numberOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state )
          arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
      ]
      
      //switch function
      val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [
          org.openhab.core.library.items.SwitchItem relayItem, 
          org.openhab.core.library.items.StringItem arduinoItem, 
          String arduinoDevMap,
          Integer subType|
          logInfo("switch", "Sending switch message to mysensors node")
          
          var Integer state = 0
          if (relayItem.state == OFF) {
              state = 0 
          }
          else {
              state = 1
          }
          logInfo("mysensors", "Function: switchOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state )
          arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
      ]
      
      
      
      
      rule "Heatpump on"
      when
          Item Power_HeatPump received command
      then
          switchOperation.apply(Power_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Power_HeatPump"),  V_STATUS)         
      end 
      
      rule "Heatpump mode"
      when
          Item Mode_HeatPump received update
      then
          numberOperation.apply(Mode_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Mode_HeatPump"),  V_VAR1)         
      end 
      
      
      rule "Heatpump temp"
      when
          Item Temp_HeatPump received command
      then
          numberOperation.apply(Temp_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Temp_HeatPump"),  V_TEMP)         
      end 
      
      rule "heatpump fan"
      when
          Item Fan_HeatPump received command
      then
          numberOperation.apply(Fan_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Fan_HeatPump"),  V_PERCENTAGE)         
      end 
      
      1 Reply Last reply
      2
      • T ToniA

        In live in Finland...

        I now have the HeatpumpIR working together with Domoticz, so that I can also define which commands to send from Domoticz. And yes, 24 bits is plenty enough :)

        https://github.com/ToniA/arduino-heatpumpir/tree/master/examples/MySensorsNode

        @johnr, do you happen to have an infrared receiver module? If you do, I could assist you in decoding the protocol. This is how I for example got the Mitsubishi protocol decoded, I've never had a Mitsubishi remote controller myself...

        SGiS Offline
        SGiS Offline
        SGi
        wrote on last edited by
        #42

        @ToniA Hi, do you have a guide on how to set up Domoticz with this example? I understand enough about mysensors and domoticz to be dangerous but i dont get how Domoticz can send the right command....

        bjacobseB 1 Reply Last reply
        0
        • T Offline
          T Offline
          ToniA
          wrote on last edited by
          #43

          Take a look at this topic on the Domoticz forum: http://www.domoticz.com/forum/viewtopic.php?f=34&t=8751

          M 1 Reply Last reply
          0
          • SGiS SGi

            @ToniA Hi, do you have a guide on how to set up Domoticz with this example? I understand enough about mysensors and domoticz to be dangerous but i dont get how Domoticz can send the right command....

            bjacobseB Offline
            bjacobseB Offline
            bjacobse
            wrote on last edited by
            #44

            @SGi
            Hi,
            I have created the wiki:
            https://www.domoticz.com/wiki/AC_/_heatpumpIR

            Everything is based in Toni's great effort :-)
            I also first used the mysensors Arduino, but since I am still using "old" mysensors ver 1.5.4 (And currently I don't have time to upgrade to latest and greatest, which support text based commands)
            Then I have taken same approach as Toni and use Wemos D1 Mini Pro that uses HTTP or MQTT wifi

            gohanG 1 Reply Last reply
            0
            • T ToniA

              Take a look at this topic on the Domoticz forum: http://www.domoticz.com/forum/viewtopic.php?f=34&t=8751

              M Offline
              M Offline
              moskovskiy82
              wrote on last edited by moskovskiy82
              #45

              @ToniA

              Thanks for the library it's great. I can also confirm that it works with Fujitsu remote AR-REB1E out of the box.

              Trying to integrate this into HomeAssistant and just do not know where to start. Is there any example how to post a whole string of commands for the air cond via mysensors-MQTT?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                moskovskiy82
                wrote on last edited by
                #46

                So nobody is using it this with MQTT gateway?

                bjacobseB 1 Reply Last reply
                0
                • bjacobseB bjacobse

                  @SGi
                  Hi,
                  I have created the wiki:
                  https://www.domoticz.com/wiki/AC_/_heatpumpIR

                  Everything is based in Toni's great effort :-)
                  I also first used the mysensors Arduino, but since I am still using "old" mysensors ver 1.5.4 (And currently I don't have time to upgrade to latest and greatest, which support text based commands)
                  Then I have taken same approach as Toni and use Wemos D1 Mini Pro that uses HTTP or MQTT wifi

                  gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #47

                  @bjacobse if I have a new Daikin heat pump with a newer remote that is not in the library, I guess I'm out of luck, right?

                  bjacobseB 1 Reply Last reply
                  0
                  • M moskovskiy82

                    So nobody is using it this with MQTT gateway?

                    bjacobseB Offline
                    bjacobseB Offline
                    bjacobse
                    wrote on last edited by
                    #48

                    @moskovskiy82
                    hi, I'm not using the MQTT with mysensors
                    I think you should direct your questions to a HomeAssistant forum.
                    My setup uses Wemos D1 Mini Pro and Domoticz

                    M 1 Reply Last reply
                    0
                    • gohanG gohan

                      @bjacobse if I have a new Daikin heat pump with a newer remote that is not in the library, I guess I'm out of luck, right?

                      bjacobseB Offline
                      bjacobseB Offline
                      bjacobse
                      wrote on last edited by
                      #49

                      @gohan
                      Please use the github for heatpump to ask you question, as I assume that Toni mostly is checking that. It seems that there 2 different Daikin heatpumps supported

                      https://github.com/ToniA/arduino-heatpumpir

                      1 Reply Last reply
                      0
                      • bjacobseB bjacobse

                        @moskovskiy82
                        hi, I'm not using the MQTT with mysensors
                        I think you should direct your questions to a HomeAssistant forum.
                        My setup uses Wemos D1 Mini Pro and Domoticz

                        M Offline
                        M Offline
                        moskovskiy82
                        wrote on last edited by
                        #50

                        @bjacobse Can you elaborate a little more on how you wired things up?
                        Also how you combined the libs and compiled everything for easyESP?
                        Have a sonoff with easyESP and docs are not that clear how to that stuff

                        bjacobseB 1 Reply Last reply
                        0
                        • M moskovskiy82

                          @bjacobse Can you elaborate a little more on how you wired things up?
                          Also how you combined the libs and compiled everything for easyESP?
                          Have a sonoff with easyESP and docs are not that clear how to that stuff

                          bjacobseB Offline
                          bjacobseB Offline
                          bjacobse
                          wrote on last edited by
                          #51

                          @moskovskiy82
                          I took 5v from the heatpump, mine is an IVT, I took it from the Ir receive, soldered 2wires, one GND and on for 5V and drilled a hole on the plastic casing, and then I had power for the Wemos D1 Mini Pro module.
                          Then 100 Ohm resister in series with the Irda LED 940nm Ir LED, connected to GPio16/D0 on the Wemos module.

                          Downlaod the ESPEASYT files + download Tonis heatpump /P115 lib and put it in same Arduino IDE, compile it all together

                          http://www.domoticz.com/wiki/AC_/_heatpumpIR

                          1 Reply Last reply
                          0
                          • IspandyI Offline
                            IspandyI Offline
                            Ispandy
                            wrote on last edited by
                            #52

                            I want to make heatpumpIR, but after trying to send the signal using simple.ino sketch to my Sharp A/C nothing happened. Confused where to start ....

                            bjacobseB 1 Reply Last reply
                            0
                            • IspandyI Ispandy

                              I want to make heatpumpIR, but after trying to send the signal using simple.ino sketch to my Sharp A/C nothing happened. Confused where to start ....

                              bjacobseB Offline
                              bjacobseB Offline
                              bjacobse
                              wrote on last edited by
                              #53

                              @Ispandy
                              did you look at the previous comment?
                              to make it easy for you, then don't use mysensors with Arduino for this, it's too difficult to setup, but instead use the Wemos and ESPEASY using your WIFI

                              http://www.domoticz.com/wiki/AC_/_heatpumpIR

                              M 1 Reply Last reply
                              0
                              • bjacobseB bjacobse

                                @Ispandy
                                did you look at the previous comment?
                                to make it easy for you, then don't use mysensors with Arduino for this, it's too difficult to setup, but instead use the Wemos and ESPEASY using your WIFI

                                http://www.domoticz.com/wiki/AC_/_heatpumpIR

                                M Offline
                                M Offline
                                moskovskiy82
                                wrote on last edited by
                                #54

                                @bjacobse There is nothing difficult in setting it up. Just connect the irda to the 3rd PWM leg

                                bjacobseB 1 Reply Last reply
                                0
                                • M moskovskiy82

                                  @bjacobse There is nothing difficult in setting it up. Just connect the irda to the 3rd PWM leg

                                  bjacobseB Offline
                                  bjacobseB Offline
                                  bjacobse
                                  wrote on last edited by
                                  #55

                                  @moskovskiy82
                                  I certainly agree, I assume your comment actually was meant to Ispandy ;-)

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  12

                                  Online

                                  11.7k

                                  Users

                                  11.2k

                                  Topics

                                  113.0k

                                  Posts


                                  Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • MySensors
                                  • OpenHardware.io
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular