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.
  • BulldogLowellB Offline
    BulldogLowellB Offline
    BulldogLowell
    Contest Winner
    wrote on last edited by
    #2

    you could try to get a basic device like a relay or a thermometer and explore.

    then, once you get through the steps, and you know what it takes to put it together, you will have an easier time of it.

    catch your first bass before you go marlin fishing kind-of-thing.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Fredrik Carlsson
      wrote on last edited by
      #3

      Hello
      You are of course right
      I have successfully made a couple of temperature sensors and more or less also got a humid understanding about how the code works.
      What I hesitate about now is how to go further.
      I think the easiest is to evaluate the incoming message in a switch statement from where I send 5 different commands

      I revert with some kind off code later this weekend

      All input and help is highly appreciated

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fredrik Carlsson
        wrote on last edited by Fredrik Carlsson
        #4

        Hello
        I have made the following code (actually not, made i have combined the heatpump example sketch and the ir mysensor sketch to make a controller that can turn ON/OFF the heatpump. But... It doesnt work. I am not sure which node id the controller gets **(how to check that??) **

        How is the MQTT message structured?
        I have tried to send the following with an android app (who is connected to the gateway off course)
        Topic: MyMQTT/22/1/V_LIGHT
        Message:1

        Have also tried node id 23-28 without result.

        I have a couple of temperature nodes working with MQTT and Openhab so the "system" is working for sure.
        But its easier to just find a published message. Harder to publish i maybe??
        Any ideas/suggestions?

        One thing I have noticed is that I dont get the "Starting" message in the serial monitor.
        Is maybe something happening which stalls the code before that?

        All help I can get is highly appreciated!!
        ps, the code inside the do loops is already tested and confirmed working in a simpler sketch without mysensors library.

                      // Example sketch showing how to control ir devices
                      // An IR LED must be connected to Arduino PWM pin 3.
                      // When binary light on is clicked - sketch will send heatpump command with on
                      // When binary light off is clicked - sketch will send heatpump command with off
                      
                      #include <Arduino.h>
                      #include <FujitsuHeatpumpIR.h>
                      #include <PanasonicCKPHeatpumpIR.h>
                      #include <PanasonicHeatpumpIR.h>
                      #include <CarrierHeatpumpIR.h>
                      #include <MideaHeatpumpIR.h>
                      #include <MitsubishiHeatpumpIR.h>
                      #include <SamsungHeatpumpIR.h>
                      #include <MySensor.h>
                      #include <SPI.h>
                      
                      
                      
                      #define CHILD_1  1  // childId
                      
                      IRSender irSender(3); // pin where ir diode is sitting
                      
                      MySensor gw;
                      MyMessage msg(CHILD_1, V_VAR1);
                      
                      HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpumpIR(), new PanasonicJKEHeatpumpIR(),
                                                  new PanasonicNKEHeatpumpIR(), new CarrierHeatpumpIR(), new MideaHeatpumpIR(),
                                                  new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(),
                                                  new SamsungHeatpumpIR(), NULL};
                        // will take away everything except PanasonicJKE when everything ready to reduce sketch size
                      
                      void setup()  
                      {  
                      
                        gw.begin(incomingMessage); // Start listening
                      
                        // Send the sketch version information to the gateway and Controller
                        gw.sendSketchInfo("IR Sensor", "1.0");
                      
                        // Register a sensors to gw. Use binary light for test purposes.
                        gw.present(CHILD_1, S_LIGHT);
                        
                        Serial.begin(9600); // Start serial only for debugging. Will be taken away when development is finished
                        delay(500);
                      
                        Serial.println(F("Starting"));
                        
                      }
                      
                      
                      void loop() 
                      {
                        
                      }
                      
                      
                      
                      void incomingMessage(const MyMessage &message) {
                        // We only expect one type of message from controller. But we better check anyway.
                        if (message.type==V_LIGHT) {
                           int incomingRelayStatus = message.getInt();
                           if (incomingRelayStatus == 1) {
                               
                                int i = 0; //counter
                                prog_char* buf;         
                             
                              do {
                             // Send the same IR command to all supported heatpumps
                                      Serial.print(F("Sending IR to "));
                                  
                                      buf = (prog_char*)heatpumpIR[i]->model();
                                      // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                      while (char modelChar = pgm_read_byte(buf++))
                                      {
                                        Serial.print(modelChar);
                                      }
                                      Serial.print(F(", info: "));
                                  
                                      buf = (prog_char*)heatpumpIR[i]->info();
                                      // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                      while (char infoChar = pgm_read_byte(buf++))
                                      {
                                        Serial.print(infoChar);
                                      }
                                      Serial.println();
                                  
                                      // Send the IR command
                                      heatpumpIR[i]->send(irSender, POWER_ON, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                      delay(500);
                                    }
                                      while (heatpumpIR[++i] != NULL);
                         
                          } else if (incomingRelayStatus == 1) {
                                     
                                int i = 0; //counter
                                prog_char* buf;
                           
                            do {
                                      // Send the same IR command to all supported heatpumps
                                      Serial.print(F("Sending IR to "));
                                  
                                      buf = (prog_char*)heatpumpIR[i]->model();
                                      // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                      while (char modelChar = pgm_read_byte(buf++))
                                      {
                                        Serial.print(modelChar);
                                      }
                                      Serial.print(F(", info: "));
                                  
                                      buf = (prog_char*)heatpumpIR[i]->info();
                                      // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                      while (char infoChar = pgm_read_byte(buf++))
                                      {
                                        Serial.print(infoChar);
                                      }
                                      Serial.println();
                                  
                                      // Send the IR command
                                      heatpumpIR[i]->send(irSender, POWER_OFF, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                      delay(500);
                                    }
                                    while (heatpumpIR[++i] != NULL);
                       
                       }
                      }
                      }
        
        F 1 Reply Last reply
        0
        • F Fredrik Carlsson

          Hello
          I have made the following code (actually not, made i have combined the heatpump example sketch and the ir mysensor sketch to make a controller that can turn ON/OFF the heatpump. But... It doesnt work. I am not sure which node id the controller gets **(how to check that??) **

          How is the MQTT message structured?
          I have tried to send the following with an android app (who is connected to the gateway off course)
          Topic: MyMQTT/22/1/V_LIGHT
          Message:1

          Have also tried node id 23-28 without result.

          I have a couple of temperature nodes working with MQTT and Openhab so the "system" is working for sure.
          But its easier to just find a published message. Harder to publish i maybe??
          Any ideas/suggestions?

          One thing I have noticed is that I dont get the "Starting" message in the serial monitor.
          Is maybe something happening which stalls the code before that?

          All help I can get is highly appreciated!!
          ps, the code inside the do loops is already tested and confirmed working in a simpler sketch without mysensors library.

                        // Example sketch showing how to control ir devices
                        // An IR LED must be connected to Arduino PWM pin 3.
                        // When binary light on is clicked - sketch will send heatpump command with on
                        // When binary light off is clicked - sketch will send heatpump command with off
                        
                        #include <Arduino.h>
                        #include <FujitsuHeatpumpIR.h>
                        #include <PanasonicCKPHeatpumpIR.h>
                        #include <PanasonicHeatpumpIR.h>
                        #include <CarrierHeatpumpIR.h>
                        #include <MideaHeatpumpIR.h>
                        #include <MitsubishiHeatpumpIR.h>
                        #include <SamsungHeatpumpIR.h>
                        #include <MySensor.h>
                        #include <SPI.h>
                        
                        
                        
                        #define CHILD_1  1  // childId
                        
                        IRSender irSender(3); // pin where ir diode is sitting
                        
                        MySensor gw;
                        MyMessage msg(CHILD_1, V_VAR1);
                        
                        HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpumpIR(), new PanasonicJKEHeatpumpIR(),
                                                    new PanasonicNKEHeatpumpIR(), new CarrierHeatpumpIR(), new MideaHeatpumpIR(),
                                                    new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(),
                                                    new SamsungHeatpumpIR(), NULL};
                          // will take away everything except PanasonicJKE when everything ready to reduce sketch size
                        
                        void setup()  
                        {  
                        
                          gw.begin(incomingMessage); // Start listening
                        
                          // Send the sketch version information to the gateway and Controller
                          gw.sendSketchInfo("IR Sensor", "1.0");
                        
                          // Register a sensors to gw. Use binary light for test purposes.
                          gw.present(CHILD_1, S_LIGHT);
                          
                          Serial.begin(9600); // Start serial only for debugging. Will be taken away when development is finished
                          delay(500);
                        
                          Serial.println(F("Starting"));
                          
                        }
                        
                        
                        void loop() 
                        {
                          
                        }
                        
                        
                        
                        void incomingMessage(const MyMessage &message) {
                          // We only expect one type of message from controller. But we better check anyway.
                          if (message.type==V_LIGHT) {
                             int incomingRelayStatus = message.getInt();
                             if (incomingRelayStatus == 1) {
                                 
                                  int i = 0; //counter
                                  prog_char* buf;         
                               
                                do {
                               // Send the same IR command to all supported heatpumps
                                        Serial.print(F("Sending IR to "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->model();
                                        // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char modelChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(modelChar);
                                        }
                                        Serial.print(F(", info: "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->info();
                                        // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char infoChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(infoChar);
                                        }
                                        Serial.println();
                                    
                                        // Send the IR command
                                        heatpumpIR[i]->send(irSender, POWER_ON, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                        delay(500);
                                      }
                                        while (heatpumpIR[++i] != NULL);
                           
                            } else if (incomingRelayStatus == 1) {
                                       
                                  int i = 0; //counter
                                  prog_char* buf;
                             
                              do {
                                        // Send the same IR command to all supported heatpumps
                                        Serial.print(F("Sending IR to "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->model();
                                        // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char modelChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(modelChar);
                                        }
                                        Serial.print(F(", info: "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->info();
                                        // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char infoChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(infoChar);
                                        }
                                        Serial.println();
                                    
                                        // Send the IR command
                                        heatpumpIR[i]->send(irSender, POWER_OFF, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                        delay(500);
                                      }
                                      while (heatpumpIR[++i] != NULL);
                         
                         }
                        }
                        }
          
          F Offline
          F Offline
          Fredrik Carlsson
          wrote on last edited by
          #5

          @Fredrik-Carlsson no ideas?
          How can i see which node id the sensor gets?

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by hek
            #6

            @Fredrik-Carlsson said:

            I am not sure which node id the controller gets

            Which controller? Do you mean the node?

            @Damme might be able to help with the MQTT stuff.

            You should see a "starting" message. If not there might be a code problem.

            loop() should at least contain gw.process() to pick up incoming messages.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Fredrik Carlsson
              wrote on last edited by
              #7

              Haha yes i have forgotten gw process in the loop. that is corrected now.
              Yes i want to know which mqtt address the node has (for example i have 2 temperatures nodes with id MyMQTT/20/ and MyMQTT/21/

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #8

                It is usually printed in serial monitor at startup .
                ...or by calling gw.getNodeId();

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Fredrik Carlsson
                  wrote on last edited by
                  #9

                  TOUCHDOWN!
                  Here is working code. Whit this i can with mymqtt android app publish topic MyMQTT/20/1/V_LIGHT with message "1" for heatpump on (with 24 degrees etc etc) and "0" for heatpump off. I have tried it with my Panasonic heatpump and it works.
                  I also added a little serial string in order to find out node Id (mine was 20 then)

                  Next step is to increase the different modes.
                  I was thinking from beginning of only having 5 different "hardcoded" modes that would actually be more then enough for my use, but it would be really nice to send over variables some how instead so you have complete control of the heatpump from OpenHAB (temp, heatingmode etc). I am just not sure about how long messages you can send with the nrf protocol. Must dig into that

                  Thanks for all the help, as I said I have almost no programming nor Arduino knowledge since before. Just starting out.
                  // Example sketch showing how to control ir Heatpumps
                  // An IR LED must be connected to Arduino PWM pin 3.

                        #include <Arduino.h>
                        #include <FujitsuHeatpumpIR.h>
                        #include <PanasonicCKPHeatpumpIR.h>
                        #include <PanasonicHeatpumpIR.h>
                        #include <CarrierHeatpumpIR.h>
                        #include <MideaHeatpumpIR.h>
                        #include <MitsubishiHeatpumpIR.h>
                        #include <SamsungHeatpumpIR.h>
                        #include <MySensor.h>
                        #include <SPI.h>
                        
                        
                        
                        #define CHILD_1  1  // childId
                        
                        IRSender irSender(3); // pin where ir diode is sitting
                        
                        MySensor gw;
                        MyMessage msg(CHILD_1, V_VAR1);
                        
                        HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpumpIR(), new PanasonicJKEHeatpumpIR(),
                                                    new PanasonicNKEHeatpumpIR(), new CarrierHeatpumpIR(), new MideaHeatpumpIR(),
                                                    new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(),
                                                    new SamsungHeatpumpIR(), NULL};
                          // will take away everything except PanasonicJKE when everything ready to reduce sketch size
                        
                        void setup()  
                        {  
                        
                          gw.begin(incomingMessage); // Start listening
                        
                          // Send the sketch version information to the gateway and Controller
                          gw.sendSketchInfo("IR Sensor", "1.0");
                        
                          // Register a sensors to gw. Use binary light for test purposes.
                          gw.present(CHILD_1, S_LIGHT);
                          
                          Serial.begin(9600); 
                          delay(500);
                        
                          Serial.println(F("Starting"));
                          Serial.print("Node Id is set to: ");
                          Serial.println(gw.getNodeId());
                        }
                        
                        
                        void loop() 
                        {
                        
                          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) {
                             int incomingRelayStatus = message.getInt();
                             if (incomingRelayStatus == 1) {
                                 
                                  int i = 0; //counter
                                  prog_char* buf;         
                               
                                do {
                               // Send the same IR command to all supported heatpumps
                                        Serial.print(F("Sending IR to "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->model();
                                        // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char modelChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(modelChar);
                                        }
                                        Serial.print(F(", info: "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->info();
                                        // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char infoChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(infoChar);
                                        }
                                        Serial.println();
                                    
                                        // Send the IR command
                                        heatpumpIR[i]->send(irSender, POWER_ON, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                        delay(500);
                                      }
                                        while (heatpumpIR[++i] != NULL);
                           
                            } else if (incomingRelayStatus == 0) {
                                       
                                  int i = 0; //counter
                                  prog_char* buf;
                             
                              do {
                                        // Send the same IR command to all supported heatpumps
                                        Serial.print(F("Sending IR to "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->model();
                                        // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char modelChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(modelChar);
                                        }
                                        Serial.print(F(", info: "));
                                    
                                        buf = (prog_char*)heatpumpIR[i]->info();
                                        // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                        while (char infoChar = pgm_read_byte(buf++))
                                        {
                                          Serial.print(infoChar);
                                        }
                                        Serial.println();
                                    
                                        // Send the IR command
                                        heatpumpIR[i]->send(irSender, POWER_OFF, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                        delay(500);
                                      }
                                      while (heatpumpIR[++i] != NULL);
                         
                         }
                        }
                        }
                  
                  RJ_MakeR 1 Reply Last reply
                  2
                  • F Fredrik Carlsson

                    TOUCHDOWN!
                    Here is working code. Whit this i can with mymqtt android app publish topic MyMQTT/20/1/V_LIGHT with message "1" for heatpump on (with 24 degrees etc etc) and "0" for heatpump off. I have tried it with my Panasonic heatpump and it works.
                    I also added a little serial string in order to find out node Id (mine was 20 then)

                    Next step is to increase the different modes.
                    I was thinking from beginning of only having 5 different "hardcoded" modes that would actually be more then enough for my use, but it would be really nice to send over variables some how instead so you have complete control of the heatpump from OpenHAB (temp, heatingmode etc). I am just not sure about how long messages you can send with the nrf protocol. Must dig into that

                    Thanks for all the help, as I said I have almost no programming nor Arduino knowledge since before. Just starting out.
                    // Example sketch showing how to control ir Heatpumps
                    // An IR LED must be connected to Arduino PWM pin 3.

                          #include <Arduino.h>
                          #include <FujitsuHeatpumpIR.h>
                          #include <PanasonicCKPHeatpumpIR.h>
                          #include <PanasonicHeatpumpIR.h>
                          #include <CarrierHeatpumpIR.h>
                          #include <MideaHeatpumpIR.h>
                          #include <MitsubishiHeatpumpIR.h>
                          #include <SamsungHeatpumpIR.h>
                          #include <MySensor.h>
                          #include <SPI.h>
                          
                          
                          
                          #define CHILD_1  1  // childId
                          
                          IRSender irSender(3); // pin where ir diode is sitting
                          
                          MySensor gw;
                          MyMessage msg(CHILD_1, V_VAR1);
                          
                          HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpumpIR(), new PanasonicJKEHeatpumpIR(),
                                                      new PanasonicNKEHeatpumpIR(), new CarrierHeatpumpIR(), new MideaHeatpumpIR(),
                                                      new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(),
                                                      new SamsungHeatpumpIR(), NULL};
                            // will take away everything except PanasonicJKE when everything ready to reduce sketch size
                          
                          void setup()  
                          {  
                          
                            gw.begin(incomingMessage); // Start listening
                          
                            // Send the sketch version information to the gateway and Controller
                            gw.sendSketchInfo("IR Sensor", "1.0");
                          
                            // Register a sensors to gw. Use binary light for test purposes.
                            gw.present(CHILD_1, S_LIGHT);
                            
                            Serial.begin(9600); 
                            delay(500);
                          
                            Serial.println(F("Starting"));
                            Serial.print("Node Id is set to: ");
                            Serial.println(gw.getNodeId());
                          }
                          
                          
                          void loop() 
                          {
                          
                            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) {
                               int incomingRelayStatus = message.getInt();
                               if (incomingRelayStatus == 1) {
                                   
                                    int i = 0; //counter
                                    prog_char* buf;         
                                 
                                  do {
                                 // Send the same IR command to all supported heatpumps
                                          Serial.print(F("Sending IR to "));
                                      
                                          buf = (prog_char*)heatpumpIR[i]->model();
                                          // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                          while (char modelChar = pgm_read_byte(buf++))
                                          {
                                            Serial.print(modelChar);
                                          }
                                          Serial.print(F(", info: "));
                                      
                                          buf = (prog_char*)heatpumpIR[i]->info();
                                          // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                          while (char infoChar = pgm_read_byte(buf++))
                                          {
                                            Serial.print(infoChar);
                                          }
                                          Serial.println();
                                      
                                          // Send the IR command
                                          heatpumpIR[i]->send(irSender, POWER_ON, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                          delay(500);
                                        }
                                          while (heatpumpIR[++i] != NULL);
                             
                              } else if (incomingRelayStatus == 0) {
                                         
                                    int i = 0; //counter
                                    prog_char* buf;
                               
                                do {
                                          // Send the same IR command to all supported heatpumps
                                          Serial.print(F("Sending IR to "));
                                      
                                          buf = (prog_char*)heatpumpIR[i]->model();
                                          // 'model' is a PROGMEM pointer, so need to write a byte at a time
                                          while (char modelChar = pgm_read_byte(buf++))
                                          {
                                            Serial.print(modelChar);
                                          }
                                          Serial.print(F(", info: "));
                                      
                                          buf = (prog_char*)heatpumpIR[i]->info();
                                          // 'info' is a PROGMEM pointer, so need to write a byte at a time
                                          while (char infoChar = pgm_read_byte(buf++))
                                          {
                                            Serial.print(infoChar);
                                          }
                                          Serial.println();
                                      
                                          // Send the IR command
                                          heatpumpIR[i]->send(irSender, POWER_OFF, MODE_HEAT, FAN_2, 24, VDIR_UP, HDIR_AUTO);
                                          delay(500);
                                        }
                                        while (heatpumpIR[++i] != NULL);
                           
                           }
                          }
                          }
                    
                    RJ_MakeR Offline
                    RJ_MakeR Offline
                    RJ_Make
                    Hero Member
                    wrote on last edited by
                    #10

                    @Fredrik-Carlsson

                    Nice Job!

                    RJ_Make

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Fredrik Carlsson
                      wrote on last edited by
                      #11

                      well, i have run into some problems. It doesnt have anything to do with the sketch though. Its either OpenHab or the gateway that is causing headache.

                      First of all, I have changed the code into this:

                                  // Example sketch showing how to control ir Heatpumps
                                  // An IR LED must be connected to Arduino PWM pin 3.
                                  
                                  
                                  #include <Arduino.h>
                                  #include <PanasonicHeatpumpIR.h>
                                  #include <MySensor.h>
                                  #include <SPI.h>
                                  
                                  
                                  
                                  #define CHILD_1  1  // childId
                                  
                                  IRSender irSender(3); // pin where ir diode is sitting
                                  
                                  MySensor gw;
                                  MyMessage msg(CHILD_1, V_VAR1);
                                  
                                  HeatpumpIR *heatpumpIR[] = {new PanasonicJKEHeatpumpIR(), NULL};
                                    // will take away everything except PanasonicJKE when everything ready to reduce sketch size
                                  
                                  void setup()  
                                  {  
                                  
                                    gw.begin(incomingMessage); // Start listening
                                  
                                    // Send the sketch version information to the gateway and Controller
                                    gw.sendSketchInfo("IR Sensor", "1.0");
                                  
                                    // Register a sensors to gw. Use binary light for test purposes.
                                    gw.present(CHILD_1, S_HEATER);
                                    
                                    Serial.begin(9600); 
                                    delay(500);
                                  
                                    Serial.println(F("Starting"));
                                    Serial.print("Node Id is set to: ");
                                    Serial.println(gw.getNodeId());
                                  }
                                  
                                  
                                  void loop() 
                                  {
                                  
                                    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_HEATER) {
                                       int incomingHeatingStatus = message.getInt();
                                       if (incomingHeatingStatus == 0) {
                                                  heatpumpIR[0]->send(irSender, POWER_OFF, MODE_HEAT, FAN_AUTO, 22, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                          } else if (incomingHeatingStatus == 1) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 21, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 2) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 22, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 3) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 23, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 4) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 24, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 5) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 25, VDIR_AUTO, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 6) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 22, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 7) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_1, 22, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 8) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_3, 22, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 9) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_HEAT, FAN_4, 22, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 10) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_COOL, FAN_AUTO, 18, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 11) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_COOL, FAN_AUTO, 20, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                } else if (incomingHeatingStatus == 12) {
                                                  heatpumpIR[0]->send(irSender, POWER_ON, MODE_COOL, FAN_AUTO, 22, VDIR_UP, HDIR_AUTO);
                                                  delay(500);
                                                  Serial.println("Setting mode to ");
                                                  Serial.println(incomingHeatingStatus);
                                                }
                                  }
                                  }
                      

                      With the Android app MyMQTT I have tried the different modes and all works, Currently the scetch has been up running a couple of days without problems.

                      The problem is when i try to do this from OpenHAB.
                      First of all, the Mqtt binding IS working, at least with inbound messages because I have also a couple of temperature sensors and that works fine. But when i try with the following setup the command line of openhab shows: "Heatpump received command ON", but nothing is happening with the arduino. Very strange. Any ideas?

                      Openhab Item:

                             Switch Heatpump (varmesystem,All)      {mqtt=">[mysensor:MyMQTT/20/1/V_HEATER:command:ON:1],>      [mysensor:MyMQTT/20/1/V_HEATER:command:OFF:0]"}
                      

                      OpenHAB Sitemap:

                           Switch item=Heatpump label="Värmepump"
                      

                      Any ideas what is going wrong?

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Fredrik Carlsson
                        wrote on last edited by
                        #12

                        Well, after a few restarts of both the node, the gateway and openhab it suddenly works.

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          johnr
                          wrote on last edited by
                          #13

                          Hi,

                          Thank you for the inspiration. I skuld like to use this to control my Daikin heatpump in my cabin. Unfortunatley I am not able to travel there for I while to access the remote. I think I need it to analyze the signal since Daikin is not supported by the library you used.

                          I am thinking just two buttons (on 22 degrees/ on 10 degrees)

                          Did you stumble over any Daikin codes while working on this project?

                          Maybe it is possible to use the code these guys decoded http://www.hifi-remote.com/forums/viewtopic.php?t=11769

                          D 1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            Fredrik Carlsson
                            wrote on last edited by
                            #14

                            Hello
                            nice that you cna use it for something :)
                            Sorry, I have no idea regarding Daikin, but if you build sometihng to record the codes with maybe you can figure it out and just add that to the library somehow?

                            Anyway, i have thought more about this and i do actually want to be able to make it a little smarter than the code above.
                            It would be nice if its possible to send a whole string direct from the controller. ie "send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, 21, VDIR_AUTO, HDIR_AUTO)" Then I can on the controller side make all the logic and that way have complete control of how the heatpump behaves.

                            I have tried to search a little, but can not find any concrete answer. How big is the maximum size of the payload you can send with this library?

                            1 Reply Last reply
                            0
                            • hekH Offline
                              hekH Offline
                              hek
                              Admin
                              wrote on last edited by hek
                              #15

                              Answer in big blue box here:
                              http://www.mysensors.org/build/serial_api

                              25 bytes.

                              1 Reply Last reply
                              0
                              • J johnr

                                Hi,

                                Thank you for the inspiration. I skuld like to use this to control my Daikin heatpump in my cabin. Unfortunatley I am not able to travel there for I while to access the remote. I think I need it to analyze the signal since Daikin is not supported by the library you used.

                                I am thinking just two buttons (on 22 degrees/ on 10 degrees)

                                Did you stumble over any Daikin codes while working on this project?

                                Maybe it is possible to use the code these guys decoded http://www.hifi-remote.com/forums/viewtopic.php?t=11769

                                D Offline
                                D Offline
                                DirkB19
                                wrote on last edited by
                                #16

                                @johnr

                                I'm taking my first steps with IR sender/receiver because I'm also looking for controlling my DAIKIN heatpump.
                                I assembled IR receiver, IR sender and nano and loaded From the examples IR Sender/Receiver sketch.
                                It works with the remote of my Samsung TV, which it recognises as NEC.
                                Daikin is not recognized.
                                My Panasonic TV remote is not recognized.
                                My Telenet Set-Top box remote is not recognized.
                                I guess there is a IRlib for Panasonic, right ?

                                Thx, guys !

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

                                  Nice to see that my little HeatpumpIR library made it all the way here :)

                                  I'm also quite new to MySensors, I actually just started today, I've had all the necessary hardware on my table for some weeks now... My goal is to power a (physically) small MySensors device directly from the Panasonic heatpump, and hide everything within the indoor unit's covers, and have it fully controlled by Domoticz. There's quite a bit of work to do, as for example Domoticz does not have a suitable devuce type yet.

                                  And how about MySensors, I'm still quite a newbie on the messaging schema... Is there a schema which could be used to communicate all of these within the same message:

                                  • ON/OFF information (0 or 1)
                                  • Temperature information (integer from 8 to 30)
                                  • Fan speed information (integer from 0 to 5)
                                  • Mode information (COOL, HEAT etc. i.e. integer from 0 to 6)

                                  What comes to Daikin, it would probably be quite easy to add it into the HeatpumpIR code, provided that I could borrow the remote controller for a while. Or, if somebody else could decode the protocol.

                                  1 Reply Last reply
                                  1
                                  • J Offline
                                    J Offline
                                    johnr
                                    wrote on last edited by
                                    #18

                                    ToniA,

                                    Where are you based? I maybe can send you my remote, if I am sure to get it back ;)
                                    I think it will be a challenge to send all the information with only 25 bytes.

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

                                      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 1 Reply Last reply
                                      0
                                      • hekH Offline
                                        hekH Offline
                                        hek
                                        Admin
                                        wrote on last edited by
                                        #20

                                        Wow, great job @ToniA

                                        Would you consider creating a pull request with the example and HeatpumpIR library when you feel finished?

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

                                          @hek, I created pull request #211. I think it's good enough, the challenges are really on the Domoticz side.

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


                                          13

                                          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