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

    @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 Online
    TheoLT Online
    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 Online
            TheoLT Online
            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 Online
                  TheoLT Online
                  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 Online
                      TheoLT Online
                      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


                      21

                      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