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. Bug Reports
  3. Node not working very well when MY_DEBUG not defined

Node not working very well when MY_DEBUG not defined

Scheduled Pinned Locked Moved Bug Reports
11 Posts 5 Posters 1.3k Views 5 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.
  • SnyfirS Snyfir

    Hello everybody,

    When MY_DEBUG is not defined in my node, the gateway doesn't received every time the ACK send by the node.

    I use MySensors V2.3.1 is both gateway and node.
    I use a nrf24l01+pa+lna with Socket Adapter Board with arduino pro mini 5V

    dbemowskD Offline
    dbemowskD Offline
    dbemowsk
    wrote on last edited by dbemowsk
    #2

    @snyfir Without seeing your code we can't comment too much, but just judging from what you are saying, if it works fine with debug turned on, but not well with it off, you may need some short delay in your main loop. The delay in time that it takes to do the serial sends may be enough to make it work. Putting the delay in there may mimic those delays. Something like this might work:

    #ifdef DEBUG
        Serial.println("your debug message");
    #else
        delay(1);
    #endif
    

    You probably only need to do this for one debug print and then adjust the delay time to your needs.

    Outside of that, post your code and we can help better.

    Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
    Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

    SnyfirS 1 Reply Last reply
    0
    • dbemowskD dbemowsk

      @snyfir Without seeing your code we can't comment too much, but just judging from what you are saying, if it works fine with debug turned on, but not well with it off, you may need some short delay in your main loop. The delay in time that it takes to do the serial sends may be enough to make it work. Putting the delay in there may mimic those delays. Something like this might work:

      #ifdef DEBUG
          Serial.println("your debug message");
      #else
          delay(1);
      #endif
      

      You probably only need to do this for one debug print and then adjust the delay time to your needs.

      Outside of that, post your code and we can help better.

      SnyfirS Offline
      SnyfirS Offline
      Snyfir
      wrote on last edited by
      #3

      thank you @dbemowsk for your answer

      my code is:

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      
      // Enable IRQ pin
      #define MY_RX_MESSAGE_BUFFER_FEATURE
      #define MY_RF24_IRQ_PIN (2)
      
      // RF24 PA level
      #define MY_RF24_PA_LEVEL (RF24_PA_HIGH)
      
      // Enable repeater functionality
      #define MY_REPEATER_FEATURE
      
      // Define pins
      #define SIREN 5
      
      // Includes
      #include <MySensors.h>
      
      // Others
      MyMessage msg(0, V_CUSTOM);
      unsigned long _sirenTime = 0;
      int _sirenState = 0;
      int _bipNumber = 0;
      int _sirenLevel = 100;
      
      void before()
      {
        pinMode(SIREN, OUTPUT);
        digitalWrite(SIREN, LOW);
        stopSiren();
      }
      
      void setup() {
      
      }
      
      void presentation() {
        sendSketchInfo("Siren", "1.0");
        present(0, S_CUSTOM);
      }
      
      void receive(const MyMessage &myMsg)
      {
        if (myMsg.type == V_CUSTOM) {
          String message = myMsg.getString();
      
          if (message == "stop") {
            stopSiren();
            send(msg.set(F("stopped by user")));
          } else if (message == "start") {
            startSiren(5, 100);
            send(msg.set(F("started")));
          }
        }
      }
      
      void loop() {
        manageSiren();
        wait(100);
      }
      
      void startSiren(char bipBumber, char level) {
        _bipNumber = bipBumber;
        _sirenLevel = level;
        _sirenTime = 0;
        _sirenState = 1;
      }
      
      void stopSiren() {
        _sirenState = 0;
        stopSirenSound();
      }
      
      bool isSirenOn() {
        return _sirenState != 0;
      }
      
      void manageSiren() {
        if (_sirenState == 0) {
          // nothing to do
        } else if ((_sirenState % 2 == 1 && _sirenState < _bipNumber * 2 + 2) && millis() - _sirenTime >= 1000) {
          startSirenSound(_sirenLevel);
          _sirenTime = millis();
          _sirenState++;
        } else if ((_sirenState % 2 == 0 && _sirenState < _bipNumber * 2 + 2) && millis() - _sirenTime >= 100) {
          stopSirenSound();
          _sirenTime = millis();
          _sirenState++;
        } else if ((_sirenState == _bipNumber * 2 + 2) && millis() - _sirenTime >= 60000) {
          stopSiren();
          send(msg.set(F("stopped")));
        }
      }
      
      void startSirenSound(char level) {
          analogWrite(SIREN, map(level, 0, 100, 0, 255));
      }
      
      void stopSirenSound() {
          analogWrite(SIREN, 0);
      }
      

      I try with delay(1) but it doesn't change anything, maybe i should increase the delay.
      I have an other node which have the same issue.

      dbemowskD 1 Reply Last reply
      0
      • SnyfirS Snyfir

        thank you @dbemowsk for your answer

        my code is:

        // Enable debug prints to serial monitor
        #define MY_DEBUG
        
        // Enable and select radio type attached
        #define MY_RADIO_RF24
        
        // Enable IRQ pin
        #define MY_RX_MESSAGE_BUFFER_FEATURE
        #define MY_RF24_IRQ_PIN (2)
        
        // RF24 PA level
        #define MY_RF24_PA_LEVEL (RF24_PA_HIGH)
        
        // Enable repeater functionality
        #define MY_REPEATER_FEATURE
        
        // Define pins
        #define SIREN 5
        
        // Includes
        #include <MySensors.h>
        
        // Others
        MyMessage msg(0, V_CUSTOM);
        unsigned long _sirenTime = 0;
        int _sirenState = 0;
        int _bipNumber = 0;
        int _sirenLevel = 100;
        
        void before()
        {
          pinMode(SIREN, OUTPUT);
          digitalWrite(SIREN, LOW);
          stopSiren();
        }
        
        void setup() {
        
        }
        
        void presentation() {
          sendSketchInfo("Siren", "1.0");
          present(0, S_CUSTOM);
        }
        
        void receive(const MyMessage &myMsg)
        {
          if (myMsg.type == V_CUSTOM) {
            String message = myMsg.getString();
        
            if (message == "stop") {
              stopSiren();
              send(msg.set(F("stopped by user")));
            } else if (message == "start") {
              startSiren(5, 100);
              send(msg.set(F("started")));
            }
          }
        }
        
        void loop() {
          manageSiren();
          wait(100);
        }
        
        void startSiren(char bipBumber, char level) {
          _bipNumber = bipBumber;
          _sirenLevel = level;
          _sirenTime = 0;
          _sirenState = 1;
        }
        
        void stopSiren() {
          _sirenState = 0;
          stopSirenSound();
        }
        
        bool isSirenOn() {
          return _sirenState != 0;
        }
        
        void manageSiren() {
          if (_sirenState == 0) {
            // nothing to do
          } else if ((_sirenState % 2 == 1 && _sirenState < _bipNumber * 2 + 2) && millis() - _sirenTime >= 1000) {
            startSirenSound(_sirenLevel);
            _sirenTime = millis();
            _sirenState++;
          } else if ((_sirenState % 2 == 0 && _sirenState < _bipNumber * 2 + 2) && millis() - _sirenTime >= 100) {
            stopSirenSound();
            _sirenTime = millis();
            _sirenState++;
          } else if ((_sirenState == _bipNumber * 2 + 2) && millis() - _sirenTime >= 60000) {
            stopSiren();
            send(msg.set(F("stopped")));
          }
        }
        
        void startSirenSound(char level) {
            analogWrite(SIREN, map(level, 0, 100, 0, 255));
        }
        
        void stopSirenSound() {
            analogWrite(SIREN, 0);
        }
        

        I try with delay(1) but it doesn't change anything, maybe i should increase the delay.
        I have an other node which have the same issue.

        dbemowskD Offline
        dbemowskD Offline
        dbemowsk
        wrote on last edited by
        #4

        @snyfir Looking at your code, I don't see any debug prints that you have defined yourself. You will however get debug info from the MySensors library. Also, I need to correct myself. You are better off using wait(ms) over delay(ms). Delay will halt all MySensors processing for the specified period of time where using wait(ms) will allow the process() method to continue to run.

        I see that you have a call to wait(100) in your main loop. Did you just add that, or is that part of the code that fails with debug off?

        Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
        Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

        SnyfirS 1 Reply Last reply
        0
        • dbemowskD dbemowsk

          @snyfir Looking at your code, I don't see any debug prints that you have defined yourself. You will however get debug info from the MySensors library. Also, I need to correct myself. You are better off using wait(ms) over delay(ms). Delay will halt all MySensors processing for the specified period of time where using wait(ms) will allow the process() method to continue to run.

          I see that you have a call to wait(100) in your main loop. Did you just add that, or is that part of the code that fails with debug off?

          SnyfirS Offline
          SnyfirS Offline
          Snyfir
          wrote on last edited by Snyfir
          #5

          @dbemowsk
          I didn't change anything of my code. This is the one who don't work well when I comments #define MY_DEBUG
          but if I don't comments this line it work well.

          1 Reply Last reply
          0
          • SnyfirS Offline
            SnyfirS Offline
            Snyfir
            wrote on last edited by
            #6

            Nobody has a clue ?

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

              Do you have capacitors on the nrf24l01+ board?

              I am just guesing here but maybe with debug it slows things down enough to allow power to the nrf to recover but without the debug code running it is a little faster and not allowing the rnf to get full power?

              We don't know what 'siren' actually is or how it is connected, so I suspect a power issue might be at play here.

              Maybe also try with #define MY_RF24_PA_LEVEL (RF24_PA_LOW) just to see if it makes a difference.

              Other than that, I too am stumped.

              1 Reply Last reply
              0
              • berkseoB Offline
                berkseoB Offline
                berkseo
                wrote on last edited by berkseo
                #8

                I confirm. Looks like a huge bug :). A node with an led was assembled. Uploaded sketch from examples - actuator relays. In the mysensors controller I send a command with a confirmation flag, the led lights up, there is no response message with confirmation. In the sketch I activate debag and then send the command with the acknowledgement, the reply message arrives. Hw for nodes is nrf52, atmega328 were used. In addition to the mysensors controller, the Majordomo controller has been tested. Same thing. Gateway was connected to a serial monitor. The error was also reproduced by other users in the community.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  FlyingDomotic
                  wrote on last edited by
                  #9

                  @Snyfir: Maybe a timing issue in MySensors code? Are both node and gateway on the same kind of hardware?

                  It seems also (at least for me) that 2.3.1 may be more concerned by timing issues than 2.3.0, even if I don't saw in the code what could be the real cause. You may perhaps revert to 2.3.0 and see if you still have this kind of issue?

                  1 Reply Last reply
                  1
                  • berkseoB Offline
                    berkseoB Offline
                    berkseo
                    wrote on last edited by
                    #10

                    My problem is temporarily solved(nrf5). Delivery confirmation to the controller come steadily if the file MyTransport.ccp (line 723) add:

                    #if !defined(MY_DEBUG)
                    wait(5);
                    #endif
                    

                    based on:
                    https://github.com/mysensors-rus/MySensors/commit/06f8083b785237b8d1b430a142fe3d9a3cd6f7ff

                    SnyfirS 1 Reply Last reply
                    1
                    • berkseoB berkseo

                      My problem is temporarily solved(nrf5). Delivery confirmation to the controller come steadily if the file MyTransport.ccp (line 723) add:

                      #if !defined(MY_DEBUG)
                      wait(5);
                      #endif
                      

                      based on:
                      https://github.com/mysensors-rus/MySensors/commit/06f8083b785237b8d1b430a142fe3d9a3cd6f7ff

                      SnyfirS Offline
                      SnyfirS Offline
                      Snyfir
                      wrote on last edited by
                      #11

                      @berkseo said in Node not working very well when MY_DEBUG not defined:

                      My problem is temporarily solved(nrf5). Delivery confirmation to the controller come steadily if the file MyTransport.ccp (line 723) add:

                      #if !defined(MY_DEBUG)
                      wait(5);
                      #endif
                      

                      based on:
                      https://github.com/mysensors-rus/MySensors/commit/06f8083b785237b8d1b430a142fe3d9a3cd6f7ff

                      The bug will be fix in the 2.3.2 release i suppose so

                      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