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. Troubleshooting
  3. Has anyone made a 2 or 4 channel relay , and is that worked correct ?

Has anyone made a 2 or 4 channel relay , and is that worked correct ?

Scheduled Pinned Locked Moved Troubleshooting
40 Posts 7 Posters 9.2k Views 5 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.
  • R Reza

    :/ why delete your post ? :(

    barduinoB Offline
    barduinoB Offline
    barduino
    wrote on last edited by
    #22

    @Reza,

    I'm a noob at electronics and arduinos and have a wild imagination :smiley:

    I had a theory but was unsure, so I decided to test it first rather than cause more confusion.

    I know this is a place of sharing, but more than once I caused more problems when trying to help.

    I don't want to bring some stupid idea into the fold.

    I'll report back.

    1 Reply Last reply
    0
    • R Reza

      @sundberg84 said:

      Strange... im out of ideas at this point. Hardware failure?
      Im not that good looking at the code, but I maybe someone else is.

      :( thank you
      this is strange for me too . pin 3 dont working . but pin4 worked . also if i change cable of pin 3 and 4 other relay working and pin 3 dont work
      I change 2 line :
      #define RELAY_1 4
      #define NUMBER_OF_RELAYS 2
      but so pin 4 dont work and pin 5 working....

      barduinoB Offline
      barduinoB Offline
      barduino
      wrote on last edited by barduino
      #23

      @Reza,

      I guess reality is stranger than fiction.

      To eliminate any bad connections I started by this:

      void setup()  
      { 
        pinMode(3, OUTPUT); 
        pinMode(4, OUTPUT); 
        pinMode(5, OUTPUT); 
        pinMode(6, OUTPUT); 
        
        digitalWrite(3,LOW);
        digitalWrite(4,LOW);
        digitalWrite(5,LOW);
        digitalWrite(6,LOW);
      }
      
      void loop() 
      {
          for( int i=3;i<=6;i++){
            digitalWrite(i,HIGH);
            delay(500);
          
          }
          for( int i=3;i<=6;i++){
            digitalWrite(i,LOW);
            delay(500);
          }
      }
      

      Using a 4 relay board, connected pins 3 through 6, I get a nice effect of all pins light up in sequence and then turn off in sequence.

      With the relay sketch from the examples (lib 2.0.0) and debugging the load state values which where set to 0 for each sensor I have for each relay (off, ON, ON, ON).

      Then on the setup I decide to reduce it to this:

      void setup()  
      { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);  
          digitalWrite(pin,LOW);
          Serial.print("Pin ");
          Serial.print(pin);
          Serial.println(" to LOW");
        }
      }
      

      Same result or each relay (off, ON, ON, ON).

      Starting repeater (RNNRA-, 2.0.0-beta)
      Radio init successful.
      Pin 3 to LOW
      Pin 4 to LOW
      Pin 5 to LOW
      Pin 6 to LOW
      send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=ok:2.0.0-beta
      send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-15 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      send: 15-15-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
      send: 15-15-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 15-15-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      Presenting sensor:1
      send: 15-15-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      Presenting sensor:2
      send: 15-15-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      Presenting sensor:3
      send: 15-15-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      Presenting sensor:4
      Init complete, id=15, parent=0, distance=1
      

      So I decided to re-initialize the pins once more in the loop section:

      void loop() 
      {
          if (isFirstTime){
            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++,pin++) {
                
                currState = loadState(sensor);  
                
                pinMode(pin, OUTPUT);  
                digitalWrite(pin,LOW);
              
                Serial.print("Current Status sensor:");
                Serial.print(sensor);
                Serial.print("\t");
                Serial.print("State:");
                Serial.print(currState);
                Serial.print("\t");
                Serial.print("Pin:");
                Serial.println(pin);
      
                // Set relay to last known state (using eeprom storage) 
                digitalWrite(pin, currState?RELAY_ON:RELAY_OFF);
                wait(500);
            }
            isFirstTime = false;
          }
      
      }
      

      Now I have all relays off:

      Init complete, id=15, parent=0, distance=1
      Current Status sensor:1	State:0	Pin:3
      Current Status sensor:2	State:0	Pin:4
      Current Status sensor:3	State:0	Pin:5
      Current Status sensor:4	State:0	Pin:6
      

      Now sending some messages:
      Relay 1

      Current Status sensor:4	State:0	Pin:6
      read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:1 On pin:3, New status: 1
      read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:1 On pin:3, New status: 0
      

      Works fine but guess what, Relay 4 also turned ON after Relay 1

      Relay 2:

      read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:2 On pin:4, New status: 1
      read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:2 On pin:4, New status: 0
      

      Works fine but Relay 4 blinks and stays on

      Relay 3:

      read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:3 On pin:5, New status: 1
      read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:3 On pin:5, New status: 0
      

      Works fine but Relay 4 blinks and stays on

      Relay 4:

      read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:4 On pin:6, New status: 1
      read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:4 On pin:6, New status: 0
      

      Relay 4 blinks and stays on

      These relays are solid state 5v, arduino pro mini 5v and I both used the power from computer USB and a 6000 mAh phone battery with the same results.

      Here is the full code:

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */ 
      // Define Node ID
      #define MY_NODE_ID 15
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensor.h>
      
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 4 // Total number of attached relays
      #define RELAY_ON HIGH  // GPIO value to write to turn on attached relay
      #define RELAY_OFF LOW // GPIO value to write to turn off attached relay
      
      bool isFirstTime = true;
      
      bool currState;
      
      void setup()  
      { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);  
          digitalWrite(pin,LOW);
          Serial.print("Pin ");
          Serial.print(pin);
          Serial.println(" to LOW");
        }
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay", "1.0");
      
        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)
          present(sensor, S_LIGHT);
          Serial.print("Presenting sensor:");
          Serial.println(sensor);
        }
      }
      
      
      void loop() 
      {
          if (isFirstTime){
            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++,pin++) {
                
                currState = loadState(sensor);  
                
                pinMode(pin, OUTPUT);  
                digitalWrite(pin,LOW);
              
                Serial.print("Current Status sensor:");
                Serial.print(sensor);
                Serial.print("\t");
                Serial.print("State:");
                Serial.print(currState);
                Serial.print("\t");
                Serial.print("Pin:");
                Serial.println(pin);
      
                // Set relay to last known state (using eeprom storage) 
                digitalWrite(pin, currState?RELAY_ON:RELAY_OFF);
                wait(500);
            }
            isFirstTime = false;
          }
      
      }
      
      void receive(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
           saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(" On pin:");
           Serial.print(message.sensor-1+RELAY_1);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      

      This could be some issue with the development branch of 2.0.0, its been some time since I refreshed.

      So refreshing the libs I see a new before() section and an empty setup() from the RelayActuator example

      void before() { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup() {
        
      }
      

      Now it runs fine

      Starting repeater (RNNRA-, 2.0.0-beta)
      Radio init successful.
      send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
      send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-15 s=2Starting repeater (RNNRA-, 2.0.0-beta)
      Radio init successful.
      send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
      send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-15 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      send: 15-15-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
      send: 15-15-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 15-15-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 15-15-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      send: 15-15-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,st=fail:
      send: 15-15-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,st=ok:
      Init complete, id=15, parent=0, distance=1
      read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:1, New status: 1
      read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:1, New status: 0
      read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:2, New status: 1
      read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:2, New status: 0
      read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:3, New status: 1
      read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:3, New status: 0
      read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:1
      Incoming change for sensor:4, New status: 1
      read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:0
      Incoming change for sensor:4, New status: 0
      

      All relays behaving as expected before and after running a clearEEPROMconfig sketch.

      So perhaps there is an issue with v1.5 but it seems the development branch of 2.0 is fine.

      Or you can try to debug the hell out of it with plenty of Serial.prints.

      Check with a simple sketch if your relays are fine.

      If so check what are you getting from the loadState, make sure its boolean, initialize the pins to LOW in setup and if it doesn't work again in loop just once.

      Try to have the relays always starting as off with no load or save state.

      Cheers

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Reza
        wrote on last edited by
        #24

        if any one built a 2 or 4 channel please help me , please send me the codes that you use , and wiring and please told me what you use adaptor ( how much V and A ) ? which arduino use ?

        TheoLT 1 Reply Last reply
        0
        • R Reza

          if any one built a 2 or 4 channel please help me , please send me the codes that you use , and wiring and please told me what you use adaptor ( how much V and A ) ? which arduino use ?

          TheoLT Offline
          TheoLT Offline
          TheoL
          Contest Winner
          wrote on last edited by
          #25

          @Reza Since it's already a long thread I didn't want to read everything. But just a stupid question. Did you measure the relay? It would be my starting point. Because if that's not working, the rest will not work either.

          Also I once had a relay connected to a ProMini 5V, which I powered over FDTI. But I forgot to setup my FDTI programmer to 5V. By this the Arduino didn't have enough power to switch on the relay. It took me a while before I discovered that, because the NFR24L01+ antenna was working just fine.

          Before I add an external power source to an Arduino, I always feed the Arduino through the USB of my computer. In my experience it has always supplied enough power for controlling a relay state. You could try it, just to eliminate power supply issues.

          Just a few tips for you my friend. I hope you'll be able to find the cause of your troubles really soon.

          Take care.

          R 1 Reply Last reply
          1
          • TheoLT TheoL

            @Reza Since it's already a long thread I didn't want to read everything. But just a stupid question. Did you measure the relay? It would be my starting point. Because if that's not working, the rest will not work either.

            Also I once had a relay connected to a ProMini 5V, which I powered over FDTI. But I forgot to setup my FDTI programmer to 5V. By this the Arduino didn't have enough power to switch on the relay. It took me a while before I discovered that, because the NFR24L01+ antenna was working just fine.

            Before I add an external power source to an Arduino, I always feed the Arduino through the USB of my computer. In my experience it has always supplied enough power for controlling a relay state. You could try it, just to eliminate power supply issues.

            Just a few tips for you my friend. I hope you'll be able to find the cause of your troubles really soon.

            Take care.

            R Offline
            R Offline
            Reza
            wrote on last edited by Reza
            #26

            @TheoL said:

            @Reza Since it's already a long thread I didn't want to read everything. But just a stupid question. Did you measure the relay? It would be my starting point. Because if that's not working, the rest will not work either.

            Also I once had a relay connected to a ProMini 5V, which I powered over FDTI. But I forgot to setup my FDTI programmer to 5V. By this the Arduino didn't have enough power to switch on the relay. It took me a while before I discovered that, because the NFR24L01+ antenna was working just fine.

            Before I add an external power source to an Arduino, I always feed the Arduino through the USB of my computer. In my experience it has always supplied enough power for controlling a relay state. You could try it, just to eliminate power supply issues.

            Just a few tips for you my friend. I hope you'll be able to find the cause of your troubles really soon.

            Take care.

            hi thank you for help me , connected the in1 to pin3 and in2 to pin4 , but pin 4 work and 3 dont work ! (voltag Priority is pin 3 , is this true ? but pin 3 is off and pin4 is work !! also i change pin3 and 4 so other relay is work and other one connect to pin3 dont work ! i test this with a adaptor 5V and 1A but dont work , do need i use a adaptor with more amper ?
            also i use a "ClearEepromConfig" program for my arduino and program relay again but dont work again...
            ( my arduino is a arduino nano )

            TheoLT 1 Reply Last reply
            0
            • R Reza

              @TheoL said:

              @Reza Since it's already a long thread I didn't want to read everything. But just a stupid question. Did you measure the relay? It would be my starting point. Because if that's not working, the rest will not work either.

              Also I once had a relay connected to a ProMini 5V, which I powered over FDTI. But I forgot to setup my FDTI programmer to 5V. By this the Arduino didn't have enough power to switch on the relay. It took me a while before I discovered that, because the NFR24L01+ antenna was working just fine.

              Before I add an external power source to an Arduino, I always feed the Arduino through the USB of my computer. In my experience it has always supplied enough power for controlling a relay state. You could try it, just to eliminate power supply issues.

              Just a few tips for you my friend. I hope you'll be able to find the cause of your troubles really soon.

              Take care.

              hi thank you for help me , connected the in1 to pin3 and in2 to pin4 , but pin 4 work and 3 dont work ! (voltag Priority is pin 3 , is this true ? but pin 3 is off and pin4 is work !! also i change pin3 and 4 so other relay is work and other one connect to pin3 dont work ! i test this with a adaptor 5V and 1A but dont work , do need i use a adaptor with more amper ?
              also i use a "ClearEepromConfig" program for my arduino and program relay again but dont work again...
              ( my arduino is a arduino nano )

              TheoLT Offline
              TheoLT Offline
              TheoL
              Contest Winner
              wrote on last edited by
              #27

              @Reza what happens if you connect pin 3 to in2 and pin 4 to in1? That's the easiest way to check your relay. I'm not an expert. Buy my guess is, that if there's a power problem, you wouldn't be able to control any one of the relays. But maybe someone with more knowledge will be able to confirm or deny that,

              R 1 Reply Last reply
              1
              • TheoLT TheoL

                @Reza what happens if you connect pin 3 to in2 and pin 4 to in1? That's the easiest way to check your relay. I'm not an expert. Buy my guess is, that if there's a power problem, you wouldn't be able to control any one of the relays. But maybe someone with more knowledge will be able to confirm or deny that,

                R Offline
                R Offline
                Reza
                wrote on last edited by
                #28

                @TheoL said:

                what happens if you connect pin 3 to in2 and pin 4 to in1? That's the easiest way to check your relay. I'm not an expert. Buy my guess is, that if there's a power problem, you wouldn't be able to control any one of the relays. But maybe someone with more knowledge will be able to confirm or deny that,

                Each relay connect to pin 4 is correct ,and each relay connect to pin 3 is not correct, ok thank you :(

                TheoLT 1 Reply Last reply
                0
                • R Reza

                  @TheoL said:

                  what happens if you connect pin 3 to in2 and pin 4 to in1? That's the easiest way to check your relay. I'm not an expert. Buy my guess is, that if there's a power problem, you wouldn't be able to control any one of the relays. But maybe someone with more knowledge will be able to confirm or deny that,

                  Each relay connect to pin 4 is correct ,and each relay connect to pin 3 is not correct, ok thank you :(

                  TheoLT Offline
                  TheoLT Offline
                  TheoL
                  Contest Winner
                  wrote on last edited by
                  #29

                  @Reza I'm not sure. But if I understand you correctly, my gut feeling is that your pin 3 on the Arduino is broken (or not correctly setup in the code). Could be a power issue, but I seriously doubt it.

                  Just try the blink sketch example. Hookup an LED to pin 3 and change the BLINK_LED pin to pin 3 instead of 13. That way you can check if pin 3 is working correctly.

                  R 1 Reply Last reply
                  1
                  • TheoLT TheoL

                    @Reza I'm not sure. But if I understand you correctly, my gut feeling is that your pin 3 on the Arduino is broken (or not correctly setup in the code). Could be a power issue, but I seriously doubt it.

                    Just try the blink sketch example. Hookup an LED to pin 3 and change the BLINK_LED pin to pin 3 instead of 13. That way you can check if pin 3 is working correctly.

                    R Offline
                    R Offline
                    Reza
                    wrote on last edited by
                    #30

                    @TheoL said:

                    @Reza I'm not sure. But if I understand you correctly, my gut feeling is that your pin 3 on the Arduino is broken (or not correctly setup in the code). Could be a power issue, but I seriously doubt it.

                    Just try the blink sketch example. Hookup an LED to pin 3 and change the BLINK_LED pin to pin 3 instead of 13. That way you can check if pin 3 is working correctly.

                    i change code to :
                    #define RELAY_1 4
                    #define NUMBER_OF_RELAYS 2
                    and in wiring in1=pin4 and in2=pin5
                    so pin 5 is working but pin4 is not work !!!

                    TheoLT 1 Reply Last reply
                    0
                    • R Reza

                      @TheoL said:

                      @Reza I'm not sure. But if I understand you correctly, my gut feeling is that your pin 3 on the Arduino is broken (or not correctly setup in the code). Could be a power issue, but I seriously doubt it.

                      Just try the blink sketch example. Hookup an LED to pin 3 and change the BLINK_LED pin to pin 3 instead of 13. That way you can check if pin 3 is working correctly.

                      i change code to :
                      #define RELAY_1 4
                      #define NUMBER_OF_RELAYS 2
                      and in wiring in1=pin4 and in2=pin5
                      so pin 5 is working but pin4 is not work !!!

                      TheoLT Offline
                      TheoLT Offline
                      TheoL
                      Contest Winner
                      wrote on last edited by
                      #31

                      @Reza In that case, since it's so predictable, it's a bug in your sketch. At least that's what I think. Unfortunately I have busy weekend and week ahead, so I don't think I have the time to investigate your code. I'm really sorry. I have to check if I have a spare relay, and if I can find one I'm willing to check your sketch. But as mentioned before I can't promise that.

                      Hopefully others might be able to help you sooner. Take care.

                      R 1 Reply Last reply
                      1
                      • TheoLT TheoL

                        @Reza In that case, since it's so predictable, it's a bug in your sketch. At least that's what I think. Unfortunately I have busy weekend and week ahead, so I don't think I have the time to investigate your code. I'm really sorry. I have to check if I have a spare relay, and if I can find one I'm willing to check your sketch. But as mentioned before I can't promise that.

                        Hopefully others might be able to help you sooner. Take care.

                        R Offline
                        R Offline
                        Reza
                        wrote on last edited by
                        #32

                        @TheoL said:

                        @Reza In that case, since it's so predictable, it's a bug in your sketch. At least that's what I think. Unfortunately I have busy weekend and week ahead, so I don't think I have the time to investigate your code. I'm really sorry. I have to check if I have a spare relay, and if I can find one I'm willing to check your sketch. But as mentioned before I can't promise that.

                        Hopefully others might be able to help you sooner. Take care.

                        ok :( thank you very much

                        1 Reply Last reply
                        0
                        • NuubiN Offline
                          NuubiN Offline
                          Nuubi
                          wrote on last edited by
                          #33

                          Maybe using increment operator causes your problem [https://www.arduino.cc/en/Reference/Increment]
                          Replacing pin++ with pin=pin+1 in your code should fix it.

                          R 1 Reply Last reply
                          1
                          • NuubiN Nuubi

                            Maybe using increment operator causes your problem [https://www.arduino.cc/en/Reference/Increment]
                            Replacing pin++ with pin=pin+1 in your code should fix it.

                            R Offline
                            R Offline
                            Reza
                            wrote on last edited by
                            #34

                            @Nuubi said:

                            Maybe using increment operator causes your problem [https://www.arduino.cc/en/Reference/Increment]
                            Replacing pin++ with pin=pin+1 in your code should fix it.

                            hi thank you , I will test this and I will report results

                            TheoLT 1 Reply Last reply
                            0
                            • R Reza

                              @Nuubi said:

                              Maybe using increment operator causes your problem [https://www.arduino.cc/en/Reference/Increment]
                              Replacing pin++ with pin=pin+1 in your code should fix it.

                              hi thank you , I will test this and I will report results

                              TheoLT Offline
                              TheoLT Offline
                              TheoL
                              Contest Winner
                              wrote on last edited by
                              #35

                              @Reza

                              So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                              Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                              #include <MySensor.h>
                              #include <SPI.h>
                              
                              #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                              #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                              #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                              #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                              #define SKETCH_NAME      "Relay"
                              #define SKETCH_VERSION   "1.0"
                              
                              // Construct MySensors library
                              MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                              
                              void setup() {
                                gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                              
                                for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                  gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                  pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                  digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                  gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                  gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                  gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                }
                              }
                              
                              
                              void loop() {
                                // Alway process incoming messages whenever possible
                                gw.process();
                              }
                              
                              void incomingMessage(const MyMessage &message) {
                                if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                   int relayPin = RELAY_1 + message.sensor - 1;
                                   if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                     digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                              
                                     // Write some debug info
                                     Serial.print("Incoming change for sensor:");
                                     Serial.print(message.sensor);
                                     Serial.print( ", relay_pin: " );
                                     Serial.print( relayPin );
                                     Serial.print(", New status: ");
                                     Serial.println(message.getBool());
                                   }  
                                 } 
                              }
                              

                              Sketch should work. Please post the serial output of this sketch.

                              My first steps would be:

                              1. Use the sketch I provided (should work, or I missed something).
                              2. Disconnect RELAY from Arduino.
                              3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                              Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                              If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                              R 2 Replies Last reply
                              2
                              • TheoLT TheoL

                                @Reza

                                So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                                Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                                #include <MySensor.h>
                                #include <SPI.h>
                                
                                #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                                #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                                #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                                #define SKETCH_NAME      "Relay"
                                #define SKETCH_VERSION   "1.0"
                                
                                // Construct MySensors library
                                MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                                
                                void setup() {
                                  gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                  gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                                
                                  for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                    gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                    pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                    digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                    gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                    gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                    gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                  }
                                }
                                
                                
                                void loop() {
                                  // Alway process incoming messages whenever possible
                                  gw.process();
                                }
                                
                                void incomingMessage(const MyMessage &message) {
                                  if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                     int relayPin = RELAY_1 + message.sensor - 1;
                                     if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                       digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                                
                                       // Write some debug info
                                       Serial.print("Incoming change for sensor:");
                                       Serial.print(message.sensor);
                                       Serial.print( ", relay_pin: " );
                                       Serial.print( relayPin );
                                       Serial.print(", New status: ");
                                       Serial.println(message.getBool());
                                     }  
                                   } 
                                }
                                

                                Sketch should work. Please post the serial output of this sketch.

                                My first steps would be:

                                1. Use the sketch I provided (should work, or I missed something).
                                2. Disconnect RELAY from Arduino.
                                3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                                Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                                If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                                R Offline
                                R Offline
                                Reza
                                wrote on last edited by
                                #36

                                @TheoL said:

                                @Reza

                                So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                                Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                                #include <MySensor.h>
                                #include <SPI.h>
                                
                                #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                                #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                                #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                                #define SKETCH_NAME      "Relay"
                                #define SKETCH_VERSION   "1.0"
                                
                                // Construct MySensors library
                                MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                                
                                void setup() {
                                  gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                  gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                                
                                  for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                    gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                    pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                    digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                    gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                    gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                    gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                  }
                                }
                                
                                
                                void loop() {
                                  // Alway process incoming messages whenever possible
                                  gw.process();
                                }
                                
                                void incomingMessage(const MyMessage &message) {
                                  if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                     int relayPin = RELAY_1 + message.sensor - 1;
                                     if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                       digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                                
                                       // Write some debug info
                                       Serial.print("Incoming change for sensor:");
                                       Serial.print(message.sensor);
                                       Serial.print( ", relay_pin: " );
                                       Serial.print( relayPin );
                                       Serial.print(", New status: ");
                                       Serial.println(message.getBool());
                                     }  
                                   } 
                                }
                                

                                Sketch should work. Please post the serial output of this sketch.

                                My first steps would be:

                                1. Use the sketch I provided (should work, or I missed something).
                                2. Disconnect RELAY from Arduino.
                                3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                                Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                                If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                                very very thank you , i will test this and i will comeback <3

                                1 Reply Last reply
                                1
                                • TheoLT TheoL

                                  @Reza

                                  So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                                  Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                                  #include <MySensor.h>
                                  #include <SPI.h>
                                  
                                  #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                  #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                                  #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                                  #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                                  #define SKETCH_NAME      "Relay"
                                  #define SKETCH_VERSION   "1.0"
                                  
                                  // Construct MySensors library
                                  MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                                  
                                  void setup() {
                                    gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                    gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                                  
                                    for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                      gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                      pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                      digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                      gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                      gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                      gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                    }
                                  }
                                  
                                  
                                  void loop() {
                                    // Alway process incoming messages whenever possible
                                    gw.process();
                                  }
                                  
                                  void incomingMessage(const MyMessage &message) {
                                    if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                       int relayPin = RELAY_1 + message.sensor - 1;
                                       if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                         digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                                  
                                         // Write some debug info
                                         Serial.print("Incoming change for sensor:");
                                         Serial.print(message.sensor);
                                         Serial.print( ", relay_pin: " );
                                         Serial.print( relayPin );
                                         Serial.print(", New status: ");
                                         Serial.println(message.getBool());
                                       }  
                                     } 
                                  }
                                  

                                  Sketch should work. Please post the serial output of this sketch.

                                  My first steps would be:

                                  1. Use the sketch I provided (should work, or I missed something).
                                  2. Disconnect RELAY from Arduino.
                                  3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                                  Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                                  If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                                  R Offline
                                  R Offline
                                  Reza
                                  wrote on last edited by Reza
                                  #37

                                  @TheoL said:

                                  @Reza

                                  So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                                  Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                                  #include <MySensor.h>
                                  #include <SPI.h>
                                  
                                  #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                  #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                                  #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                                  #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                                  #define SKETCH_NAME      "Relay"
                                  #define SKETCH_VERSION   "1.0"
                                  
                                  // Construct MySensors library
                                  MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                                  
                                  void setup() {
                                    gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                    gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                                  
                                    for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                      gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                      pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                      digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                      gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                      gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                      gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                    }
                                  }
                                  
                                  
                                  void loop() {
                                    // Alway process incoming messages whenever possible
                                    gw.process();
                                  }
                                  
                                  void incomingMessage(const MyMessage &message) {
                                    if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                       int relayPin = RELAY_1 + message.sensor - 1;
                                       if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                         digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                                  
                                         // Write some debug info
                                         Serial.print("Incoming change for sensor:");
                                         Serial.print(message.sensor);
                                         Serial.print( ", relay_pin: " );
                                         Serial.print( relayPin );
                                         Serial.print(", New status: ");
                                         Serial.println(message.getBool());
                                       }  
                                     } 
                                  }
                                  

                                  Sketch should work. Please post the serial output of this sketch.

                                  My first steps would be:

                                  1. Use the sketch I provided (should work, or I missed something).
                                  2. Disconnect RELAY from Arduino.
                                  3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                                  Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                                  If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                                  @TheoL this is trueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee <3 <3 <3

                                  so where was problem ? so this sketch will work for 4 or 8 channel ?
                                  this problem was just for me ? or all ?

                                  TheoLT 1 Reply Last reply
                                  0
                                  • R Reza

                                    @TheoL said:

                                    @Reza

                                    So I took your Sketch and refactored it. Just to be sure that nothing strange is in the code. I don't think there was anything strange in it. I just don't like the ID of defining one relay and calculate the others. But that's just me. I'd like to be able to debug, but with the way this sketch is set-up, checking what might be wrong is just harder to do.

                                    Haven't tested it on an Arduino, don't have any empty breadboard at the moment.

                                    #include <MySensor.h>
                                    #include <SPI.h>
                                    
                                    #define RELAY_1          3     // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                    #define NUMBER_OF_RELAYS 2     // Total number of attached relays
                                    #define RELAY_ON         HIGH  // GPIO value to write to turn on attached relay
                                    #define RELAY_OFF        LOW   // GPIO value to write to turn off attached relay
                                    #define SKETCH_NAME      "Relay"
                                    #define SKETCH_VERSION   "1.0"
                                    
                                    // Construct MySensors library
                                    MySensor gw; // don't bother with singing yet. First get the sketch and hardware to work...!!!!
                                    
                                    void setup() {
                                      gw.begin( incomingMessage, AUTO, true ); // Initialize library and add callback for incoming messages
                                      gw.sendSketchInfo( SKETCH_NAME, SKETCH_VERSION); // Send the sketch version information to the gateway and Controller
                                    
                                      for ( int sensor = 0; sensor < NUMBER_OF_RELAYS; sensor++ ) {
                                        gw.present( sensor + 1, S_LIGHT );           // Present the actuator to the GW
                                        pinMode( RELAY_1 + sensor, OUTPUT );         // Assign Relay_pin as output
                                        digitalWrite( RELAY_1 + sensor, RELAY_OFF ); // turn of the relay (some relay need inverted value. You'll have to check yours.). Turning it of is for safety!!!
                                        gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                        gw.request( sensor + 1, V_LIGHT );           // Request current state from Home Automation controller. I just don't see any reason to store it in the EPROM
                                        gw.wait( 50 );                               // my gateway sometimes just can't handle to much child presents after each other
                                      }
                                    }
                                    
                                    
                                    void loop() {
                                      // Alway process incoming messages whenever possible
                                      gw.process();
                                    }
                                    
                                    void incomingMessage(const MyMessage &message) {
                                      if ( message.type==V_LIGHT ) { // We only expect one type of message from controller. But we better check anyway.
                                         int relayPin = RELAY_1 + message.sensor - 1;
                                         if ( message.sensor >= 1 && message.sensor <= NUMBER_OF_RELAYS ) { // make sure message is for a known pin. You wouldn't want to write to a pin that's being used for the radio.
                                           digitalWrite( relayPin, message.getBool() ? RELAY_ON : RELAY_OFF ); // Change relay state
                                    
                                           // Write some debug info
                                           Serial.print("Incoming change for sensor:");
                                           Serial.print(message.sensor);
                                           Serial.print( ", relay_pin: " );
                                           Serial.print( relayPin );
                                           Serial.print(", New status: ");
                                           Serial.println(message.getBool());
                                         }  
                                       } 
                                    }
                                    

                                    Sketch should work. Please post the serial output of this sketch.

                                    My first steps would be:

                                    1. Use the sketch I provided (should work, or I missed something).
                                    2. Disconnect RELAY from Arduino.
                                    3. Connect LEDs to the arduino with resistor (330 Ohm should be just fine)

                                    Test this. The reason I would remove the relay is to be sure there's no power issue. The arduino should be able to provide enough power for driving a simple LED.

                                    If this works you know that it's a hardware problem and from there on, you can investigate what the problem is.

                                    @TheoL this is trueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee <3 <3 <3

                                    so where was problem ? so this sketch will work for 4 or 8 channel ?
                                    this problem was just for me ? or all ?

                                    TheoLT Offline
                                    TheoLT Offline
                                    TheoL
                                    Contest Winner
                                    wrote on last edited by
                                    #38

                                    @Reza The Sketch is working? If so great. I wasn't sure, because I wasn't able to test it. I can't tell what was wrong. I just rewrote it. In theory it's possible to add 6 relays this way. This is because pin 9 is in use by the NFR24L01+ antenna. You could use pin 2 as a starting pin (you don't need to connect the radio to pin 2, because it's not using it). So you might be able to add up 7 relays with this sketch.

                                    Because you also have pin 0 + 1 and the 6 analog pins, you can add up to 15 relays, but you'll need a different Sketch for this. Just let me now if you can get it to work with the max of 7 relays.

                                    R 1 Reply Last reply
                                    1
                                    • TheoLT TheoL

                                      @Reza The Sketch is working? If so great. I wasn't sure, because I wasn't able to test it. I can't tell what was wrong. I just rewrote it. In theory it's possible to add 6 relays this way. This is because pin 9 is in use by the NFR24L01+ antenna. You could use pin 2 as a starting pin (you don't need to connect the radio to pin 2, because it's not using it). So you might be able to add up 7 relays with this sketch.

                                      Because you also have pin 0 + 1 and the 6 analog pins, you can add up to 15 relays, but you'll need a different Sketch for this. Just let me now if you can get it to work with the max of 7 relays.

                                      R Offline
                                      R Offline
                                      Reza
                                      wrote on last edited by
                                      #39

                                      @TheoL said:

                                      @Reza The Sketch is working? If so great. I wasn't sure, because I wasn't able to test it. I can't tell what was wrong. I just rewrote it. In theory it's possible to add 6 relays this way. This is because pin 9 is in use by the NFR24L01+ antenna. You could use pin 2 as a starting pin (you don't need to connect the radio to pin 2, because it's not using it). So you might be able to add up 7 relays with this sketch.

                                      Because you also have pin 0 + 1 and the 6 analog pins, you can add up to 15 relays, but you'll need a different Sketch for this. Just let me now if you can get it to work with the max of 7 relays.

                                      yes this is working true.
                                      ok.
                                      very very very very thank you <3 <3 <3

                                      TheoLT 1 Reply Last reply
                                      0
                                      • R Reza

                                        @TheoL said:

                                        @Reza The Sketch is working? If so great. I wasn't sure, because I wasn't able to test it. I can't tell what was wrong. I just rewrote it. In theory it's possible to add 6 relays this way. This is because pin 9 is in use by the NFR24L01+ antenna. You could use pin 2 as a starting pin (you don't need to connect the radio to pin 2, because it's not using it). So you might be able to add up 7 relays with this sketch.

                                        Because you also have pin 0 + 1 and the 6 analog pins, you can add up to 15 relays, but you'll need a different Sketch for this. Just let me now if you can get it to work with the max of 7 relays.

                                        yes this is working true.
                                        ok.
                                        very very very very thank you <3 <3 <3

                                        TheoLT Offline
                                        TheoLT Offline
                                        TheoL
                                        Contest Winner
                                        wrote on last edited by
                                        #40

                                        @Reza Glad that I could help. I was just thinking. I've added a wait in between the presentation of the relays childs to the gateway. Maybe that made the difference. Anyway good luck and enjoy the greatness of MySensors and it's wonderful community.

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


                                        28

                                        Online

                                        11.7k

                                        Users

                                        11.2k

                                        Topics

                                        113.1k

                                        Posts


                                        Copyright 2025 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