Skip to content
  • 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. Announcements
  3. 💬 Relay
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

💬 Relay

Scheduled Pinned Locked Moved Announcements
139 Posts 47 Posters 33.7k Views 45 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.
  • amemo06A amemo06

    @BulldogLowell said in 💬 Relay:

    MsTimer2::

    Thanks for the MSTimer, I was not aware of it.
    And yes, definitively, having a wait() is probably the worst I could have written. Active wait cannot stay.
    My intention, in the stuff I develop, was to remove it asap and probably by handling the wait time in the loop with flags.

    Maybe I was not clear enough about my intention when I opened this thread. I have no issue with what I develop. I already had several ways to solves this. And now, I have a new one with MSTimer. Again thanks.

    I only wanted to raise the fact void receive(const MyMessage &message) may lead to trouble as 'message' content may change during processing of that function.
    And if, like many, you are not skilled enough to code/debug.., you will face erratic issues and real difficulty to understand what is going wrong.

    BulldogLowellB Offline
    BulldogLowellB Offline
    BulldogLowell
    Contest Winner
    wrote on last edited by
    #69

    @amemo06

    I only wanted to raise the fact void receive(const MyMessage &message) may lead to trouble as 'message' content may change during processing of that function.

    As I already explained... message cannot change during the function, because of constness.

    The message handler is being called again from within itself (i.e. from wait()). You would then processing any new messages on that call. It looks as if the function may not be designed to perform recursively as you are trying to do in your code, so that would explain your unexpected/undefined results.

    So yes, block during the relay's holding state or use another non-blocking method (i.e. flag or timer/callback) as you mentioned. Fully process each message before allowing the library to handle subsequent message calls.

    ;)

    fhenrycoF 1 Reply Last reply
    0
    • BulldogLowellB BulldogLowell

      @amemo06

      I only wanted to raise the fact void receive(const MyMessage &message) may lead to trouble as 'message' content may change during processing of that function.

      As I already explained... message cannot change during the function, because of constness.

      The message handler is being called again from within itself (i.e. from wait()). You would then processing any new messages on that call. It looks as if the function may not be designed to perform recursively as you are trying to do in your code, so that would explain your unexpected/undefined results.

      So yes, block during the relay's holding state or use another non-blocking method (i.e. flag or timer/callback) as you mentioned. Fully process each message before allowing the library to handle subsequent message calls.

      ;)

      fhenrycoF Offline
      fhenrycoF Offline
      fhenryco
      wrote on last edited by fhenryco
      #70

      I was looking for a solution for a low consumption relay and i was adviced in this thread to use a latching relay.
      However since i just need to switch on or off a 12V Vcc (from Li ion battery) to trigger a solenoid valve, i'm wondering whether i need a relay for that :
      looking at the schematic from post #2 in https://forum.arduino.cc/index.php?topic=436555.0 may be i coud just have my solenoid valve directly in place of the relay in the schematic. In other words , i just need a transistor and not a real relay ... just because my application is a low voltage (12V to apply directly to the Vcc in the schematic) rather than 230V one: can someone confirm ? There is a diode in the schematic : what is it needed for ?

      0_1505132986740_arduino-control-relay-schematic.png

      sundberg84S 1 Reply Last reply
      0
      • fhenrycoF fhenryco

        I was looking for a solution for a low consumption relay and i was adviced in this thread to use a latching relay.
        However since i just need to switch on or off a 12V Vcc (from Li ion battery) to trigger a solenoid valve, i'm wondering whether i need a relay for that :
        looking at the schematic from post #2 in https://forum.arduino.cc/index.php?topic=436555.0 may be i coud just have my solenoid valve directly in place of the relay in the schematic. In other words , i just need a transistor and not a real relay ... just because my application is a low voltage (12V to apply directly to the Vcc in the schematic) rather than 230V one: can someone confirm ? There is a diode in the schematic : what is it needed for ?

        0_1505132986740_arduino-control-relay-schematic.png

        sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by sundberg84
        #71

        @fhenryco

        Since an inductor (im many cases a relay coil) cannot change it's current instantly, the flyback diode provides a path for the current when the coil is switched off. Otherwise, a voltage spike will occur causing arcing on switch contacts or possibly destroying switching transistors.

        https://electronics.stackexchange.com/questions/100134/why-is-there-a-diode-connected-in-parallel-to-a-relay-coil

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        1 Reply Last reply
        1
        • rozpruwaczR Offline
          rozpruwaczR Offline
          rozpruwacz
          wrote on last edited by rozpruwacz
          #72

          treat yor solenoid as it was a relay, the difference is that relay switches flow of current, and solenoid valve switches flow of water. so You have to use the same schematic, but put your valve where the relay is. But if You want power it from a battery, choose a latching solenoid valve instead of regular solenoid valve - and that requeires different schematic.

          fhenrycoF 1 Reply Last reply
          0
          • rozpruwaczR rozpruwacz

            treat yor solenoid as it was a relay, the difference is that relay switches flow of current, and solenoid valve switches flow of water. so You have to use the same schematic, but put your valve where the relay is. But if You want power it from a battery, choose a latching solenoid valve instead of regular solenoid valve - and that requeires different schematic.

            fhenrycoF Offline
            fhenrycoF Offline
            fhenryco
            wrote on last edited by
            #73

            @rozpruwacz
            thanks, but do you mean that the schematic simply would not work for the regular valve or that it would work but not be low power cinsumption design anymore ?
            I have a regular solenoid valve but in my application the valve is normally closed and it will be only exceptionnally opened and for a short time when the 12V is applied, so i guess that i can live with it ...
            As for the transistor in the schematic, except it seems to be a NPN , i don't know if i need a particular one for it . probably i can just buy a 2N3904 , or is there a better choice?

            1 Reply Last reply
            0
            • rozpruwaczR Offline
              rozpruwaczR Offline
              rozpruwacz
              wrote on last edited by rozpruwacz
              #74

              the schematic you posted is not using latching relay/valve. it doesn't matter if it is relay or valve. both works the same and consume power when in ON state. If you plan to use it in a way that the valve will be ON for very short periods than it is not important if it is latching or not.

              when choosing a transistor for such use, You have to look at its datasheet into "absolute maximum ratings" section and check if it will handle the voltages you will apply to it. 2N3904 looks like it will handle 12V without a problem.

              fhenrycoF 1 Reply Last reply
              0
              • rozpruwaczR rozpruwacz

                the schematic you posted is not using latching relay/valve. it doesn't matter if it is relay or valve. both works the same and consume power when in ON state. If you plan to use it in a way that the valve will be ON for very short periods than it is not important if it is latching or not.

                when choosing a transistor for such use, You have to look at its datasheet into "absolute maximum ratings" section and check if it will handle the voltages you will apply to it. 2N3904 looks like it will handle 12V without a problem.

                fhenrycoF Offline
                fhenrycoF Offline
                fhenryco
                wrote on last edited by fhenryco
                #75

                @rozpruwacz
                thanks , i will use 2N2222 because the valve needs between 200 and 400 mA.
                I'v read the 2N3904 is OK for < 100 mA

                1 Reply Last reply
                0
                • fhenrycoF Offline
                  fhenrycoF Offline
                  fhenryco
                  wrote on last edited by fhenryco
                  #76

                  It works very well with the transistor and schematic posted above. I think the valve is a latching valve because it only discharges the battery when there is a transition. The only remaining problem is that the 5V arduino alone is too much power consuming. So i'm wondering if the transistor could as well work with a 3.3V arduino, that is when the signal level on the transistor Base is 3.3V rather than 5 V ... then i also could remove the arduino led but i'll need to keep the arduino regulator because my 3.7V cell voltage is too much greater than 3.3V

                  fhenrycoF 1 Reply Last reply
                  0
                  • fhenrycoF fhenryco

                    It works very well with the transistor and schematic posted above. I think the valve is a latching valve because it only discharges the battery when there is a transition. The only remaining problem is that the 5V arduino alone is too much power consuming. So i'm wondering if the transistor could as well work with a 3.3V arduino, that is when the signal level on the transistor Base is 3.3V rather than 5 V ... then i also could remove the arduino led but i'll need to keep the arduino regulator because my 3.7V cell voltage is too much greater than 3.3V

                    fhenrycoF Offline
                    fhenrycoF Offline
                    fhenryco
                    wrote on last edited by
                    #77

                    @fhenryco Actually the internal resistor of the solenoid is 27 Ohm while the resistance between C and E of the transistor in the passing state is 35 Ohm ... so it remains less than Vcc/2 for my solenoid which needs 12V ... so i need to tune my boost module at the max ==> more than 30V ... that does not seem ideal, may be i shoud choose another transistor with less internal resistor, but i have little experience with transistors : studied them a long time ago , so if someone can suggest something smart, ready to buy it ...

                    1 Reply Last reply
                    0
                    • skywatchS Offline
                      skywatchS Offline
                      skywatch
                      wrote on last edited by
                      #78

                      Can I suggest a change to this page?

                      As it stands the wiring diagram only applies to sketch 1 (without switch). It could get confusing as the 2 sketches use different pins for the relay and there is no need for this.

                      I propose that the wiring diagram be changed for the relay to be attached to pin 4.
                      The first sketch needs the relay pin to change from pin 3 to pin 4.

                      That's it. Then the diagram and sketches will work whichever way the builder wants to do it.

                      mfalkviddM 1 Reply Last reply
                      1
                      • skywatchS skywatch

                        Can I suggest a change to this page?

                        As it stands the wiring diagram only applies to sketch 1 (without switch). It could get confusing as the 2 sketches use different pins for the relay and there is no need for this.

                        I propose that the wiring diagram be changed for the relay to be attached to pin 4.
                        The first sketch needs the relay pin to change from pin 3 to pin 4.

                        That's it. Then the diagram and sketches will work whichever way the builder wants to do it.

                        mfalkviddM Offline
                        mfalkviddM Offline
                        mfalkvidd
                        Mod
                        wrote on last edited by
                        #79

                        Good idea @skywatch
                        When doing the update, we should also rename RELAY_1 to RELAY_PIN to be consistent with sketch 2.

                        1 Reply Last reply
                        0
                        • mfalkviddM Offline
                          mfalkviddM Offline
                          mfalkvidd
                          Mod
                          wrote on last edited by
                          #80

                          https://github.com/mysensors/MySensors/pull/973

                          1 Reply Last reply
                          0
                          • mfalkviddM Offline
                            mfalkviddM Offline
                            mfalkvidd
                            Mod
                            wrote on last edited by
                            #81

                            https://www.mysensors.org/build/relay has been updated with new wiring instructions (picture + table)

                            1 Reply Last reply
                            0
                            • skywatchS Offline
                              skywatchS Offline
                              skywatch
                              wrote on last edited by
                              #82

                              That looks good, only the sketchs to go....On that note I wonder if Relay_1 might not be better choice as it gives a clue to people that if they want to add a second relay then that would be Relay_2.... Just a thought and maybe not needed.... ;)

                              1 Reply Last reply
                              0
                              • HenryWhiteH Offline
                                HenryWhiteH Offline
                                HenryWhite
                                wrote on last edited by
                                #83

                                @mfalkvidd when updating the example sketch you could maybe consider my version of the relay sketch which offers some nice additions: https://forum.mysensors.org/topic/6638/multiple-relays-motion-sketch-fully-customizable-optional-timer-manual-override

                                mfalkviddM 1 Reply Last reply
                                0
                                • HenryWhiteH HenryWhite

                                  @mfalkvidd when updating the example sketch you could maybe consider my version of the relay sketch which offers some nice additions: https://forum.mysensors.org/topic/6638/multiple-relays-motion-sketch-fully-customizable-optional-timer-manual-override

                                  mfalkviddM Offline
                                  mfalkviddM Offline
                                  mfalkvidd
                                  Mod
                                  wrote on last edited by
                                  #84

                                  @HenryWhite my mind is divided when it comes to that type of sketch. Yes, it has a lot of functionality. Yes, it is probably what people need anyway. But the examples are meant to be used by someone who is just getting into diy home automation. Someone new should be able to understand as much of the sketch as possible. There should be as little as possible to trubleshoot. If the sketch is complex, most people's initial reaction will be that there is something wrong with the code, when in reality almost all newbie problems are power or wiring-related. Keeping the sketch simple helps, at lest a bit.

                                  fhenrycoF 1 Reply Last reply
                                  1
                                  • mfalkviddM mfalkvidd

                                    @HenryWhite my mind is divided when it comes to that type of sketch. Yes, it has a lot of functionality. Yes, it is probably what people need anyway. But the examples are meant to be used by someone who is just getting into diy home automation. Someone new should be able to understand as much of the sketch as possible. There should be as little as possible to trubleshoot. If the sketch is complex, most people's initial reaction will be that there is something wrong with the code, when in reality almost all newbie problems are power or wiring-related. Keeping the sketch simple helps, at lest a bit.

                                    fhenrycoF Offline
                                    fhenrycoF Offline
                                    fhenryco
                                    wrote on last edited by
                                    #85

                                    @mfalkvidd You are right but may be should there be for each sensor or actuator first the most basic sketch but also at the end of the page a complete version with all functionalities and granted to work by the mysensors team.

                                    Of course for the complicated sketch version a big warning in red letters that this is not recommended for newbies would help...

                                    fhenrycoF 1 Reply Last reply
                                    1
                                    • fhenrycoF fhenryco

                                      @mfalkvidd You are right but may be should there be for each sensor or actuator first the most basic sketch but also at the end of the page a complete version with all functionalities and granted to work by the mysensors team.

                                      Of course for the complicated sketch version a big warning in red letters that this is not recommended for newbies would help...

                                      fhenrycoF Offline
                                      fhenrycoF Offline
                                      fhenryco
                                      wrote on last edited by
                                      #86

                                      After testing some functionalities of nodemanager, i was wondering if already somebody was working on making a GUI for nodemanager which would allow to build one's sketch completely from a graphical interface (at least the most common and basic functionalities) : i thing the great work that resulted in Nodemanager has so well structured the various functions needed that it has already paved the way for creating such a graphical interface.

                                      1 Reply Last reply
                                      0
                                      • gohanG Offline
                                        gohanG Offline
                                        gohan
                                        Mod
                                        wrote on last edited by
                                        #87

                                        There was a user some time ago that was trying to make a web GUI

                                        1 Reply Last reply
                                        0
                                        • skywatchS Offline
                                          skywatchS Offline
                                          skywatch
                                          wrote on last edited by
                                          #88

                                          I would agree that more advanced sketches 'should' be included on the same page. Keep all the info in one resource place. Provided it is clearly marked as an advanced project it might help people looking for similar functionality or just interested in learning more about programming....

                                          1 Reply Last reply
                                          1
                                          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
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular