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. My Project
  3. Curtain Control Node.

Curtain Control Node.

Scheduled Pinned Locked Moved My Project
domoticzcurtain controlmysensors node
51 Posts 15 Posters 20.0k Views 22 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.
  • Tore André RosanderT Tore André Rosander

    @AWI Thank you, that helped :)
    I now have it up and running.

    But how do i connect and use this with a controller (like Domoticz)?

    I use an ESP gateway (from the dev branch) and the curtain node is connected and showing up in domoticz.
    But how do i make domoticz send commands to the curtain node?

    All i get when adding the curtain node both as on/off button and blinds in domoticz is "unreconized" in the curtain serial monoitor.

    AWIA Offline
    AWIA Offline
    AWI
    Hero Member
    wrote on last edited by
    #20

    @Tore-André-Rosander I have defined it as "Blinds Percentage" in Domoticz. This send the V_STATUS and V_PERCENTAGE messages where the node should respond to...
    0_1458557025507_upload-d16cb932-d511-433f-9488-112b68d308f4

    Tore André RosanderT 1 Reply Last reply
    0
    • AWIA AWI

      @Tore-André-Rosander I have defined it as "Blinds Percentage" in Domoticz. This send the V_STATUS and V_PERCENTAGE messages where the node should respond to...
      0_1458557025507_upload-d16cb932-d511-433f-9488-112b68d308f4

      Tore André RosanderT Offline
      Tore André RosanderT Offline
      Tore André Rosander
      wrote on last edited by
      #21

      @AWI THanks again for your fast replys!

      This is what i get in serial monitor when i use the "up" "down" buttons for blinds percentage in domoticz.

      This is my very first MySensor setup so it might be some error with my setup, i will have a deeper look at it later tonight.

      Starting sensor (RNNNA-, 2.0.0-beta)
      Radio init successful.
      State read: -1
      State read: -1
      send: 13-13-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 13-13-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:2.0.0-beta
      send: 13-13-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      read: 0-0-13 s=255,c=3,t=15,pt=0,l=2,sg=0:
      read: 0-0-13 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      send: 13-13-0-0 s=1,c=0,t=5,pt=0,l=7,sg=0,st=ok:Curtain
      send: 13-13-0-0 s=255,c=3,t=11,pt=0,l=18,sg=0,st=ok:Curtain control 13
      send: 13-13-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      Init complete, id=13, parent=0, distance=1
      read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
      Message - valid: 1, Unrecognized```
      AWIA 1 Reply Last reply
      0
      • Tore André RosanderT Tore André Rosander

        @AWI THanks again for your fast replys!

        This is what i get in serial monitor when i use the "up" "down" buttons for blinds percentage in domoticz.

        This is my very first MySensor setup so it might be some error with my setup, i will have a deeper look at it later tonight.

        Starting sensor (RNNNA-, 2.0.0-beta)
        Radio init successful.
        State read: -1
        State read: -1
        send: 13-13-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
        send: 13-13-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:2.0.0-beta
        send: 13-13-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
        read: 0-0-13 s=255,c=3,t=15,pt=0,l=2,sg=0:
        read: 0-0-13 s=255,c=3,t=6,pt=0,l=1,sg=0:M
        send: 13-13-0-0 s=1,c=0,t=5,pt=0,l=7,sg=0,st=ok:Curtain
        send: 13-13-0-0 s=255,c=3,t=11,pt=0,l=18,sg=0,st=ok:Curtain control 13
        send: 13-13-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
        Init complete, id=13, parent=0, distance=1
        read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=29,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized read: 0-0-13 s=1,c=1,t=30,pt=0,l=0,sg=0:
        Message - valid: 1, Unrecognized```
        AWIA Offline
        AWIA Offline
        AWI
        Hero Member
        wrote on last edited by
        #22

        @Tore-André-Rosander Nothing wrong with you interpretation. I have not written this sketch as a complete S_COVER implementation. Only the V_PERCENTAGE part (not V_UP/V_DOWN). If you define it in Domoticz as "Blinds percentage" (see my previous post) it will work. Sorry for the confusion.

        Tore André RosanderT 1 Reply Last reply
        0
        • AWIA AWI

          @Tore-André-Rosander Nothing wrong with you interpretation. I have not written this sketch as a complete S_COVER implementation. Only the V_PERCENTAGE part (not V_UP/V_DOWN). If you define it in Domoticz as "Blinds percentage" (see my previous post) it will work. Sorry for the confusion.

          Tore André RosanderT Offline
          Tore André RosanderT Offline
          Tore André Rosander
          wrote on last edited by
          #23

          @AWI Seems like my problem is with Domoticz itselfe.
          I have the same problem as described in this post https://www.domoticz.com/forum/viewtopic.php?f=6&t=7748

          AWIA 1 Reply Last reply
          0
          • Tore André RosanderT Tore André Rosander

            @AWI Seems like my problem is with Domoticz itselfe.
            I have the same problem as described in this post https://www.domoticz.com/forum/viewtopic.php?f=6&t=7748

            AWIA Offline
            AWIA Offline
            AWI
            Hero Member
            wrote on last edited by
            #24

            @Tore-André-Rosander You can probably solve it by deleting the sensor in Domoticz and let the sketch present itself as S_DIMMER (and use another sensor id)

            1 Reply Last reply
            0
            • Tore André RosanderT Offline
              Tore André RosanderT Offline
              Tore André Rosander
              wrote on last edited by
              #25

              Maybe its because i have not calibrated it? I dont have any pushbuttons laying around, so im gonna make one with some wires. But i see that there is two pins defined as buttons. Should i use the buttonPin1 as VCC?

              So it would look something like buttonPin1 -> buttonPin2 -> button -> gnd?

              AWIA 1 Reply Last reply
              0
              • Tore André RosanderT Tore André Rosander

                Maybe its because i have not calibrated it? I dont have any pushbuttons laying around, so im gonna make one with some wires. But i see that there is two pins defined as buttons. Should i use the buttonPin1 as VCC?

                So it would look something like buttonPin1 -> buttonPin2 -> button -> gnd?

                AWIA Offline
                AWIA Offline
                AWI
                Hero Member
                wrote on last edited by
                #26

                @Tore-André-Rosander You can ignore buttonpin2. Just connect your "button" to buttonpin1 and ground.

                1 Reply Last reply
                0
                • AWIA AWI

                  Looks good. I am curious to see the details... jealous for the speed :runner: your curtain is moving.

                  I have been working on a similar project last week. The mechanics and ´looks´ are the most difficult part for me.

                  For now I have used a ´tuned´ cheap & small stepper which makes it slooow but effective ;-) The rail and mounting is standard IKEA. The pro-mini has the jModule attached. Works like a charm (/snail)!

                  0_1457980545567_upload-c50fc1e9-f23e-458d-a812-62ad4bf478e0
                  0_1457981153586_upload-c7064209-3900-4e4b-b335-8c88721367c0

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

                  @AWI I'm curious where you got the rails for the curtain. I wasn't been able to find them, but stumbled on this topic.

                  AWIA 1 Reply Last reply
                  0
                  • TheoLT TheoL

                    @AWI I'm curious where you got the rails for the curtain. I wasn't been able to find them, but stumbled on this topic.

                    AWIA Offline
                    AWIA Offline
                    AWI
                    Hero Member
                    wrote on last edited by
                    #28

                    @TheoL Ikea :smile:

                    TheoLT 1 Reply Last reply
                    0
                    • AWIA AWI

                      @TheoL Ikea :smile:

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

                      @AWI Really interested in the mechanics ;-)

                      1 Reply Last reply
                      0
                      • franzelareF Offline
                        franzelareF Offline
                        franzelare
                        wrote on last edited by
                        #30

                        I'm currently working on a similar project, only I got started with 24V DC motors that I got from my work (left overs from a test project) These motors are very strong (way way over rated) and have a big gearbox what unfortunately makes the movement a bit slow.
                        I started off with 1 motor to move 2 curtains at the same time, but will change this to 2 motors for either side since the better half of me likes to control the curtains separately in case she only wants to close 1.
                        Next to the automation there will also be a manual control switch be hidden behind the curtains in case the node is down and I'm not at home to fix the issue...
                        all running on an ESP8266 (ESP-12e) unit to have it over WiFi and have enough io

                        Currently the test setup is working fine and I'm ordering parts to start implementing this a bit bigger in the first room. the test setup I made with some old wood 1 meter of rail and a few old rugs as curtains...
                        alt text

                        I use a GT2 timing belt that is commently used for 3D printers and pully's are widely available as well as the belts in different lengths (I order them on rolls of 10 meters) and attached the timing belt to a carriage that is normally to pull the curtains with a rod.
                        alt text

                        the motor is mounted on a bracket with currently 2 end stop switches for open and close (but will be 1 switch for open and 1 for close in the final solution)
                        alt text

                        resulting in driving the curtain from 1 side
                        alt text

                        alt text

                        electronics are working fine now and need to be ported to a test print and later to a real PCB design

                        alt text

                        alt text

                        1 Reply Last reply
                        3
                        • R Offline
                          R Offline
                          romeok01
                          wrote on last edited by romeok01
                          #31

                          Hello.

                          To my project i use stepper motor JK42HS34-0404 and driver L298N.

                          This is a wiring diagram.
                          alt text

                          This is a program code that I use

                          #include <MySensor.h>  
                          #include <SPI.h>
                          #include <AccelStepper.h>
                          #define HALFSTEP 4  // Stepper uses "Halfstep" mode
                          #define CURTAIN_CLOSED 1000 // value when closed
                          #define CURTAIN_OPEN 0 // value when open
                          #define CHILD_ID 1   // Id of the sensor child
                          // MySensors definitions
                          MySensor gw;
                          // Initialize message
                          MyMessage msg(CHILD_ID, V_TRIPPED);
                          
                          
                          // Motor pin definitions
                          #define motorPin1  3     // IN1 on the ULN2003 driver 1
                          #define motorPin2  4     // IN2 on the ULN2003 driver 1
                          #define motorPin3  5     // IN3 on the ULN2003 driver 1
                          #define motorPin4  6     // IN4 on the ULN2003 driver 1
                          
                          // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
                          AccelStepper stepper1(HALFSTEP, motorPin1, motorPin2, motorPin3, motorPin4);
                          
                          unsigned long current_position ; // remembers current position, need to be saved in EEPROM?
                          
                          void setup() {
                            // MySensors
                            gw.begin(); // fixed node 13
                            gw.sendSketchInfo("Curtain control 13", "1.0"); // Send the sketch version information to the gateway and Controller
                          
                            //pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                            // Register all sensors to gw (they will be created as child devices)
                            gw.present(CHILD_ID, S_COVER); // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
                            
                            stepper1.setMaxSpeed(500.0);
                            stepper1.setAcceleration(700.0);
                            stepper1.moveTo(CURTAIN_OPEN);
                            
                            current_position = CURTAIN_OPEN ;
                            stepper1.moveTo(CURTAIN_OPEN);
                          }//--(end setup )---
                          
                          void loop() {
                            // if message = V_UP start moving until closed
                            // if message = V_DOWN start moving back until open
                            // if message = V_STOP stop moving
                            // Test: Change direction when the stepper reaches the target position
                            gw.process(); // check if message from controller
                            if (stepper1.distanceToGo() == 0){
                              if (stepper1.currentPosition() == CURTAIN_OPEN){
                                stepper1.moveTo(CURTAIN_CLOSED);
                                Serial.println("Curtain Open, now closing");
                                gw.request(CHILD_ID, V_UP, 0); // request new values from controller  
                              }
                              else{
                                stepper1.moveTo(CURTAIN_OPEN);
                                Serial.println("Curtain Closed, now opening");
                                gw.request(CHILD_ID, V_DOWN, 0); // request new values from controller   
                              }
                            }
                            
                            stepper1.run();
                          }
                          
                          // This is called when a message is received 
                          void incomingMessage(const MyMessage &message) {
                            // We only expect few types of messages from controller, check which
                            stepper1.moveTo(message.getInt() * CURTAIN_CLOSED/100);
                            Serial.print("Message - valid: ");
                            Serial.print(message.sensor);
                            Serial.print(" , value: % ");
                            Serial.println(message.getInt());
                            switch (message.getInt()) {
                            case 100:
                              // Curtain should be opened
                               Serial.print("Message - valid: ");
                               Serial.print(message.sensor);
                               Serial.print(", Message UP ");
                               stepper1.moveTo(CURTAIN_OPEN);
                               break;
                            case 0:
                              // Curtain should be closed
                               Serial.print("Message - valid: ");
                               Serial.print(message.sensor);
                               Serial.print(", Message DOWN ");
                               stepper1.moveTo(CURTAIN_CLOSED);
                              break;
                            case 50:
                              // Curtain action should be stopped
                               Serial.print("Message - valid: ");
                               Serial.print(message.sensor);
                               Serial.print(", Message STOP ");
                              break;
                            default: 
                              // not recognizable message
                               Serial.print("Message - valid: ");
                               Serial.print(message.sensor);
                               Serial.print(", Unrecognized ");
                          
                            }
                           
                          }
                          

                          When the program I have uploaded to my mysensors, the engine still turns, one left and one to the right and did not work the button blinds in Domoticz.

                          I cant turn off my stepper motor in Domoticz.

                          https://www.youtube.com/embed/1Wc1p_9YDQQ

                          Please help me.

                          1 Reply Last reply
                          1
                          • R Offline
                            R Offline
                            romeok01
                            wrote on last edited by
                            #32

                            I write a program on library Stepper not AccelStepper.
                            Now is working.

                            Program code:

                            // 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 <MySensors.h>
                            #include <Stepper.h>
                            
                            #define CURTAIN_CLOSED 1000  // wartosc gdy kurtyna zamknieta
                            #define CURTAIN_OPEN -1000         // wartosc gdy kurtyna otwarta 
                            #define CHILD_ID 1
                            
                            // definicje MySensors 
                            
                            MyMessage message(CHILD_ID, S_COVER);
                            
                            int in1Pin = 3;
                            int in2Pin = 4;
                            int in3Pin = 5;
                            int in4Pin = 6;
                            int lastState;
                             
                            // liczba kroków na jeden obrót
                            #define stepsPerRevolution 200
                            
                            //ustawienie szybkości silnika 
                            int motorSpeed = 40;
                            
                            Stepper myStepper(stepsPerRevolution, in1Pin, in2Pin, in3Pin, in4Pin);
                            
                            void setup() {
                              
                            // ustawienie pinów jako wyjście
                              pinMode(in1Pin, OUTPUT);
                              pinMode(in2Pin, OUTPUT);
                              pinMode(in3Pin, OUTPUT);
                              pinMode(in4Pin, OUTPUT);
                            // ustawienie szybkosci silnika
                              myStepper.setSpeed(motorSpeed);
                            }
                            
                            void presentation()  
                            { 
                              // Wyslanie informacji o wersji programu
                              sendSketchInfo("Program kurtyna", "1.0");
                              // Register all sensors to gw (they will be created as child devices)
                              present(CHILD_ID, S_COVER); // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
                            }
                            
                            void receive(const MyMessage &message) {
                              // if message = V_UP start moving until closed
                              if (message.type==V_UP) {
                                 myStepper.step(CURTAIN_OPEN);
                                 // Store state in eeprom
                                 saveState(message.sensor, message.getBool());
                                 request(CHILD_ID, V_UP, 0); // request new values from controller
                                    }
                                 
                             if (message.type==V_DOWN) {
                                 myStepper.step(CURTAIN_CLOSED);
                                 // Store state in eeprom
                                 saveState(message.sensor, message.getBool());
                                 request(CHILD_ID, V_DOWN, 0); // request new values from controller
                                    } 
                            }
                            
                            

                            I use MySensors Library 2.0

                            Youtube film

                            https://www.youtube.com/embed/gm0r2kDXrt4

                            1 Reply Last reply
                            2
                            • franzelareF Offline
                              franzelareF Offline
                              franzelare
                              wrote on last edited by
                              #33

                              your wiring diagram is not accessable:
                              Error (403)
                              It seems you don't belong here! You should probably sign in. Check out our Help Center and forums for help, or head back to home.

                              i use a DC motor so can't help with stepper motors, but can you share an image of how you setup your rails?

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                romeok01
                                wrote on last edited by
                                #34

                                Now the wiring diagram should be visible.

                                1 Reply Last reply
                                1
                                • R Offline
                                  R Offline
                                  romeok01
                                  wrote on last edited by
                                  #35

                                  I write program with AccelStepper library

                                  / 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 <MySensors.h>
                                  #include <AccelStepper.h>      //import biblioteki AccelStepper 
                                  
                                  #define HALFSTEP 8
                                  #define CURTAIN_CLOSED 2000  // wartosc gdy kurtyna zamknieta
                                  #define CURTAIN_OPEN 0       // wartosc gdy kurtyna otwarta
                                  #define CHILD_ID 1
                                  
                                  // definicje MySensors
                                  
                                  MyMessage message(CHILD_ID, S_COVER);
                                  
                                  // Definicja pinow silnika
                                  #define IN1  3     // IN1 - zielony
                                  #define IN2  4     // IN2 - czarny
                                  #define IN3  5     // IN3 - niebieski
                                  #define IN4  6     // IN4 - czerwony
                                   
                                  AccelStepper stepper1(HALFSTEP, IN1, IN2, IN3, IN4);
                                  
                                  void setup()
                                  {
                                    stepper1.setMaxSpeed(200.0);
                                    stepper1.setAcceleration(1000.0);
                                    stepper1.setSpeed(200);
                                    stepper1.moveTo(CURTAIN_OPEN);
                                  }
                                  
                                  void presentation() 
                                  {
                                    // Wyslanie informacji o wersji programu
                                    sendSketchInfo("Program kurtyna", "1.0");
                                    // Register all sensors to gw (they will be created as child devices)
                                    present(CHILD_ID, S_COVER); // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
                                  }
                                  
                                  void loop()
                                  {
                                    stepper1.run();  //Start
                                  }
                                  
                                  void receive(const MyMessage &message)
                                  {
                                    // if message = V_UP start moving until closed
                                    if (message.type==V_UP) {
                                       if (stepper1.distanceToGo() == 0){
                                           if (stepper1.currentPosition() == CURTAIN_OPEN){
                                               stepper1.moveTo(CURTAIN_CLOSED);
                                       // Store state in eeprom
                                       saveState(message.sensor, message.getBool());
                                       request(CHILD_ID, V_UP, 0); // request new values from controller
                                           }
                                        }
                                     }
                                     if (message.type==V_DOWN) {
                                         stepper1.moveTo(CURTAIN_OPEN);
                                         // Store state in eeprom
                                         saveState(message.sensor, message.getBool());
                                         request(CHILD_ID, V_DOWN, 0); // request new values from controller   
                                      }
                                      if (message.type==V_STOP) {
                                          stepper1.setCurrentPosition(0);
                                          // Store state in eeprom
                                          saveState(message.sensor, message.getBool());
                                          request(CHILD_ID, V_STOP, 0); // request new values from controller
                                      }
                                  }
                                  
                                  

                                  I use MySensors library 2.0

                                  Now i working.

                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    jacikaas
                                    wrote on last edited by
                                    #36

                                    Hello,

                                    I trying to adopt the code for 28BYJ-48 stepper motor with ULN2003 driver board for roller blinds control. Code is working, but when the stepper motor is always on - it gets hot. Because of it also its consumes more energy. So thats why I want to turn on ULN2003 board only when new action is started, and after that it should be shuted down again. I could do it, because ULN2003 has On/Off jumper:
                                    alt text

                                    Question #1: I trying to use relay for that On/Off. Could I do it without relay and control On/Off jumper directly from arduino? Does relay is the best solution?

                                    Question #2: I suck at programming, but I trying to add theese lines to my code to control the relay SIL05-1A72-71D, which controls the ULN2003 driver board:
                                    int powerPin = 7; //before SETUP
                                    pinMode(powerPin, OUTPUT); // In SETUP
                                    digitalWrite(powerPin, LOW); // In SETUP
                                    digitalWrite(powerPin, HIGH); // In void receive function
                                    delay(CURTAIN_CLOSED); // In void receive function
                                    digitalWrite(powerPin, LOW); // In void receive function

                                    digitalWrite(powerPin, HIGH); - I think is in right position, but I don't know how to turn off relay when action is done. Please advise for coding, because I not good in it. Thank You! Below is the code:

                                    // Enable debug prints to serial monitor
                                    #define MY_DEBUG
                                    
                                    // Enable and select radio type attached
                                    #define MY_NODE_ID 10
                                    #define MY_RADIO_NRF24
                                    //#define MY_RADIO_RFM69
                                    
                                    // Enable repeater functionality for this node
                                    //#define MY_REPEATER_FEATURE
                                    
                                    #include <SPI.h>
                                    #include <MySensors.h>
                                    #include <AccelStepper.h>      //import biblioteki AccelStepper 
                                    
                                    #define HALFSTEP 8
                                    #define CURTAIN_CLOSED 10000  // wartosc gdy kurtyna zamknieta
                                    #define CURTAIN_OPEN 0       // wartosc gdy kurtyna otwarta
                                    #define CHILD_ID 1
                                    
                                    int powerPin = 7;
                                    
                                    // definicje MySensors
                                    
                                    MyMessage message(CHILD_ID, S_COVER);
                                    
                                    // Definicja pinow silnika
                                    #define IN1  3     // IN1 - zielony
                                    #define IN2  4     // IN2 - czarny
                                    #define IN3  5     // IN3 - niebieski
                                    #define IN4  6     // IN4 - czerwony
                                     
                                    AccelStepper stepper1(HALFSTEP, IN1, IN3, IN2, IN4);
                                    
                                    void setup()
                                    {
                                      stepper1.setMaxSpeed(1000.0);
                                      stepper1.setAcceleration(100.0);
                                      stepper1.setSpeed(200);
                                      stepper1.moveTo(CURTAIN_OPEN);
                                      
                                      pinMode(powerPin, OUTPUT);
                                      digitalWrite(powerPin, LOW);
                                    }
                                    
                                    void presentation() 
                                    {
                                      // Wyslanie informacji o wersji programu
                                      sendSketchInfo("Roller blinds", "1.0");
                                      // Register all sensors to gw (they will be created as child devices)
                                      present(CHILD_ID, S_COVER); // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
                                    }
                                    
                                    void loop()
                                    {
                                      stepper1.run();  //Start
                                    }
                                    
                                    void receive(const MyMessage &message)
                                    {
                                      // if message = V_UP start moving until closed
                                      if (message.type==V_UP) {
                                         digitalWrite(powerPin, HIGH);
                                         if (stepper1.distanceToGo() == 0){
                                             if (stepper1.currentPosition() == CURTAIN_OPEN){
                                                 stepper1.moveTo(CURTAIN_CLOSED);
                                         // Store state in eeprom
                                         saveState(message.sensor, message.getBool());
                                         request(CHILD_ID, V_UP, 0); // request new values from controller
                                             }
                                          }
                                       }
                                       if (message.type==V_DOWN) {
                                           digitalWrite(powerPin, HIGH);
                                           stepper1.moveTo(CURTAIN_OPEN);
                                           // Store state in eeprom
                                           saveState(message.sensor, message.getBool());
                                           request(CHILD_ID, V_DOWN, 0); // request new values from controller   
                                        }
                                        if (message.type==V_STOP) {
                                            digitalWrite(powerPin, HIGH);
                                            stepper1.setCurrentPosition(0);
                                            // Store state in eeprom
                                            saveState(message.sensor, message.getBool());
                                            request(CHILD_ID, V_STOP, 0); // request new values from controller
                                        }
                                     //   delay(CURTAIN_CLOSED);
                                     //   digitalWrite(powerPin, LOW);
                                    }
                                    
                                    
                                    Suresh MaliS 1 Reply Last reply
                                    0
                                    • J jacikaas

                                      Hello,

                                      I trying to adopt the code for 28BYJ-48 stepper motor with ULN2003 driver board for roller blinds control. Code is working, but when the stepper motor is always on - it gets hot. Because of it also its consumes more energy. So thats why I want to turn on ULN2003 board only when new action is started, and after that it should be shuted down again. I could do it, because ULN2003 has On/Off jumper:
                                      alt text

                                      Question #1: I trying to use relay for that On/Off. Could I do it without relay and control On/Off jumper directly from arduino? Does relay is the best solution?

                                      Question #2: I suck at programming, but I trying to add theese lines to my code to control the relay SIL05-1A72-71D, which controls the ULN2003 driver board:
                                      int powerPin = 7; //before SETUP
                                      pinMode(powerPin, OUTPUT); // In SETUP
                                      digitalWrite(powerPin, LOW); // In SETUP
                                      digitalWrite(powerPin, HIGH); // In void receive function
                                      delay(CURTAIN_CLOSED); // In void receive function
                                      digitalWrite(powerPin, LOW); // In void receive function

                                      digitalWrite(powerPin, HIGH); - I think is in right position, but I don't know how to turn off relay when action is done. Please advise for coding, because I not good in it. Thank You! Below is the code:

                                      // Enable debug prints to serial monitor
                                      #define MY_DEBUG
                                      
                                      // Enable and select radio type attached
                                      #define MY_NODE_ID 10
                                      #define MY_RADIO_NRF24
                                      //#define MY_RADIO_RFM69
                                      
                                      // Enable repeater functionality for this node
                                      //#define MY_REPEATER_FEATURE
                                      
                                      #include <SPI.h>
                                      #include <MySensors.h>
                                      #include <AccelStepper.h>      //import biblioteki AccelStepper 
                                      
                                      #define HALFSTEP 8
                                      #define CURTAIN_CLOSED 10000  // wartosc gdy kurtyna zamknieta
                                      #define CURTAIN_OPEN 0       // wartosc gdy kurtyna otwarta
                                      #define CHILD_ID 1
                                      
                                      int powerPin = 7;
                                      
                                      // definicje MySensors
                                      
                                      MyMessage message(CHILD_ID, S_COVER);
                                      
                                      // Definicja pinow silnika
                                      #define IN1  3     // IN1 - zielony
                                      #define IN2  4     // IN2 - czarny
                                      #define IN3  5     // IN3 - niebieski
                                      #define IN4  6     // IN4 - czerwony
                                       
                                      AccelStepper stepper1(HALFSTEP, IN1, IN3, IN2, IN4);
                                      
                                      void setup()
                                      {
                                        stepper1.setMaxSpeed(1000.0);
                                        stepper1.setAcceleration(100.0);
                                        stepper1.setSpeed(200);
                                        stepper1.moveTo(CURTAIN_OPEN);
                                        
                                        pinMode(powerPin, OUTPUT);
                                        digitalWrite(powerPin, LOW);
                                      }
                                      
                                      void presentation() 
                                      {
                                        // Wyslanie informacji o wersji programu
                                        sendSketchInfo("Roller blinds", "1.0");
                                        // Register all sensors to gw (they will be created as child devices)
                                        present(CHILD_ID, S_COVER); // Window Cover sub-type, commands: V_UP, V_DOWN, V_STOP
                                      }
                                      
                                      void loop()
                                      {
                                        stepper1.run();  //Start
                                      }
                                      
                                      void receive(const MyMessage &message)
                                      {
                                        // if message = V_UP start moving until closed
                                        if (message.type==V_UP) {
                                           digitalWrite(powerPin, HIGH);
                                           if (stepper1.distanceToGo() == 0){
                                               if (stepper1.currentPosition() == CURTAIN_OPEN){
                                                   stepper1.moveTo(CURTAIN_CLOSED);
                                           // Store state in eeprom
                                           saveState(message.sensor, message.getBool());
                                           request(CHILD_ID, V_UP, 0); // request new values from controller
                                               }
                                            }
                                         }
                                         if (message.type==V_DOWN) {
                                             digitalWrite(powerPin, HIGH);
                                             stepper1.moveTo(CURTAIN_OPEN);
                                             // Store state in eeprom
                                             saveState(message.sensor, message.getBool());
                                             request(CHILD_ID, V_DOWN, 0); // request new values from controller   
                                          }
                                          if (message.type==V_STOP) {
                                              digitalWrite(powerPin, HIGH);
                                              stepper1.setCurrentPosition(0);
                                              // Store state in eeprom
                                              saveState(message.sensor, message.getBool());
                                              request(CHILD_ID, V_STOP, 0); // request new values from controller
                                          }
                                       //   delay(CURTAIN_CLOSED);
                                       //   digitalWrite(powerPin, LOW);
                                      }
                                      
                                      
                                      Suresh MaliS Offline
                                      Suresh MaliS Offline
                                      Suresh Mali
                                      wrote on last edited by
                                      #37

                                      @jacikaas said in Curtain Control Node.:

                                      void receive(const MyMessage &message)
                                      {
                                      // if message = V_UP start moving until closed
                                      if (message.type==V_UP) {
                                      digitalWrite(powerPin, HIGH);
                                      if (stepper1.distanceToGo() == 0){
                                      if (stepper1.currentPosition() == CURTAIN_OPEN){
                                      stepper1.moveTo(CURTAIN_CLOSED);
                                      // Store state in eeprom
                                      saveState(message.sensor, message.getBool());
                                      request(CHILD_ID, V_UP, 0); // request new values from controller
                                      }
                                      }
                                      }
                                      if (message.type==V_DOWN) {
                                      digitalWrite(powerPin, HIGH);
                                      stepper1.moveTo(CURTAIN_OPEN);
                                      // Store state in eeprom
                                      saveState(message.sensor, message.getBool());
                                      request(CHILD_ID, V_DOWN, 0); // request new values from controller
                                      }
                                      if (message.type==V_STOP) {
                                      digitalWrite(powerPin, HIGH);
                                      stepper1.setCurrentPosition(0);
                                      // Store state in eeprom
                                      saveState(message.sensor, message.getBool());
                                      request(CHILD_ID, V_STOP, 0); // request new values from controller
                                      }
                                      // delay(CURTAIN_CLOSED);
                                      // digitalWrite(powerPin, LOW);
                                      }

                                      You can enable and disable outputs and try. In the following function:

                                      void receive(const MyMessage &message)
                                      
                                      //add the following at the begining of the function
                                      stepper1.enableOutputs ()
                                      //and add the following at the end in the same function.
                                      stepper1.disableOutputs ()
                                      

                                      I hope this helps haven't tried it myself.

                                      J 1 Reply Last reply
                                      0
                                      • Suresh MaliS Suresh Mali

                                        @jacikaas said in Curtain Control Node.:

                                        void receive(const MyMessage &message)
                                        {
                                        // if message = V_UP start moving until closed
                                        if (message.type==V_UP) {
                                        digitalWrite(powerPin, HIGH);
                                        if (stepper1.distanceToGo() == 0){
                                        if (stepper1.currentPosition() == CURTAIN_OPEN){
                                        stepper1.moveTo(CURTAIN_CLOSED);
                                        // Store state in eeprom
                                        saveState(message.sensor, message.getBool());
                                        request(CHILD_ID, V_UP, 0); // request new values from controller
                                        }
                                        }
                                        }
                                        if (message.type==V_DOWN) {
                                        digitalWrite(powerPin, HIGH);
                                        stepper1.moveTo(CURTAIN_OPEN);
                                        // Store state in eeprom
                                        saveState(message.sensor, message.getBool());
                                        request(CHILD_ID, V_DOWN, 0); // request new values from controller
                                        }
                                        if (message.type==V_STOP) {
                                        digitalWrite(powerPin, HIGH);
                                        stepper1.setCurrentPosition(0);
                                        // Store state in eeprom
                                        saveState(message.sensor, message.getBool());
                                        request(CHILD_ID, V_STOP, 0); // request new values from controller
                                        }
                                        // delay(CURTAIN_CLOSED);
                                        // digitalWrite(powerPin, LOW);
                                        }

                                        You can enable and disable outputs and try. In the following function:

                                        void receive(const MyMessage &message)
                                        
                                        //add the following at the begining of the function
                                        stepper1.enableOutputs ()
                                        //and add the following at the end in the same function.
                                        stepper1.disableOutputs ()
                                        

                                        I hope this helps haven't tried it myself.

                                        J Offline
                                        J Offline
                                        jacikaas
                                        wrote on last edited by
                                        #38

                                        @suresh-mali Thank You Suresh for Your answer!
                                        I disconnect relay and delete it lines from the code.

                                        I add lines to code like You said:

                                        void receive(const MyMessage &message)
                                        {
                                        stepper1.enableOutputs ();
                                         // rest of code
                                        stepper1.disableOutputs ();
                                        }
                                        

                                        It looks like it have to work because it is simple solution, but it doesn't... On driver board ULN2003, when motor is not rotating, A Led is always on. I think if command with disableOutputs would be activated, then the LED should not be on?

                                        Suresh MaliS 1 Reply Last reply
                                        0
                                        • J jacikaas

                                          @suresh-mali Thank You Suresh for Your answer!
                                          I disconnect relay and delete it lines from the code.

                                          I add lines to code like You said:

                                          void receive(const MyMessage &message)
                                          {
                                          stepper1.enableOutputs ();
                                           // rest of code
                                          stepper1.disableOutputs ();
                                          }
                                          

                                          It looks like it have to work because it is simple solution, but it doesn't... On driver board ULN2003, when motor is not rotating, A Led is always on. I think if command with disableOutputs would be activated, then the LED should not be on?

                                          Suresh MaliS Offline
                                          Suresh MaliS Offline
                                          Suresh Mali
                                          wrote on last edited by Suresh Mali
                                          #39

                                          @jacikaas Ok.

                                          //Remove this line from loop function
                                          stepper1.run(); 
                                          
                                          //Change this line
                                          stepper1.moveTo(CURTAIN_CLOSED);
                                          //to
                                          stepper1.runToPosition(CURTAIN_CLOSED);
                                          

                                          I hope this works. Also make similar changes in block which closes curtains.
                                          Refernce article: https://www.pjrc.com/teensy/td_libs_AccelStepper.html

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


                                          29

                                          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