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. Call to begin function hangs arduino

Call to begin function hangs arduino

Scheduled Pinned Locked Moved Troubleshooting
hangarduinonrf24l01+
5 Posts 3 Posters 3.4k 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.
  • gerardG Offline
    gerardG Offline
    gerard
    wrote on last edited by
    #1

    I have a NRF24L01+ module connected to an arduino uno board. I use a 100uF 25V capacitor. When execute sketch arduino hangs and returns this text in serial output:

    send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0

    I tried to call MySensor constructor and begin function with and without parameters.

    Where is the problem?

    Thanks

    The code I used is

    #include <MySensor.h>
    #include <MySigningNone.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <SPI.h>
     
    #define ID 0
    #define OPEN 1
    #define CLOSE 0
    
    MyTransportNRF24 transport(9, 10);
    MySigningNone signer;
    MyHwATMega328 hw;
    MySensor gw(transport,hw);
    //MySensor gw;
    MyMessage msg(ID, V_TRIPPED);
    
    void response(const MyMessage &m){
    
    }
     
    void setup() 
    { 
      Serial.begin(115200);
      //Serial.print("Setup ");
      gw.begin(response,2,false,AUTO);
      //gw.begin();
      Serial.println("begin");
      gw.present(ID, S_DOOR,"Sensor de prova",false); 
    }
     
    void loop()
    {
         Serial.print("Identificador ");
         Serial.println(gw.getNodeId());
         gw.send(msg.set(OPEN));
         gw.sendSketchInfo("Sketch de prova","0.0", true);
         delay(1000); // Wait 10 seconds
    }```
    BartEB 1 Reply Last reply
    0
    • gerardG gerard

      I have a NRF24L01+ module connected to an arduino uno board. I use a 100uF 25V capacitor. When execute sketch arduino hangs and returns this text in serial output:

      send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0

      I tried to call MySensor constructor and begin function with and without parameters.

      Where is the problem?

      Thanks

      The code I used is

      #include <MySensor.h>
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyHwATMega328.h>
      #include <SPI.h>
       
      #define ID 0
      #define OPEN 1
      #define CLOSE 0
      
      MyTransportNRF24 transport(9, 10);
      MySigningNone signer;
      MyHwATMega328 hw;
      MySensor gw(transport,hw);
      //MySensor gw;
      MyMessage msg(ID, V_TRIPPED);
      
      void response(const MyMessage &m){
      
      }
       
      void setup() 
      { 
        Serial.begin(115200);
        //Serial.print("Setup ");
        gw.begin(response,2,false,AUTO);
        //gw.begin();
        Serial.println("begin");
        gw.present(ID, S_DOOR,"Sensor de prova",false); 
      }
       
      void loop()
      {
           Serial.print("Identificador ");
           Serial.println(gw.getNodeId());
           gw.send(msg.set(OPEN));
           gw.sendSketchInfo("Sketch de prova","0.0", true);
           delay(1000); // Wait 10 seconds
      }```
      BartEB Offline
      BartEB Offline
      BartE
      Contest Winner
      wrote on last edited by
      #2

      @gerard What do you want to achive with this sketch?

      Normally this line is located in the setup() fucntion, sending this message once in enough

      gw.sendSketchInfo("Sketch de prova","0.0", true);
      

      And beter use

      gw.wait(1000);
      

      in stead of delay().

      During the gw.wait() the gw.process() function is called which handles the MySensor incomming messages.

      1 Reply Last reply
      0
      • gerardG Offline
        gerardG Offline
        gerard
        wrote on last edited by
        #3

        @BartE Its simply a test. My final project is to connect a motion sensor and a NRF24L01+ module to an arduino nano board. And in the other side another arduino with a NRF24L01+ module connected to a Raspberry.
        But at this moment I just want to test communication between two nodes

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SiLeX
          wrote on last edited by
          #4

          I can confirm that the Arduino hangs at the init, if it cannot communicate with the nRF24L01+.

          Often had that "issue" when I accidentally disconnected the MOSI cable and the communcation was broken. There seems to be no timeout though. If you enable the MySensors debugging, you will see radio init... on your serial line.

          I now use this behaviour as a kind of self-test. In the setup() of my sketches, I turn on an LED, do the radio init and turn it off afterwards. If it stays on, I know there is something wrong with the radio. Without even connecting a single serial cable.

          Maybe you can use it this way, too.

          Just to clarify: The hang will not happen if you have a bad radio range. It will only happen if the local communcation through SPI fails.

          gerardG 1 Reply Last reply
          1
          • S SiLeX

            I can confirm that the Arduino hangs at the init, if it cannot communicate with the nRF24L01+.

            Often had that "issue" when I accidentally disconnected the MOSI cable and the communcation was broken. There seems to be no timeout though. If you enable the MySensors debugging, you will see radio init... on your serial line.

            I now use this behaviour as a kind of self-test. In the setup() of my sketches, I turn on an LED, do the radio init and turn it off afterwards. If it stays on, I know there is something wrong with the radio. Without even connecting a single serial cable.

            Maybe you can use it this way, too.

            Just to clarify: The hang will not happen if you have a bad radio range. It will only happen if the local communcation through SPI fails.

            gerardG Offline
            gerardG Offline
            gerard
            wrote on last edited by
            #5

            @SiLeX So it may be due to an incorrect connection? Pins of module are untagged and I connected them according to the positions of schemes that I found online. All modules have same pinout?

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


            24

            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