Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 26 to 50 of 55

Thread: Teensy 4.0 + nrf24l01

  1. #26
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    Not sure yet... Actually I have the Radiohead client/server now running on T4 and T4.1 as I found my package of the NRF... from Addicore that I purchased awhile ago...

    So far they ARE NOT talking... But did confirm it looks like they don't need PUs...

    Not sure why you can not upload pictures. Maybe need a few more posts? But here is a small capture on Logic Analyzer of pins, on the Server one (while waiting for data from client... I put a 5ms pause between calls to see if that might make a difference... So far not.

    Click image for larger version. 

Name:	screenshot.jpg 
Views:	16 
Size:	174.2 KB 
ID:	21450

    I had it also show the analog of the MISO pin to see what voltage...

    Will look also see if anything makes sense.

  2. #27
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,397
    Photos have a small size limit of near 1MB - one image there was 3.7 MB.

    It tends to reject without notice or info. It also seems to constrain dimensions at times?

    If stored elsewhere they can be linked and sometime copied - see if this works 'FROM URL' - won't 'retrieve' locally - but this is linked ( if google links are persistent to the file ) ??:




  3. #28
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    Quote Originally Posted by Wittecactus View Post
    Hi mjs513,

    Thank you for joining this thread and for helping us to find the solution . Correct me if I am wrong, but the RF69 uses the interrupt pin and for the nrf24l01 it is optional to use the interrupt pin. The simple client server code does not use the interrupt function. So the code is:

    Code:
     RH_NRF24 nrf24(CS, CSN);


    So I think that, that piece of the code is correct. But still thank you for your suggestion because I now double checked it.

    (If I said something wrong or if I did not understand you well, just say it because I am not a expert myself)

    Thank you for your help and for your suggestion.

    Have a great day,

    Becarfeful, if you look at the constructor in the .cpp file:
    Code:
    uint8_t slaveSelectPin, uint8_t interruptPin, uint8_t sdnPin, RHGenericSPI& spi)
    it appears that it looking a certain order of pins so your constructor would be, I think,
    Code:
    RH_NRF24 nrf24(CS, IRQ, CSN);
    It looks like it wants the IRQ hooked up.

  4. #29
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    Quick update: The Radiohead client and server with both T4.x did not talk.

    But I just swapped in a T3.2 for a T4. Pulled T4 out of breadboard and plugged T3.2 in. No program change...
    And they are talking. I have logic captures of both T3.2 and T4 for this. So now will try to see if I see any logical difference.

    One thing I notice is timing between commands. On T3.2 the CS pin goes high between commands and width of High back to low is about 2.4-3us...
    On T4 they are typically less than .4us .. So would not be surprised if some timing issue. Like we need to give more time after some commands or the like.

  5. #30
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    @mjs513... I think I know where there may be some confusion.

    There are two very similar looking constructors and classes. NRF24 and RF24...

    Code:
       RH_NRF24(uint8_t chipEnablePin = 8, uint8_t slaveSelectPin = SS, RHGenericSPI& spi = hardware_spi);
    and
    Code:
        RH_RF24(uint8_t slaveSelectPin = SS, uint8_t interruptPin = 2, uint8_t sdnPin = 9, RHGenericSPI& spi = hardware_spi);

  6. #31
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    @KurtE
    Thanks - thats it. Was rumaging around after i posted and saw what I did. Had right example but opened the wrong .cpp file.

    Tried testing with my single radio and getting init failed so found another lib: https://github.com/nRF24/RF24 and gave it a try and it got an radio fail as well. One nice thing is that with the other lib it has a nice example sketch to get radio debug info.

    EDIT: Just ordered another set from amazon - should have tomorrow.

    Forgot to add - sounds like you found the problem now for the solution

  7. #32
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    @KurtE - messed up my T3.6. How do you do a reset on a T3.6?

  8. #33
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    @mjs513 - Sort of the same was as T4.x... Hold the program button for about 15 seconds, But there is a timeout after N more seconds... So it usually takes me a couple of attempts to get it to work... (Or use hammer and use a different one )

    For the heck of it I thought I would try the RF24 library as Sparkfun suggests using it.

    I loaded up the GettingStarted Sketch.

    Started off with T3.2 and T4.1

    Edited line: RF24 radio(9,10); And built on T3.2 leaving radioNumber = 0

    On the T4.1 I changed the radioNumber = 1 and downloaded...

    Noticed I was not seeing the messages at start so edited:
    Code:
    void setup() {
      while(!Serial && millis() < 4000) ;
      Serial.begin(115200);
      Serial.println(F("RF24/examples/GettingStarted"));
      Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
      Serial.flush();
      radio.begin();
    ...
    And then showed that I need to type a T So I did:
    And started seeing things like in the Terminal monitor for T4.1:
    Code:
    Now sending
    Sent 423326336, Got response 423326336, Round-trip delay 1494 microseconds
    Now sending
    Sent 424328145, Got response 424328145, Round-trip delay 1494 microseconds
    Now sending
    And in other:
    Code:
    Sent response 485440639
    Sent response 486442448
    Sent response 487444269
    Sent response 488446090
    ...
    So I replaced the T3.2 back with T4 and programmed it and it continued to work for T4 to T4.1...
    Restarted both boards, did the T this time from the T4 and it worked talking to T4.1...

    Build shows I am using the RF24 out of my libraries folder...
    Code:
    Multiple libraries were found for "RF24.h"
     Used: C:\Users\kurte\Documents\Arduino\libraries\RF24
     Not used: C:\Users\kurte\Documents\Arduino\libraries\arduino_367930
    Using library SPI at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\SPI 
    Using library RF24 at version 1.3.9 in folder: C:\Users\kurte\Documents\Arduino\libraries\RF24
    So in this case at least the basics work.

    But sort of side point it the one that is waiting to receive data is totally saturating the SPI bus ... As you maybe can see in:
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	10 
Size:	63.5 KB 
ID:	21454
    It cycles through a lot of asking for the current status until it shows the RX is not empty.

    You can see some of this in this portion at the end of one of those clumps...
    Click image for larger version. 

Name:	screenshot2.jpg 
Views:	10 
Size:	145.0 KB 
ID:	21455

    Note the top channel (0) which I shrunk the height of is the IRQ pin... Looks like it drops low when it receives data. Wonder if the library can be configured to look at IRQ pin...
    Probably, I just have not looked yet.

  9. #34
    Junior Member
    Join Date
    Aug 2020
    Posts
    17
    Quote Originally Posted by KurtE View Post
    @mjs513 - Sort of the same was as T4.x... Hold the program button for about 15 seconds, But there is a timeout after N more seconds... So it usually takes me a couple of attempts to get it to work... (Or use hammer and use a different one )

    For the heck of it I thought I would try the RF24 library as Sparkfun suggests using it.

    I loaded up the GettingStarted Sketch.

    Started off with T3.2 and T4.1

    Edited line: RF24 radio(9,10); And built on T3.2 leaving radioNumber = 0

    On the T4.1 I changed the radioNumber = 1 and downloaded...

    Noticed I was not seeing the messages at start so edited:
    Code:
    void setup() {
      while(!Serial && millis() < 4000) ;
      Serial.begin(115200);
      Serial.println(F("RF24/examples/GettingStarted"));
      Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
      Serial.flush();
      radio.begin();
    ...
    And then showed that I need to type a T So I did:
    And started seeing things like in the Terminal monitor for T4.1:
    Code:
    Now sending
    Sent 423326336, Got response 423326336, Round-trip delay 1494 microseconds
    Now sending
    Sent 424328145, Got response 424328145, Round-trip delay 1494 microseconds
    Now sending
    And in other:
    Code:
    Sent response 485440639
    Sent response 486442448
    Sent response 487444269
    Sent response 488446090
    ...
    So I replaced the T3.2 back with T4 and programmed it and it continued to work for T4 to T4.1...
    Restarted both boards, did the T this time from the T4 and it worked talking to T4.1...

    Build shows I am using the RF24 out of my libraries folder...
    Code:
    Multiple libraries were found for "RF24.h"
     Used: C:\Users\kurte\Documents\Arduino\libraries\RF24
     Not used: C:\Users\kurte\Documents\Arduino\libraries\arduino_367930
    Using library SPI at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\SPI 
    Using library RF24 at version 1.3.9 in folder: C:\Users\kurte\Documents\Arduino\libraries\RF24
    So in this case at least the basics work.

    But sort of side point it the one that is waiting to receive data is totally saturating the SPI bus ... As you maybe can see in:
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	10 
Size:	63.5 KB 
ID:	21454
    It cycles through a lot of asking for the current status until it shows the RX is not empty.

    You can see some of this in this portion at the end of one of those clumps...
    Click image for larger version. 

Name:	screenshot2.jpg 
Views:	10 
Size:	145.0 KB 
ID:	21455

    Note the top channel (0) which I shrunk the height of is the IRQ pin... Looks like it drops low when it receives data. Wonder if the library can be configured to look at IRQ pin...
    Probably, I just have not looked yet.
    Hi,

    Thank you again for your great help. These are really promising results. This morning I tested it on my arduino Mega and the Teensy 4.0 (I do not have two Teensy's to test the exacts same setup.

    Great news here too: There is "some" communication, the only thing is, it is only one way......... So the Teensy can send something to the Arduino Mega but the Arduino Mega can not send something to the Teensy. (So if the Arduino Mega is in transmitting mode nothing happens, when Teensy is in transmit mode it can send data to the Mega but the Mega can not send a response back. This give the following result:

    Click image for larger version. 

Name:	Results.jpg 
Views:	9 
Size:	90.0 KB 
ID:	21457

    You have Teensy to Teensy contact, can it be possible that you can test Arduino to Teensy contact?

    Maybe I am doing something wrong so here are my codes:

    Arduino Mega:

    Code:
    /*
    * Getting Started example sketch for nRF24L01+ radios
    * This is a very basic example of how to send data from one node to another
    * Updated: Dec 2014 by TMRh20
    */
    
    #include <SPI.h>
    #include "RF24.h"
    
    /****************** User Config ***************************/
    /***      Set this radio as radio number 0 or 1         ***/
    bool radioNumber = 0;
    
    /* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
    RF24 radio(7,8);
    /**********************************************************/
    
    byte addresses[][6] = {"1Node","2Node"};
    
    // Used to control whether this node is sending or receiving
    bool role = 0;
    
    void setup() {
      Serial.begin(115200);
      Serial.println(F("RF24/examples/GettingStarted"));
      Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
      
      radio.begin();
    
      // Set the PA Level low to prevent power supply related issues since this is a
     // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
      radio.setPALevel(RF24_PA_LOW);
      
      // Open a writing and reading pipe on each radio, with opposite addresses
      if(radioNumber){
        radio.openWritingPipe(addresses[1]);
        radio.openReadingPipe(1,addresses[0]);
      }else{
        radio.openWritingPipe(addresses[0]);
        radio.openReadingPipe(1,addresses[1]);
      }
      
      // Start the radio listening for data
      radio.startListening();
    }
    
    void loop() {
      
      
    /****************** Ping Out Role ***************************/  
    if (role == 1)  {
        
        radio.stopListening();                                    // First, stop listening so we can talk.
        
        
        Serial.println(F("Now sending"));
    
        unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
         if (!radio.write( &start_time, sizeof(unsigned long) )){
           Serial.println(F("failed"));
         }
            
        radio.startListening();                                    // Now, continue listening
        
        unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
        boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
        
        while ( ! radio.available() ){                             // While nothing is received
          if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
              timeout = true;
              break;
          }      
        }
            
        if ( timeout ){                                             // Describe the results
            Serial.println(F("Failed, response timed out."));
        }else{
            unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
            radio.read( &got_time, sizeof(unsigned long) );
            unsigned long end_time = micros();
            
            // Spew it
            Serial.print(F("Sent "));
            Serial.print(start_time);
            Serial.print(F(", Got response "));
            Serial.print(got_time);
            Serial.print(F(", Round-trip delay "));
            Serial.print(end_time-start_time);
            Serial.println(F(" microseconds"));
        }
    
        // Try again 1s later
        delay(1000);
      }
    
    
    
    /****************** Pong Back Role ***************************/
    
      if ( role == 0 )
      {
        unsigned long got_time;
        
        if( radio.available()){
                                                                        // Variable for the received timestamp
          while (radio.available()) {                                   // While there is data ready
            radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
          }
         
          radio.stopListening();                                        // First, stop listening so we can talk   
          radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
          radio.startListening();                                       // Now, resume listening so we catch the next packets.     
          Serial.print(F("Sent response "));
          Serial.println(got_time);  
       }
     }
    
    
    
    
    /****************** Change Roles via Serial Commands ***************************/
    
      if ( Serial.available() )
      {
        char c = toupper(Serial.read());
        if ( c == 'T' && role == 0 ){      
          Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
          role = 1;                  // Become the primary transmitter (ping out)
        
       }else
        if ( c == 'R' && role == 1 ){
          Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
           role = 0;                // Become the primary receiver (pong back)
           radio.startListening();
           
        }
      }
    
    
    } // Loop
    Teensy 4.0

    Code:
    /*
    * Getting Started example sketch for nRF24L01+ radios
    * This is a very basic example of how to send data from one node to another
    * Updated: Dec 2014 by TMRh20
    */
    
    #include <SPI.h>
    #include "RF24.h"
    
    /****************** User Config ***************************/
    /***      Set this radio as radio number 0 or 1         ***/
    bool radioNumber = 1;
    
    /* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
    RF24 radio(9,10);
    /**********************************************************/
    
    byte addresses[][6] = {"1Node","2Node"};
    
    // Used to control whether this node is sending or receiving
    bool role = 0;
    
    void setup() {
       while(!Serial && millis() < 4000) ;
      Serial.begin(115200);
      Serial.println(F("RF24/examples/GettingStarted"));
      Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
      Serial.flush();
      radio.begin();
    
      // Set the PA Level low to prevent power supply related issues since this is a
     // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
      radio.setPALevel(RF24_PA_LOW);
      
      // Open a writing and reading pipe on each radio, with opposite addresses
      if(radioNumber){
        radio.openWritingPipe(addresses[1]);
        radio.openReadingPipe(1,addresses[0]);
      }else{
        radio.openWritingPipe(addresses[0]);
        radio.openReadingPipe(1,addresses[1]);
      }
      
      // Start the radio listening for data
      radio.startListening();
    }
    
    void loop() {
      
      
    /****************** Ping Out Role ***************************/  
    if (role == 1)  {
        
        radio.stopListening();                                    // First, stop listening so we can talk.
        
        
        Serial.println(F("Now sending"));
    
        unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
         if (!radio.write( &start_time, sizeof(unsigned long) )){
           Serial.println(F("failed"));
         }
            
        radio.startListening();                                    // Now, continue listening
        
        unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
        boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
        
        while ( ! radio.available() ){                             // While nothing is received
          if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
              timeout = true;
              break;
          }      
        }
            
        if ( timeout ){                                             // Describe the results
            Serial.println(F("Failed, response timed out."));
        }else{
            unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
            radio.read( &got_time, sizeof(unsigned long) );
            unsigned long end_time = micros();
            
            // Spew it
            Serial.print(F("Sent "));
            Serial.print(start_time);
            Serial.print(F(", Got response "));
            Serial.print(got_time);
            Serial.print(F(", Round-trip delay "));
            Serial.print(end_time-start_time);
            Serial.println(F(" microseconds"));
        }
    
        // Try again 1s later
        delay(1000);
      }
    
    
    
    /****************** Pong Back Role ***************************/
    
      if ( role == 0 )
      {
        unsigned long got_time;
        
        if( radio.available()){
                                                                        // Variable for the received timestamp
          while (radio.available()) {                                   // While there is data ready
            radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
          }
         
          radio.stopListening();                                        // First, stop listening so we can talk   
          radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
          radio.startListening();                                       // Now, resume listening so we catch the next packets.     
          Serial.print(F("Sent response "));
          Serial.println(got_time);  
       }
     }
    
    
    
    
    /****************** Change Roles via Serial Commands ***************************/
    
      if ( Serial.available() )
      {
        char c = toupper(Serial.read());
        if ( c == 'T' && role == 0 ){      
          Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
          role = 1;                  // Become the primary transmitter (ping out)
        
       }else
        if ( c == 'R' && role == 1 ){
          Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
           role = 0;                // Become the primary receiver (pong back)
           radio.startListening();
           
        }
      }
    
    
    } // Loop
    Maybe the problem can be with the pins, so to be sure here are the pin connections:

    Arduino Mega:

    CE - 7
    CSN - 8
    SCK - 52
    MOSI - 51
    MISO - 50

    Teensy 4.0

    CE = 9
    CSN = 10
    SCK = 13
    MOSI = 11
    MISO = 12

    If there is more information that can be usefull just ask. I will just keep trying some stuff today especially related to why it can send but not receive.

    Thank you for your help.

    Have a great day,

  10. #35
    Junior Member
    Join Date
    Aug 2020
    Posts
    17
    Quote Originally Posted by defragster View Post
    Photos have a small size limit of near 1MB - one image there was 3.7 MB.

    It tends to reject without notice or info. It also seems to constrain dimensions at times?

    If stored elsewhere they can be linked and sometime copied - see if this works 'FROM URL' - won't 'retrieve' locally - but this is linked ( if google links are persistent to the file ) ??:



    Hi Defragster,

    Thank you, this explains a lot. I will trying to edit the previous posts so that the photos are included.

    Have a great day,

  11. #36
    Junior Member
    Join Date
    Aug 2020
    Posts
    17
    Quote Originally Posted by mjs513 View Post
    @KurtE
    Thanks - thats it. Was rumaging around after i posted and saw what I did. Had right example but opened the wrong .cpp file.

    Tried testing with my single radio and getting init failed so found another lib: https://github.com/nRF24/RF24 and gave it a try and it got an radio fail as well. One nice thing is that with the other lib it has a nice example sketch to get radio debug info.

    EDIT: Just ordered another set from amazon - should have tomorrow.

    Forgot to add - sounds like you found the problem now for the solution
    Hi Mjs513,

    Thank you for your help. It is really special that there are so many people like you on this forum that are constantly helping people. That you even ordered the radio is awesome!

    So thank you for that and I am curious of your results.

    Have a great day,

  12. #37
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    This morning I swapped in an Arduino Mega (I have an old 1280)... I ran this with the code you just posted, with the same pins. I did hook up the IRQ to pin 2, but did not do anything with it. And it appears to work fine. I tried switching the role of which one was the main transmitter...

    As you can see in this picture of two TyCommander windows open. One on each Serial port...

    Click image for larger version. 

Name:	screenshot.jpg 
Views:	16 
Size:	95.6 KB 
ID:	21458

    So not sure what is different. Note: I am running I think the latest version of the RF24 library:
    Code:
    Using library SPI at version 1.0 in folder: C:\arduino-1.8.13\hardware\arduino\avr\libraries\SPI 
    Using library RF24 at version 1.3.9 in folder: C:\Users\kurte\Documents\Arduino\libraries\RF24
    So not sure what is different.

    Side Notes:

    @mjs513 and several others of us do appear to collect lots of stuff I purchased my set from Amazon in 2014 and never used. I meant to try them out. I was thinking of setting up a new remote control using these instead of XBees.

    My memory may not be correct, but think @jwatte switched to these sometime back then and found that he had better luck with not getting the random timing issues like pauses with XBees and also maybe actually hooked up two sets. One for TX and one for RX... But again that was awhile ago and it might have been someone else...

  13. #38
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    Spoke too fast. Worked first time. Then started to fail...

    What is interesting is that it worked at first, but then stopped... Not sure what is going on yet....

  14. #39
    Junior Member
    Join Date
    Aug 2020
    Posts
    17
    Quote Originally Posted by KurtE View Post
    This morning I swapped in an Arduino Mega (I have an old 1280)... I ran this with the code you just posted, with the same pins. I did hook up the IRQ to pin 2, but did not do anything with it. And it appears to work fine. I tried switching the role of which one was the main transmitter...

    As you can see in this picture of two TyCommander windows open. One on each Serial port...

    Click image for larger version. 

Name:	screenshot.jpg 
Views:	16 
Size:	95.6 KB 
ID:	21458

    So not sure what is different. Note: I am running I think the latest version of the RF24 library:
    Code:
    Using library SPI at version 1.0 in folder: C:\arduino-1.8.13\hardware\arduino\avr\libraries\SPI 
    Using library RF24 at version 1.3.9 in folder: C:\Users\kurte\Documents\Arduino\libraries\RF24
    So not sure what is different.

    Side Notes:

    @mjs513 and several others of us do appear to collect lots of stuff I purchased my set from Amazon in 2014 and never used. I meant to try them out. I was thinking of setting up a new remote control using these instead of XBees.

    My memory may not be correct, but think @jwatte switched to these sometime back then and found that he had better luck with not getting the random timing issues like pauses with XBees and also maybe actually hooked up two sets. One for TX and one for RX... But again that was awhile ago and it might have been someone else...
    Hi KurtE,

    Promising results! I added the irq pin, updated the library but it still does not work (only one way communication). Then I was thinking maybe it is something related to the power supply. I unhooked the other electronics and then nothing worked. So I hooked up the power supply directly to the nrf24l01 and added some capicitors and now sometimes I get a response back, but it is really sometimes (every 10 seconds).

    So I am using these power boards for the nrf24l01, maybe it can be related to that? But it does work between arduino's so I do not think that that is the problem.

    Click image for larger version. 

Name:	5V-3.3V-VCC-Adapter-Board-for-NRF24L01-Wireless-Module-01.jpg 
Views:	10 
Size:	57.7 KB 
ID:	21461

    I now see that it stopped working for you..... So then maybe it still code related? It is all quite difficult and I hope that we will find the solution!

    Thank you for your help

    Have a great day,

  15. #40
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    Quote Originally Posted by KurtE
    And it appears to work fine. I tried switching the role of which one was the main transmitter...
    Got my radios and turn out they are of the NRF24+ variety. But that is neither here or there. Tried a couple of things using a T3.6 and a T4.1 (have to be different).

    1. Downloaded the latest and greatest Radiohead library but that seems to be dead for use with the NRF and the T4.1 for some reason.

    2. so went back to the RF24 library and both talked to each other. However.

    3. If i change the mode (T/R) on the T3.6 before I change it on the T4.1 I have problems with the T3.6 having sending errors. If i do the change on the T4.1 first no problem. Not sure why.

  16. #41
    Junior Member
    Join Date
    Aug 2020
    Location
    Montreal
    Posts
    16
    The naming is a bit confusing. The datasheet for the nRF24L01+ says :

    CSN is Chip Select : the N means NEGATE because it's active low. (page 11)

    CE is Chip Enable : high pulse activates transmit or receive. When CE is low, the chip goes into standby. (pages 23 and 75)

    The chip transmits when PRIM_RX (a bit in the CONFIG register) is low and receives when PRIM_RX is high (pages 23 and 75).

    On the oscilloscope, it looks like MISO and MOSI are active at the same time. Don't know if that's supposed to happen. The CSN looks ok.

    Sorry, I can't tell much more than that.

  17. #42
    Junior Member
    Join Date
    Aug 2020
    Location
    Montreal
    Posts
    16
    Hey, Wittecactus, did you try powering the radio from the 3.3v on the Teensy? That's how it works here.

  18. #43
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    @KurtE, et.al.
    I did a quick retest of the latest version of the RadioHead library running client and server on both the T3.6 and the T4.1 and it seems to be working with no issue at this point - must have did something wrong. But here is a screenshot of the one of the test cases. Doesn't seem like its dying but didn't run for an extended period of time. If i can find my mega I will give it a try as well:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	45.9 KB 
ID:	21469

  19. #44
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    Hi @mjs513 - For the heck of it, I have I think merged the latest stuff into the RadioHead library in to my fork and a new branch merge_latest

    Right now trying to get the T4 to talk to the Arduino Mega. Using T4(nrf24_client) and Mega(nrf24_server)

    At first I could not get the INIT to succeed on Mega. I had the IRQ pin connected to pin2, doing a pinMode(2, INPUT); And now it appears to init.
    But so far not receiving anything from the Teensy...

    Still playing.

  20. #45
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    Hi @KurtE - funny was just going to let you know i was doing the exact same thing.

    Got same results as you. Except not the T4.1 does not want to act as a server. Going to try your branch. What did you do with the IRQ pin - just assign it?

  21. #46
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    On the T4, I put the IRQ to pin 6... Maybe will move to pin 2 to be consistent...

    The T4 client one starts up OK (I think)...
    And the Mega starts up... As you might see in the following partial screen short (WindowsKey+SHIFT+S) where I have two instances of the Beta Logic analyzer software running and I have one LA on each of the two boards and did a capture... Sort of nice seeing two of them at same time...
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	14 
Size:	102.5 KB 
ID:	21471

    Still debugging

  22. #47
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    Hi again...

    @mjs513, I made sort of the same changes you suggested except I went to 4mhz instead, since comments said 8mhz was not reliable...

    Code:
    bool RH_NRF24::init()
    {
        // Teensy with nRF24 is unreliable at 8MHz:
        // so is Arduino with RF73
        // Must allow the radio time to settle else configuration bits will not necessarily stick.
        // This is actually only required following power up but some settling time also appears to
        // be required after resets too. For full coverage, we'll always assume the worst.
        // Enabling 16b CRC is by far the most obvious case if the wrong timing is used - or skipped.
        // Technically we require 4.5ms + 14us as a worst case. We'll just call it 5ms for good measure.
        // WARNING: Delay is based on P-variant whereby non-P *may* require different timing.
        delay(15);
        //Serial.print("RH_NRF24::init CE: ");
        //Serial.println(_chipEnablePin, DEC);
        // lets try 4...
        _spi.setFrequency(RHGenericSPI::Frequency4MHz);
        _spi.setBitOrder(RHGenericSPI::BitOrderMSBFirst);
        _spi.setDataMode(RHGenericSPI::DataMode0);
    
        if (!RHNRFSPIDriver::init())
    	return false;
        //Serial.println("After RHNRFSPIDriver::init()");
        // Initialise the slave select pin
        pinMode(_chipEnablePin, OUTPUT);
        digitalWrite(_chipEnablePin, LOW);
      
        // Clear interrupts
        spiWriteRegister(RH_NRF24_REG_07_STATUS, RH_NRF24_RX_DR | RH_NRF24_TX_DS | RH_NRF24_MAX_RT);
        // Enable dynamic payload length on all pipes
        spiWriteRegister(RH_NRF24_REG_1C_DYNPD, RH_NRF24_DPL_ALL);
        // Enable dynamic payload length, disable payload-with-ack, enable noack
        spiWriteRegister(RH_NRF24_REG_1D_FEATURE, RH_NRF24_EN_DPL | RH_NRF24_EN_DYN_ACK);
        // Test if there is actually a device connected and responding
        // CAUTION: RFM73 and version 2.0 silicon may require ACTIVATE
        if (spiReadRegister(RH_NRF24_REG_1D_FEATURE) != (RH_NRF24_EN_DPL | RH_NRF24_EN_DYN_ACK))
        { 
    	spiWrite(RH_NRF24_COMMAND_ACTIVATE, 0x73);
            // Enable dynamic payload length, disable payload-with-ack, enable noack
            spiWriteRegister(RH_NRF24_REG_1D_FEATURE, RH_NRF24_EN_DPL | RH_NRF24_EN_DYN_ACK);
            if (spiReadRegister(RH_NRF24_REG_1D_FEATURE) != (RH_NRF24_EN_DPL | RH_NRF24_EN_DYN_ACK)) {
                //Serial.println("Failed RH_NRF24_REG_1D_FEATURE");
                return false;
            }
        }
    
        clearRxBuf();
    
        // Make sure we are powered down
        setModeIdle();
    
        // Flush FIFOs
        flushTx();
        flushRx();
    
        setChannel(2); // The default, in case it was set by another app without powering down
        setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm);
    
        return true;
    }
    And maybe the key maybe is that defaults for SPI Mode or like different between the two platforms?

    But good news is I build for a T4 and an Arduino Mega and they are talking...

    Here is Screen shot of Arduino Mega Logic Analyzer running Server...
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	8 
Size:	95.7 KB 
ID:	21487

    I pushed the change up to my fork/branch...

    The interesting thing here would be to look at the top line which is the IRQ line and make version that uses this to know when something has been received.

  23. #48
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    @KurtE
    Great you got the 2 talking to each other.

    A couple of comments. Been running at 8Mhz for the T4.1 and the T3.6 with any issue but don't know if there is any impact on the T3.2 or a T2.

    Unfortunately I cant get the nRF24 working on the mega or the Due no matter what I tried. Still keeps giving me "initialization failed". So either my mega is dead or something else going on with SPI. But the mega doesn't work with the RF24 library either so maybe something with the Mega. Maybe with SPI implementation.

    Not sure you need anything else in the code besides changing the SPI speed.

    The interesting thing here would be to look at the top line which is the IRQ line and make version that uses this to know when something has been received.
    Looked at what he did for the rf24 and looks like it would take some rework to the lib to make that happen but knowing you, you will find a simpler way to do it

  24. #49
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,658
    @mjs513 - I had better luck when I told the pin that is the IRQ pin to be in input mode...


    Here is the sketch I was using on the Mega:
    Code:
    // nrf24_server.pde
    // -*- mode: C++ -*-
    // Example sketch showing how to create a simple messageing server
    // with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
    // reliability, so you should only use RH_NRF24  if you do not need the higher
    // level messaging abilities.
    // It is designed to work with the other example nrf24_client
    // Tested on Uno with Sparkfun NRF25L01 module
    // Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
    // Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
    
    #include <SPI.h>
    #include <RH_NRF24.h>
    
    // Singleton instance of the radio driver
    RH_NRF24 nrf24(9, 10);
    // RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
    // RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
    // RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
    
    void setup() 
    {
      Serial.begin(9600);
      pinMode(2, INPUT);
      while (!Serial) 
        ; // wait for serial port to connect. Needed for Leonardo only
      Serial.println("Starting up Server");    
      if (!nrf24.init())
        Serial.println("init failed");
      // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
      if (!nrf24.setChannel(1))
        Serial.println("setChannel failed");
      if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
        Serial.println("setRF failed");    
    }
    
    void loop()
    {
      if (nrf24.available())
      {
        // Should be a message for us now   
        uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
        uint8_t len = sizeof(buf);
        if (nrf24.recv(buf, &len))
        {
    //      NRF24::printBuffer("request: ", buf, len);
          Serial.print("got request: ");
          Serial.println((char*)buf);
          
          // Send a reply
          uint8_t data[] = "And hello back to you";
          nrf24.send(data, sizeof(data));
          nrf24.waitPacketSent();
          Serial.println("Sent a reply");
        }
        else
        {
          Serial.println("recv failed");
        }
      }
    }
    First step for IRQ pin, would be to simply check it first before calling nrf24.available... Simply do a digitalRead and see if LOW then process else don't do anything...

  25. #50
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,601
    @KurtE
    Tried the IRQ 2 method as well but no luck with that but will try again. I was testing with Sainsmart 2560 don't think that should make a difference though. So...

    Found my genuine Arduino Uno hooked it up and ran it at 4Mhz was a bit sluggish and would loose packets. Changed it to 8Mhz and both T4.1 and Uno are talking to each other.

    Still not sure why Mega is having a problem.

    When I get the energy i will try again.

    UPDATE: Used pins 9,10 instead of 8, 53 and now its working like a charm at 8Mhz, Thats with no IRQ

    Can't believe thats all it was

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •