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. Is serial.print blocked by mySensors?

Is serial.print blocked by mySensors?

Scheduled Pinned Locked Moved Troubleshooting
11 Posts 3 Posters 4.4k Views 4 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #2

    Does it ever reach the loop-section then? Please post your log.

    samburner3S 1 Reply Last reply
    0
    • T Offline
      T Offline
      Tag
      wrote on last edited by Tag
      #3

      Hi!,

      Where did the following piece of code go?

      void setup()
      {
      Serial.Begin(115200);
      }
      

      That might help, since it will tell the sketch you want to talk to the outside world using serial communication.
      Have you tried that?

      Another option is adding this in your sketch:
      (before you include the mysensors lib!)

      #define MY_DEBUG 
      

      See: https://www.mysensors.org/build/debug

      samburner3S 1 Reply Last reply
      0
      • T Tag

        Hi!,

        Where did the following piece of code go?

        void setup()
        {
        Serial.Begin(115200);
        }
        

        That might help, since it will tell the sketch you want to talk to the outside world using serial communication.
        Have you tried that?

        Another option is adding this in your sketch:
        (before you include the mysensors lib!)

        #define MY_DEBUG 
        

        See: https://www.mysensors.org/build/debug

        samburner3S Offline
        samburner3S Offline
        samburner3
        wrote on last edited by
        #4

        @Tag said in Is serial.print blocked by mySensors?:

        void setup()
        {
        Serial.Begin(115200);
        }

        I did try putting in a Serial.begin(115200); as I mentioned in my post, and yes it was in the void setup loop.

          void setup()
          { 
          Serial.begin(115200);
          }
        

        I also do have the #define MY_DEBUG and it outputs the radio debug only.
        Still did not fix it.

        T 1 Reply Last reply
        0
        • hekH hek

          Does it ever reach the loop-section then? Please post your log.

          samburner3S Offline
          samburner3S Offline
          samburner3
          wrote on last edited by
          #5

          @hek It is reaching the loop, yep.

          Source Sketch:

          #define MY_DEBUG 
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          
          #include <SPI.h>
          #include <MySensors.h>
          
          
          #define NODE_ID 3
          
          #define OPEN 1
          #define CLOSE 0
          
          MyMessage msg(NODE_ID, V_TRIPPED);
          
          uint8_t value = OPEN;
          
          void setup()
          {
          Serial.begin(115200);
          }
          
          void presentation()
          {
              present(NODE_ID, S_DOOR);
          }
          
          void loop()
          {
              value = value == OPEN ? CLOSE : OPEN;
              send(msg.set(value));
              Serial.print("TestMessage to Serial that is not displaying.");
              sleep(10000);
          }
          

          Serial Output:

          TSM:INIT
          TSM:RADIO:OK
          TSP:ASSIGNID:OK (ID=2)
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          !TSM:FPAR:FAIL
          !TSM:FAILURE
          TSM:PDT
          TSM:INIT
          TSM:RADIO:OK
          TSP:ASSIGNID:OK (ID=2)
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          !TSM:FPAR:FAIL
          !TSM:FAILURE
          TSM:PDT
          TSM:INIT
          TSM:RADIO:OK
          TSP:ASSIGNID:OK (ID=2)
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
          TSM:FPAR
          

          (the fails are not of concern at this time as my test bench is quite far from the gateway and I need to add a capacitor to the radio. This just proves that the program is hitting the loop but not outputting any Serial.print.)

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by hek
            #6

            No, it's not....

            The node is searching for a gateway or repeater. If you want it to enter the loop without finding a parent, you have to add the following to your sketch:

            #define MY_TRANSPORT_WAIT_READY_MS 1
            

            Which means it will only wait one millisecond before entering loop even if transport is unavailable.

            samburner3S 1 Reply Last reply
            0
            • samburner3S samburner3

              @Tag said in Is serial.print blocked by mySensors?:

              void setup()
              {
              Serial.Begin(115200);
              }

              I did try putting in a Serial.begin(115200); as I mentioned in my post, and yes it was in the void setup loop.

                void setup()
                { 
                Serial.begin(115200);
                }
              

              I also do have the #define MY_DEBUG and it outputs the radio debug only.
              Still did not fix it.

              T Offline
              T Offline
              Tag
              wrote on last edited by
              #7

              @samburner3

              Strange, will have a look later today see if i can recreate your issue.
              Did you post your complete sketch?

              1 Reply Last reply
              0
              • hekH hek

                No, it's not....

                The node is searching for a gateway or repeater. If you want it to enter the loop without finding a parent, you have to add the following to your sketch:

                #define MY_TRANSPORT_WAIT_READY_MS 1
                

                Which means it will only wait one millisecond before entering loop even if transport is unavailable.

                samburner3S Offline
                samburner3S Offline
                samburner3
                wrote on last edited by
                #8

                Oh so the send messages are it attempting to connect to the gateway? I thaught they were the loop as they were appearing exactly once a second (hence the sleep(10000);)

                Even after moving next to the gateway it still won't connect? Gateway is up and ok:

                0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
                0;255;3;0;9;TSM:INIT
                0;255;3;0;9;TSM:RADIO:OK
                0;255;3;0;9;TSM:GW MODE
                0;255;3;0;9;TSM:READY
                0;255;3;0;14;Gateway startup complete.
                0;255;0;0;18;2.0.0
                0;255;3;0;9;No registration required
                0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
                0;255;3;0;9;TSP:SANCHK:OK
                0;255;3;0;9;TSP:SANCHK:OK
                0;255;3;0;9;TSP:SANCHK:OK
                

                Anyway first things first;

                @hek Ok so I added the line #define MY_TRANSPORT_WAIT_READY_MS 1 to my sketch, however it did not turn blue in the IDE like other define tags have. This is using libray version 2.0.0.

                0_1485185424115_Screen Shot 2017-01-24 at 2.29.45 AM.png

                So I re-added the mysensors lib from the menu in the IDE (Sketch > Include Library > MySensors) to ensure it was added correctly.

                Then I tried to compile I got an error

                   #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
                    ^
                exit status 1
                Error compiling for board Arduino/Genuino Uno.
                

                I think I got this before but overlooked it. However the sketch is the same as the example so not sure what I am missing?

                My current sketch (with compile error):

                #include <MyConfig.h>
                #include <MySensors.h>
                
                // Enable debug prints to serial monitor
                #define MY_DEBUG 
                
                #define MY_TRANSPORT_WAIT_READY_MS 1
                
                // Enable and select radio type attached
                #define MY_RADIO_NRF24
                //#define MY_RADIO_RFM69
                
                #include <SPI.h>
                //#include <MySensors.h>
                
                #define NODE_ID 3
                
                #define OPEN 1
                #define CLOSE 0
                
                MyMessage msg(NODE_ID, V_TRIPPED);
                
                uint8_t value = OPEN;
                
                void setup()
                {
                Serial.begin(115200);
                }
                
                void presentation()
                {
                    present(NODE_ID, S_DOOR);
                }
                
                void loop()
                {
                    value = value == OPEN ? CLOSE : OPEN;
                    send(msg.set(value));
                    Serial.print("TestMessage to Serial that is not displaying.");
                    sleep(10000);
                }```
                1 Reply Last reply
                0
                • hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #9

                  Put MySensors include at the bottom of the file (or at least below the defines)

                  samburner3S 2 Replies Last reply
                  0
                  • hekH hek

                    Put MySensors include at the bottom of the file (or at least below the defines)

                    samburner3S Offline
                    samburner3S Offline
                    samburner3
                    wrote on last edited by
                    #10

                    @hek Ok have done so:

                    
                    // Enable debug prints to serial monitor
                    #define MY_DEBUG 
                    
                    #define MY_TRANSPORT_WAIT_READY_MS 1
                    
                    // Enable and select radio type attached
                    #define MY_RADIO_NRF24
                    //#define MY_RADIO_RFM69
                    
                    #include <SPI.h>
                    //#include <MySensors.h>
                    
                    #define NODE_ID 3
                    
                    #define OPEN 1
                    #define CLOSE 0
                    
                    #include <MySensors.h>
                    
                    MyMessage msg(NODE_ID, V_TRIPPED);
                    
                    uint8_t value = OPEN;
                    
                    void setup()
                    {
                    Serial.begin(115200);
                    }
                    
                    void presentation()
                    {
                        present(NODE_ID, S_DOOR);
                    }
                    
                    void loop()
                    {
                        value = value == OPEN ? CLOSE : OPEN;
                        send(msg.set(value));
                        Serial.print("TestMessage to Serial that is not displaying.");
                        sleep(10000);
                    }
                    

                    It now compiles ok however the MY_TRANSPORT_WAIT_READY_MS 1 is still not blue. (Just a sanity check this define feature exists in library version 2.0.0. correct?)

                    Also still no serial prints:

                    TSM:INIT
                    TSM:RADIO:OK
                    TSP:ASSIGNID:OK (ID=2)
                    TSM:FPAR
                    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                    TSM:FPAR
                    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                    TSM:FPAR
                    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                    TSM:FPAR
                    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                    !TSM:FPAR:FAIL
                    !TSM:FAILURE
                    TSM:PDT
                    TSM:INIT
                    TSM:RADIO:OK
                    TSP:ASSIGNID:OK (ID=2)
                    
                    1 Reply Last reply
                    0
                    • hekH hek

                      Put MySensors include at the bottom of the file (or at least below the defines)

                      samburner3S Offline
                      samburner3S Offline
                      samburner3
                      wrote on last edited by
                      #11

                      @hek Ok I tried again using lib version 2.1.1. and it works!

                      3 TSM:INIT
                      4 TSF:WUR:MS=1
                      11 TSM:INIT:TSP OK
                      13 TSF:SID:OK,ID=2
                      14 TSM:FPAR
                      1613 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                      1620 MCO:BGN:STP
                      1622 MCO:BGN:INIT OK,TSP=0
                      1625 !MCO:SND:NODE NOT REG
                      TestMessage to Serial that is not displaying.1627 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
                      1635 !MCO:SLP:TNR
                      3621 !TSM:FPAR:NO REPLY
                      3623 TSM:FPAR
                      5223 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                      7230 !TSM:FPAR:NO REPLY
                      7232 TSM:FPAR
                      8832 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                      10839 !TSM:FPAR:NO REPLY
                      10841 TSM:FPAR
                      

                      However the '1' is still not blue
                      0_1485186778237_Screen Shot 2017-01-24 at 2.52.20 AM.png

                      and got the compile warning

                      warning: "MY_TRANSPORT_WAIT_READY_MS" redefined
                       #define MY_TRANSPORT_WAIT_READY_MS 1
                      note: this is the location of the previous definition
                       #define MY_TRANSPORT_WAIT_READY_MS (0ul)
                      

                      Glad it is working, however would the output suggest it is not connected to the gate way or just not registered? (forgive me I should RTFM go read the serial debug output message documentation)

                      Is the MY_TRANSPORT_WAIT_READY_MS needed when not just connected to the gateway or when its has not been 'included' or regestered?

                      So the main code im MySensors won't run until what condition is met? (forgive me again I am still learning the exciting mySensors lib :)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      15

                      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