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. General Discussion
  3. Relay on when starting up

Relay on when starting up

Scheduled Pinned Locked Moved General Discussion
9 Posts 3 Posters 1.6k Views 3 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.
  • archiijsA Offline
    archiijsA Offline
    archiijs
    wrote on last edited by
    #1

    Hi there.
    First of all sorry for this topick as I think there already is something similar, but I just can not find one.

    The problem is that two of three of my ESP nodes starts up with a relay in ON position so lights go on as, let's say, power appears. This is starting to be problem because now winter is coming and quite often I go home from work and those two lights are (and have been for the majority of the day) ON.

    I do have this in my "setup"

       // Then set relay pins in output mode
      pinMode(RELAY_PIN, OUTPUT);
      // Make sure relays and LED are off when starting up
      digitalWrite(RELAY_PIN, RELAY_OFF);
    

    but it does not change anything. The difference from light that is not on is that those two lights have relays with turns on with LOW signal so I have this at start

    #define RELAY_ON                    0
    #define RELAY_OFF                   1
    

    The Home Assistant and openhab correctly reports ON and OFF states and all else is good.
    Thanks in advance.

    petewillP 1 Reply Last reply
    0
    • archiijsA archiijs

      Hi there.
      First of all sorry for this topick as I think there already is something similar, but I just can not find one.

      The problem is that two of three of my ESP nodes starts up with a relay in ON position so lights go on as, let's say, power appears. This is starting to be problem because now winter is coming and quite often I go home from work and those two lights are (and have been for the majority of the day) ON.

      I do have this in my "setup"

         // Then set relay pins in output mode
        pinMode(RELAY_PIN, OUTPUT);
        // Make sure relays and LED are off when starting up
        digitalWrite(RELAY_PIN, RELAY_OFF);
      

      but it does not change anything. The difference from light that is not on is that those two lights have relays with turns on with LOW signal so I have this at start

      #define RELAY_ON                    0
      #define RELAY_OFF                   1
      

      The Home Assistant and openhab correctly reports ON and OFF states and all else is good.
      Thanks in advance.

      petewillP Offline
      petewillP Offline
      petewill
      Admin
      wrote on last edited by
      #2

      @archiijs can you post a picture of the wiring? My relays have two ways to connect- one keeps the circuit closed and the other open. Also, you mentioned you come home and the lights are on. Can you give more details about that?

      My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

      1 Reply Last reply
      1
      • archiijsA Offline
        archiijsA Offline
        archiijs
        wrote on last edited by
        #3

        @petewill said in Relay on when starting up:

        a picture of the wiring? My relays have two ways to connect- one ke

        Sorry for my long delay and thanks for your answer, seems like this should be the problem, I did not think about that.

        Right now, if I remember correctly lights are connected with relays normally closed contacts, and to be honest, I do not remember why I did that... It should be because of software before mysensors and some problems with that.

        As I get a lot of power cuts in this time of year nodes reboots often, so if this happens when I'm at work they stay at "ON" until I come home and switch them off.

        1 Reply Last reply
        0
        • rejoe2R Offline
          rejoe2R Offline
          rejoe2
          wrote on last edited by
          #4

          As "setup()" (at least in most cases) requires a working network connection, you may put the "turn off"-code in a different function named "before()" or "preHwInit()" to make sure they are turned off at a very early stage of the nodes reboot.

          Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

          1 Reply Last reply
          1
          • archiijsA Offline
            archiijsA Offline
            archiijs
            wrote on last edited by
            #5

            Thanks for your input and this is also a valid point. I recently discovered this when I started to power some small sensors from arduinos gpio. and found that indeed Sensors stays off until the connection is made.
            I should check and implement this to all my nodes.

            1 Reply Last reply
            0
            • rejoe2R Offline
              rejoe2R Offline
              rejoe2
              wrote on last edited by
              #6

              @archiijs Thanks for your feedback. Nevertheless: With your "old" code, the nodes should have turned off the relays, the change only assures it is done when there is no controller available at all and to a rather early point of the initialisation process.

              But when the relays stay on as long as you describe, there most likely exists a problem in the general layout of your MySensors network making the controller completely unreachable in case of power cutoffs.

              My personal bet on the root cause of this: This might happen due to the ESP's general codeing: Afaik they try to connect to the recent known network only for a distinct periode. If this has passed without the expected Wifi-AP beeing available (as it takes much longer for example to boot an ordinary router with integrated DSL-modem), it will open up it's own AP and thus will not reintegrate in your normal Wifi network. (I'n not sure if this also applies to the MySensors-ESP-code, but this is one of the reasons I personally dislike this mcu type).

              Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

              1 Reply Last reply
              0
              • archiijsA Offline
                archiijsA Offline
                archiijs
                wrote on last edited by
                #7

                @rejoe2 said in Relay on when starting up:

                he change only assures it is done when there is no controller

                Interesting thought.
                Yes, this is not the cause of the problem, but I think that it is better to move the code for turning the relay off to the beginning to improve overall experience. You know, every small change sums up.
                And my router take time to boot up

                rejoe2R 1 Reply Last reply
                0
                • archiijsA archiijs

                  @rejoe2 said in Relay on when starting up:

                  he change only assures it is done when there is no controller

                  Interesting thought.
                  Yes, this is not the cause of the problem, but I think that it is better to move the code for turning the relay off to the beginning to improve overall experience. You know, every small change sums up.
                  And my router take time to boot up

                  rejoe2R Offline
                  rejoe2R Offline
                  rejoe2
                  wrote on last edited by
                  #8

                  @archiijs You may check the available AP's in your house next time you have a power loss - if all the ESP's really open up a new one, you will never know whether you can reach all of your nodes reliably.
                  You may test this possible behaviour also by compiling a copy of an existing node to a mcu using wrong Wifi registration data.

                  Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                  1 Reply Last reply
                  0
                  • archiijsA Offline
                    archiijsA Offline
                    archiijs
                    wrote on last edited by
                    #9

                    @rejoe2 said in Relay on when starting up:

                    really open up a new one, you will never know whether you can reach all of your nodes reliably.

                    Thanks for ideas, I will start to tackle them when I get some free time. Thanks all for input.

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


                    14

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.0k

                    Posts


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

                    • Don't have an account? Register

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