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. Ethernet gateway and receive function

Ethernet gateway and receive function

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 2 Posters 513 Views 2 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.
  • D Offline
    D Offline
    DanieleF
    wrote on last edited by
    #1

    I have an ethernet gw based on Arduino Uno + W5100, working as expected.
    I tried to add an actuator (a simple relay), thus I added the usual "receive" function to the script, but at this point the ethernet stopped sending messages to others nodes.

    I tried filtering the destination, sensors type etc. but it still doesn't work.
    I suppose I should "forward" the messages manually in my receive function, correct?
    Does someone have a working example?

    Thanks
    Daniele

    mfalkviddM 1 Reply Last reply
    0
    • D DanieleF

      I have an ethernet gw based on Arduino Uno + W5100, working as expected.
      I tried to add an actuator (a simple relay), thus I added the usual "receive" function to the script, but at this point the ethernet stopped sending messages to others nodes.

      I tried filtering the destination, sensors type etc. but it still doesn't work.
      I suppose I should "forward" the messages manually in my receive function, correct?
      Does someone have a working example?

      Thanks
      Daniele

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

      @danielef hard to say without looking at your code, but my guess is that you're doing something in receive that blocks normal processing.

      I am not sure if I have seen any sketches with actuators on the gateway, but it should be the same as other nodes.

      You should not forward messages manually.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DanieleF
        wrote on last edited by
        #3

        The code is really basic, taken from the ethernet gw template simply adding the receive function:

        
        #define MY_DEBUG
        
        #define MY_GATEWAY_W5100
        
        #define MY_RF24_CS_PIN 3
        #define MY_RF24_IRQ_PIN 2
        #define MY_RX_MESSAGE_BUFFER_FEATURE 6
        
        #define MY_IP_ADDRESS 192,168,1,20
        #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
        #define MY_IP_SUBNET_ADDRESS 255,255,255,0
        #define MY_PORT 5003
        #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
        
        #if defined(MY_USE_UDP)
        #include <EthernetUdp.h>
        #endif
        #include <Ethernet.h>
        
        #define CHILD_ID_LIGHT 1
        
        #include <MyRF24_P2_GW.h>
        #include <MySensors.h>
        
        
        
        
        void setup()
        {
        
        }
        
        void presentation()
        {
        
          present(CHILD_ID_LIGHT, S_BINARY, "P2 Luci Armadio");
        
        }
        
        void loop() {
        
          
        }
        
        void receive(const MyMessage &message)
        {
        
          if (message.type == V_STATUS && message.sensor == CHILD_ID_LIGHT && !message.isAck()) {
            #ifdef MY_DEBUG
            Serial.println("*** Receiving ***");
            #endif
            statoLuci = message.getBool();
          }
        
        }
        
        mfalkviddM 1 Reply Last reply
        0
        • D DanieleF

          The code is really basic, taken from the ethernet gw template simply adding the receive function:

          
          #define MY_DEBUG
          
          #define MY_GATEWAY_W5100
          
          #define MY_RF24_CS_PIN 3
          #define MY_RF24_IRQ_PIN 2
          #define MY_RX_MESSAGE_BUFFER_FEATURE 6
          
          #define MY_IP_ADDRESS 192,168,1,20
          #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
          #define MY_IP_SUBNET_ADDRESS 255,255,255,0
          #define MY_PORT 5003
          #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
          
          #if defined(MY_USE_UDP)
          #include <EthernetUdp.h>
          #endif
          #include <Ethernet.h>
          
          #define CHILD_ID_LIGHT 1
          
          #include <MyRF24_P2_GW.h>
          #include <MySensors.h>
          
          
          
          
          void setup()
          {
          
          }
          
          void presentation()
          {
          
            present(CHILD_ID_LIGHT, S_BINARY, "P2 Luci Armadio");
          
          }
          
          void loop() {
          
            
          }
          
          void receive(const MyMessage &message)
          {
          
            if (message.type == V_STATUS && message.sensor == CHILD_ID_LIGHT && !message.isAck()) {
              #ifdef MY_DEBUG
              Serial.println("*** Receiving ***");
              #endif
              statoLuci = message.getBool();
            }
          
          }
          
          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @danielef thanks for sharing the code. It looks good. What does the debug output look like?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DanieleF
            wrote on last edited by
            #5

            Sorry for the late response, I've been away for a few days.
            The debug output looks very odd to me:

            4850944 MCO:BGN-Q-,REL=255,VER=2.3.1
            4850945 5,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 5,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
            4850945 ```
            mfalkviddM 1 Reply Last reply
            0
            • D DanieleF

              Sorry for the late response, I've been away for a few days.
              The debug output looks very odd to me:

              4850944 MCO:BGN-Q-,REL=255,VER=2.3.1
              4850945 5,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 5,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
              4850945 ```
              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by mfalkvidd
              #6

              @danielef the sketch you posted does not compile

              'statoLuci' was not declared in this scope
              

              are you sure this is the code you are using?
              Is there anything in MyRF24_P2_GW.h that we need to know about?

              From the log, it looks like the node is repeatedly calling Init, without reboot. That is very strange.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DanieleF
                wrote on last edited by
                #7

                This is the full code, in my previous message I tried simplifing it and I missed a variable declaration:

                #define MY_DEBUG
                //#define MY_DEBUG_DETAIL
                
                #define MY_GATEWAY_W5100
                
                #define MY_RF24_CS_PIN 3
                #define MY_RF24_IRQ_PIN 2
                #define MY_RX_MESSAGE_BUFFER_FEATURE 6
                
                #define MY_IP_ADDRESS 192,168,1,20
                #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                #define MY_PORT 5003
                #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                
                #if defined(MY_USE_UDP)
                #include <EthernetUdp.h>
                #endif
                #include <Ethernet.h>
                
                #define CHILD_ID_LIGHT 1
                
                #include <MyRF24_P2_GW.h>
                #include <MySensors.h>
                
                MyMessage msgLIGHT(CHILD_ID_LIGHT, V_STATUS);
                
                
                #define BUTTON_UP A4
                #define BUTTON_DW A5
                
                #include <Bounce2.h>
                Bounce debounceUp = Bounce(); 
                Bounce debounceDw = Bounce();
                
                bool statoLuci = 1;
                const byte numReed = 4;
                const byte pinReed[numReed] = {A0,A1,A2,A3};
                const byte pinRelay[numReed] = {5,6,7,8};
                bool statoReed[numReed];
                
                
                
                void setup()
                {
                
                //  request(CHILD_ID_LIGHT, V_STATUS);
                
                  debounceUp.attach(BUTTON_UP, INPUT_PULLUP);
                  debounceUp.interval(5);
                  debounceDw.attach(BUTTON_DW, INPUT_PULLUP);
                  debounceDw.interval(5);
                
                  for (int i=0; i<numReed; i++){
                    pinMode(pinReed[i], INPUT_PULLUP);
                    statoReed[i] = 0;
                    pinMode(pinRelay[i], OUTPUT);
                  }
                
                }
                
                void presentation()
                {
                
                  present(CHILD_ID_LIGHT, S_BINARY, "P2 Luci Armadio");
                
                }
                
                void loop() {
                
                  debounceUp.update();
                  debounceDw.update();
                  
                  if ( debounceUp.fell() ) {
                    Serial.println("UP");
                  }
                  if ( debounceDw.fell() ) {
                    Serial.println("DOWN");
                  }
                  
                
                  for (int i=0; i<numReed; i++){
                    if (statoLuci){
                      statoReed[i] = digitalRead(pinReed[i]);
                      digitalWrite(pinRelay[i], statoReed[i]);
                    }
                    else
                      digitalWrite(pinRelay[i], 0);
                
                    #ifdef MY_DEBUG_DETAIL
                    Serial.print("Reed ");
                    Serial.print(i);
                    Serial.print(" : ");
                    Serial.println(statoReed[i]);
                    #endif
                  }
                
                  #ifdef MY_DEBUG_DETAIL
                  Serial.println("****************");
                  wait(1000);
                  #endif
                  
                }
                
                /*
                void receive(const MyMessage &message)
                {
                
                  if (message.destination == 0 && message.type == V_STATUS && message.sensor == CHILD_ID_LIGHT && !message.isAck()) {
                    #ifdef MY_DEBUG
                    Serial.println("*** Receiving ***");
                    #endif
                    statoLuci = message.getBool();
                  }
                
                }
                */
                

                MyRF24_2_GW.h contains simply some common defines I use for all the nodes connected to this GW:

                #define MY_RADIO_NRF24
                #define MY_RF24_DATARATE   RF24_250KBPS
                #define MY_RF24_CHANNEL 115
                
                #ifndef MY_RF24_PA_LEVEL
                #define MY_RF24_PA_LEVEL   RF24_PA_HIGH
                #endif
                
                #ifndef MY_PARENT_NODE_ID
                #define MY_PARENT_NODE_ID 0
                #define MY_PARENT_NODE_IS_STATIC
                #endif
                
                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                19

                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