Relay and Repeater - Just learning stuff



  • So I have several nodes going in the house. I love mysensors and really appreciate all who have made this possible.

    Today I am looking into repeaters and learning how to make my custom multi sensor nodes into repeaters. Specifically any with a relay since they process incoming messages. From what I can tell they already are. Could someone fact check me to make sure I am thinking about this correctly?

    1.) To make a repeater node you first off cannot have any sort of sleep function

    2.) You need this code to enable repeater mode, specifically I think you only need the true part.

    gw.begin(NULL, AUTO, true);
    

    this would also work i am thinking

    gw.begin(incomingMessage, AUTO, true);
    

    3.) This is what makes a repeater do repeater things.

    gw.process();
    

  • Hardware Contributor

    Hi!

    Not the expert, but I think you are on the right track.
    The gw.begin(incomingMessage, AUTO, true); is only needed if you have a senser expecting incoming messages.
    If its only a repeater you can use the first one.

    Br


  • Contest Winner

    I have never worked with the repeater but I just hacked an example for you. I'm not able to test it and I don't know if this will effect the performance of the repeater. But at least it compiles.

    For test purposes it might be better to hook an led with a 220 ohm resistor to the relay_pin.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Example sketch showing how to create a node thay repeates messages
     * from nodes far from gateway back to gateway. 
     * It is important that nodes that has enabled repeater mode calls  
     * gw.process() frequently. Repeaters should never sleep. 
     */
    
    #include <MySensor.h>
    #include <SPI.h>
    
    #define CHILD_ID_RELAY 1   // Id of the sensor child
    #define RELAY_PIN 3 // The pin for controling the relay
    
    
    MySensor gw;
    
    void setup()  
    {  
      // The third argument enables repeater mode.
      gw.begin( incomingMessage, AUTO, true);
    
      //Send the sensor node sketch version information to the gateway
      gw.sendSketchInfo("Repeater Node", "1.0");
      pinMode (RELAY_PIN, OUTPUT );
      gw.present(CHILD_ID_RELAY, S_LIGHT);
    
    }
    
    void loop() 
    {
      // By calling process() you route messages in the background
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      if (message.type==V_LIGHT) {
         if ( message.sensor == CHILD_ID_RELAY ) {
            digitalWrite( RELAY_PIN, message.getBool()? HIGH :LOW );
         }
       }
    }
    

    Let me know if it works. Might be somthing I'll be needing myself 😉



  • Do I need to link/pair the repeater node to the gateway or does it just work when I power it up?


Log in to reply
 

Suggested Topics

  • 4
  • 20
  • 9
  • 2
  • 17
  • 15

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts