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. Create relay free potential free switch.

Create relay free potential free switch.

Scheduled Pinned Locked Moved Troubleshooting
14 Posts 3 Posters 3.8k 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.
  • R Offline
    R Offline
    Rene046
    wrote on last edited by Rene046
    #1

    Hi there,

    i need some help with an idea i need...
    I looking far a way to control a potential free contact to control an water lock, but without using a relay. if my water lock sees 10K on its connection it keeps it closed so no watering, if it sees 0 ohm it will have permission to water. my plants
    .
    i was thinking to use an opto coupler but those i now need a voltage going tru on the output... or am i wrong.

    or maybe some kind of hal sensor with internal coil controlled by an arduino

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

      I didn't get what's the problem with the relay

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rene046
        wrote on last edited by
        #3

        battery powered project....

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

          Transistor? Latching relay? I am just throwing ideas since I haven't fully understood your project.

          1 Reply Last reply
          0
          • R Rene046

            battery powered project....

            N Offline
            N Offline
            Nca78
            Hardware Contributor
            wrote on last edited by
            #5

            @Rene046 said in Create relay free potential free switch.:

            battery powered project....

            Why not just use a latching relay ?

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rene046
              wrote on last edited by
              #6

              because i dont want the water lock stay open after power lost.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rene046
                wrote on last edited by Rene046
                #7

                Ok i explain.

                i have and Gardena Watering computer, here i want to connect a controller on battery to
                All this controller has to do via Mysensors is open or close a an switch (the 2 wires of this switch go inside the gardena computer that is looking for an 10k resistance to stop watering the plants, and an open switch 0 ohm to water the plants.

                Some distance further i have an other node that's measuring soil moisture,

                I have this now running by using normal relays, but using 2 of them (2 garden computers ) they use allot of battery power while watering so i was hoping there are some more better options.

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

                  If you are afraid of wasting too much water, just run a command in setup function that checks the status of latching relay and turns it off. In addition there are many arduino projects for watering plants you can look for inspiration

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    Nca78
                    Hardware Contributor
                    wrote on last edited by
                    #9

                    And there are also some latching relays with 2 latches, one to switch on, one to switch off.
                    You can just switch off at the beginning of your sketch.
                    It's even possible to do that with hardware, to send a pulse to the "switch off" latch when the system is started. So even if your sketch fails to start, your relay will be off.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Rene046
                      wrote on last edited by Rene046
                      #10

                      will give it a try.

                      this is the sketch i want to implement this in:
                      It will be a repeater node,
                      I would like to have 2 Relays on pins D3,D4
                      And a temperature sensor on D5 (DS1820)
                      Eventually an voltage sense pin A3

                      /*
                       * Documentation: http://www.mysensors.org
                       * Support Forum: http://forum.mysensors.org
                       *
                       * http://www.mysensors.org/build/relay
                       */
                      
                      // Enable debug prints to serial monitor
                      #define MY_DEBUG
                      
                      // Enable and select radio type attached
                      #define MY_RADIO_NRF24
                      //#define MY_RADIO_RFM69
                      #define MY_RF24_PA_LEVEL RF24_PA_MAX
                      
                      // Enabled repeater feature for this node
                      #define MY_REPEATER_FEATURE
                      #define MY_NODE_ID 1
                      #include <SPI.h>
                      #include <MySensors.h>
                      #include <Bounce2.h>
                      #include <SPI.h>
                      #include <DallasTemperature.h>
                      #include <OneWire.h>
                      
                      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
                      
                      #define RELAY_PIN1  3  // Arduino Digital I/O pin number for relay
                      #define BUTTON_PIN  7  // dont need this one remove
                      #define CHILD_ID 1
                      #define RELAY_ON 1
                      #define RELAY_OFF 0
                      
                      Bounce debouncer = Bounce();
                      bool state = false;
                      bool initialValueSent = false;
                      
                      MyMessage msg(CHILD_ID, V_STATUS);
                      
                      void setup()
                      {
                        // Setup the button
                        //pinMode(BUTTON_PIN, INPUT_PULLUP);
                      
                        // After setting up the button, setup debouncer
                        //debouncer.attach(BUTTON_PIN);
                        //debouncer.interval(10);
                      
                        // Make sure relays are off when starting up
                        digitalWrite(RELAY_PIN1, RELAY_OFF);
                        // Then set relay pins in output mode
                        pinMode(RELAY_PIN1, OUTPUT);
                      
                        // Set relay to last known state (using eeprom storage)
                        state = loadState(CHILD_ID);
                        digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF);
                      }
                      
                      void presentation()  {
                        // Startup initialize MySensors library. Set callback for incoming messages. 
                         
                        
                        sendSketchInfo("Lamp", "1.0");
                        present(CHILD_ID, S_BINARY);
                        
                      }
                      
                      void loop()
                      {
                        if (!initialValueSent) {
                          Serial.println("Sending initial value");
                          send(msg.set(state?RELAY_ON:RELAY_OFF));
                          Serial.println("Requesting initial value from controller");
                          request(CHILD_ID, V_STATUS);
                          wait(2000, C_SET, V_STATUS);
                        }
                        if (debouncer.update()) {
                          if (debouncer.read()==LOW) {
                            state = !state;
                            send(msg.set(state?RELAY_ON:RELAY_OFF), true); // Send new state and request ack back
                          }
                        }
                       }
                      
                      void receive(const MyMessage &message) {
                        if (message.isAck()) {
                           Serial.println("This is an ack from gateway");
                        }
                      
                        if (message.type == V_STATUS) {
                          if (!initialValueSent) {
                            Serial.println("Receiving initial value from controller");
                            initialValueSent = true;
                          }
                          // Change relay state
                      
                          state = (bool)message.getInt();
                          digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF);
                          send(msg.set(state?RELAY_ON:RELAY_OFF));
                          // Store state in eeprom
                          saveState(CHILD_ID, state);
                      
                          // Write some debug info
                          Serial.print("Incoming change for sensor:");
                          Serial.print(message.sensor);
                          Serial.print(", New status: ");
                          Serial.println(message.getInt());
                        }
                      }```
                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Rene046
                        wrote on last edited by Rene046
                        #11

                        So far 1 relay works perfect adding a second one will be a bid harder because the sketch samples i found use more than 2 i would like to know how to add just a second one.
                        also in this sketch in need to find out hoe to remove the button function.
                        Adding the temperature sensor seems for me very hard, because i would like to call it every 5 minutes without interrupting the repeater. (No Sleep can be used).
                        if i know how to call every 5 minutes the temperature, i think i'll be able to add the also the adc code.

                        I someone could point me to some code sample i would be very happy...

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

                          Just use wait() instead of sleep

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            Rene046
                            wrote on last edited by
                            #13

                            Thanks Gohan,

                            Will the repeater function keep working...... ? more like an interrupt when something is seen ?

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

                              The wait is specific for keeping the communications going while pausing the loop

                              1 Reply Last reply
                              0

                              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                              With your input, this post could be even better 💗

                              Register Login
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              16

                              Online

                              12.0k

                              Users

                              11.2k

                              Topics

                              113.4k

                              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