Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 41

Thread: Does anybody get Teensy 3 working with NRF24L01+?

  1. #1

    Does anybody get Teensy 3 working with NRF24L01+?

    I'm using this library with Teensy 3.0 and a NRF24L01+: http://playground.arduino.cc/Interfa...dware/Nrf24L01

    I checked the code, and it doesn't seem system dependent because it uses SPI interface. The code that I'm using is the ping_server and ping_client example. The only difference is I'm setting up CSN and CE like this:

    Mirf.cePin = 9;
    Mirf.csnPin = 10;

    For testing purpose I used 2 arduino Uno with the same code to make sure everything was wired correctly. Now, I'm moving my ping_server to the Teensy, it compiles and uploads ok. But I can't get the packets on it.

    Maybe something that I'm missing?

    I used this pins:
    SS (CSN) = 10
    MOSI = 11
    MISO = 12
    SCK = 13
    CE = 9
    IRQ = DISCONNECTED

    And connecting as the following image: http://arduino-info.wikispaces.com/f...Pinout-800.jpg

    On uno it works, on teensy it doesn't.

    Any ideas?

    Thanks

  2. #2
    I think I made some progress.

    My client station sends a char to the server station it is always 'A'. I'm still testing with 2 arduino uno boards, and it is working with then. Moving the "receiver" (server) to teensy.

    I realized that the Mirf library uses:

    SPI.setDataMode(SPI_MODE0);
    SPI.setClockDivider(SPI_2XCLOCK_MASK);

    With this I received random chars but at least the address (registers) read on:
    RX_ADDR_P0 = E7
    RX_ADDR_P1 = 73
    TX_ADDR = 5

    Are correct. If I try to change the MODE it goes wrong, so I'm assuming, I need MODE0. But I receive random chars.

    Changing to: SPI_CLOCK_MASK gives me random chars too.
    Changing to any SPI_CLOCK_DIV I receive random chars as well.

    I tried to go with a lower clock too (24mhz) but I get the same behavior. Ideas? :/

    When you're using Teensy SPI does it enable pullup resistor by default? If yes, what is it value?

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,788
    Are you using the module from Sparkfun? Or is it from some other source?

  4. #4
    Hello Paul,

    I'm using nrf24l01+ from a ebay seller but I believe it is basically the same.

    Any idea to sparkfun ones? I could try the idea, maybe it will help me.

  5. #5
    I think I got this working. I will run some more tests by tomorrow and post here an update.

    For now, I can say that I'm using on MirfHardwareSpiDriver.cpp

    SPI.setDataMode(SPI_MODE0);
    SPI.setClockDivider(SPI_CLOCK_DIV2);

    Tested with: SPI_2XCLOCK_MASK (default value) and SPI_CLOCK_DIV4 and SPI_CLOCK_DIV2.

    I think it was an issue with the data rate.

    PS: I'm using Mirf library with SPI one. Maybe I forget any modifications that I did. Will try with a fresh ide tomorrow.

  6. #6
    That is bizarre. Today I'm testing the examples sketches of Mirf library, ping_client and ping_server. Yesterday it wasn't working. Now it is without any bigger changes. The only change that I made was setup the cePin and csnPin
    Mirf.cePin = 9;
    Mirf.csnPin = 10;

    I thought that it could be the wires, but after all connections I tested then with a multimeter (continuity test?) and everything was ok. So I have no idea what changed. Maybe some neighbor or homie has something that works on the same specific channel or some kind of interference.

    So if somebody has an idea what could had changed. Let me know, then I can run more tests and figure out what is going on.

  7. #7
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Hello matheusbrat,
    did you manage to get a working library for the nRF24L01+ on Teensy 3.0 ? It would be really great if you could share it.
    If you need some testers for your ideas and betas, i have 2 Teensy 3.0, 4 arduinos and 8 RF24 modules.

    I tried the RF24t.zip you posted in another post, but no success.

    Thanks

  8. #8
    Hey benkuper,

    I was working on a library to node communications on top of NRF24L01+. My protocol work on top of maniacbugs RF24 library.

    The NRF24L01+ library that I was using can be found:
    https://github.com/x-warrior/RF24SH/...librf24/teensy

    Sadly, my Teensy has gone (died) and the shipping costs are kind of prohibitive. I will be back working on teensy when I find somebody to bring the teensy from US to Brazil for me.

    Anyway, if you need some help, please drop me a line. I will be glad to help.

    Best regards,
    Matheus

  9. #9
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Wow, you are very fast !
    Thanks for your answer and sharing your lib, i didn't get to find it elsewhere.

    This looks very promising !
    I tried to get it working, i see that with 2 arduinos there is a connection made (however i can't understand what actually happens).

    Could you explain how your library works ? (or if you did some doc, i can read it before)

    When i try to replace the station arduino with a teensy, i get nothing in the Serial console and the communication stops working, same result with Teensy as master and Arduino as station...
    I am wondering if i got the wiring right on the Teensy, could you help me with that and explain what is your wiring ?
    Currently my wiring is (on the Teensy 3.0):
    -SCK on the pin 13
    - MOSI (DIN) on the pin 12
    - MISO (DOUT) on the pin 11
    - CSn on the pin 10
    - CE on the pin 9
    - 3.3V on the 3.3V pin of the Teensy
    - GND on the AGND pin of the Teensy

    is it right ?

    Thanks for the help, have a nice day !
    Ben

  10. #10
    Well the easy way to use is just to get the librf24 outisde of my project and use the RF24 (from maniacbugs) examples.

    My library is supposed to have a master station listening to connections when stations connects, it sends a message on a reserved channel, it has a protocol to distribute the ID. When other stations connects there are some logic to decide how will be that nodes parent. and the node can just communicate directly to own parent/own childs. It will create a network. All this to be a network where nodes can connect without any user configuration (to be easy to use by non tech users). The idea in the future is to have multiple types of stations. Where you can just turn it on and start using (it will need a master and to be inside a range of other connected peer).

    There is no documentation for now, sorry. I'm trying to find more time to put on this project but right now it is hard to find it.

    Looking inside RF24 library constructor on https://github.com/x-warrior/RF24SH/...duino/RF24.cpp
    You can see that RF24(ce, csn)

    And on https://github.com/x-warrior/RF24SH/...ricStation.cpp you can see that I use
    radio(9, 10)

    So SCK, MOSI, MISO, CSN, CE, 3.3V seems right. But the GND, I'm not sure about what the AGND means. If I record correctly I used the GND pin.

    As I told you, I can't go much further than what I still remember since I don't have a teensy right now.

    If you have some arduinos around, I recommend to start using the library inside arduino and getting then to communicate, with arduino there is a lot of debug messages. Teensy version doesn't. It was kind of tricky to get mine working.

    Ha

  11. #11
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Hello again
    I kept trying and trying without any [positive] result...

    I managed to port the printf code to Serial.print so i got the printDetails() function working (tested on Arduino Uno, RedBoard and Fio, all working as expected, Teensy is outputing correctly) but the Teensy is hard to crack

    I tried mutiple wirings, got back to the original one. I don't know if it comes from the library or the hardware, but when i test the "Getting Started" code, the Teensy (in Receive role) keeps sending "Got payload.. sent response" messages, even when it's the only module connected..

    I tried to reproduce this behavior on arduino to see if it came from a wiring problem, and i manage to get this behavior by unplugging one of the following cables (tested one by one) : ground / CE / CSN

    The most weird thing is that now that i got some info from the library for Teensy, i tested some plugging / unplugging / swapping pins on the Teensy, and the infos change ! But nothing that makes sense (even if it seems stable, i.e. same cable plugged/unplugged twice = same result).
    For instance, i got some times Data rates at 1Mbps or 2Mbps (without changing anything on the code, just plugging / unplugging and rebooting the Teensy), got CRC either on 8bit, 16bit or disabled depending on which cable has been unplugged, etc..

    The only thing that makes really sense is the model name : on arduinos, the model name is output correctly ONLY if all the wiring is good and the setup is working (so i can see "nRF24L01+" when it's working instead of "nRF24L01" when it's not working).
    On the Teensy, i never managed to get the "nRF24L01+" on the output, so i'm assuming if i can get this model name to get the tiny "+" in the output, it will be good sign..

    I'm very lost and very sad !!
    The nRF24L01+ combined with Teensy is a really tiny and powerful solution for our project, and we don't really wan't to have to go to Fio or Xbee...


    Thanks again,

    Ben
    Last edited by benkuper; 05-28-2013 at 08:03 PM.

  12. #12
    I got mine to work with the Teensy3.

    I am basically using the library RF24Network (https://github.com/maniacbug/RF24Network). Just comment out all the printf related commands in the library files and it works like a charm. I got one to send and another to receive.

    It should be straight forward, but feel free to drop me a message if it still doesn't work for you.

  13. #13
    Kian,

    That is what I did on mine. Maybe on my work on my library I changed something and I don't remember.

    benkunper,

    Can you try to do the same as Kian? And have you tried the NRF24L01+ on arduino too? Is it working? I remember that one of mine was 'burned' or something (it wasn't working)

  14. #14
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Hello Kian and matheus ,

    Thanks for that i will try it today !

    Maybe you can upload or send me some photos of a working setup/wiring with the Teensy ? Because i'm not really sure i connect it properly with the Teensy 3.

    On arduino, i got them working on Uno, Redboard and Fio without too much problem, so i'm pretty sure the rf modules are not burned down.


    Edit : just to be sure, as i got only one teensy for now (i will get more later in the month), a setup with one teensy+rf24 as receiver/sender and an arduino+rf24 as sender/receiver should work, right ? Or is there a need for the 2 rf24 to be connected to the same hardware family ?

    Edit 2 : Actually, i got the RedBoard and the Fio working in one way but not the other, tested with all combinations possible : changing modules, changing roles, same result ! the Redboard (Uno fork from Sparkfun) can send data to the Fio, and the Fio receive it. But the data sent back by the Fio is never received by the Redboard. i can see that the printDetails are not the same on the Redboard and Fio (the TX address is different, even if the code is the same).

    I'll try and tell you what i got.

    Thanks again,
    Ben
    Last edited by benkuper; 05-29-2013 at 11:21 AM.

  15. #15
    Junior Member
    Join Date
    May 2013
    Posts
    9
    So, i tested the RF24Network lib, as well as the RF24.
    I took the time to modify both in order to get more info, and especially the printDetails() function working.
    With the teensy on one side, and the redBoard on the other side, nothing is working...

    I attached the modified library with the printDetails() working, and a screenshot of my setup.
    The Left window (COM9) is the Redboard showing a working init of the RF24 (model = nRF24L01+) and the right window (COM8) is the Teensy3 not working (model = nRF24L01, CRC Length=Disabled, PA Power =PA_MIN... where it should be nRF24L01+, CRC Length = 16Bit and PA Power = PA_HIGH)


    RF24Network mod for Teensy with prints.zip


    Click image for larger version. 

Name:	2013-05-29 13_19_50-Does anybody get Teensy 3 working with NRF24L01+_ - Reply to Topic.jpg 
Views:	1812 
Size:	117.4 KB 
ID:	517

    Is it possible for you to test this lib with your teensy and tell me what you get in the printDetails ? i added in the helloworld_rx / tx a small code, since it's not possible to see the Serial.print from the setup with the Teensy. You just have to send "d" from the Serial Monitor and it will print the details.

    Thanks

    Ben

  16. #16
    Hi Ben,

    I am using this nrf24l01 chip:

    http://imall.iteadstudio.com/wireless/im120606002.html

    And the connecting to my teensy3 is as follows:

    Teensy3 -> nrf24l01
    Gnd 1. GND
    VCC 2. VCC
    Pin 9 3. CE
    Pin 10 4. CSN
    Pin 13 5. SCK
    Pin 11 6. MOSI
    Pin 12 7. MISO
    no connected 8. IRQ


    Here are my codes for the receiver:


    #include <RF24Network.h>
    #include <RF24.h>
    #include <SPI.h>
    #include "printf.h"

    // nRF24L01(+) radio attached using Getting Started board
    RF24 radio(9,10);

    // Network uses that radio
    RF24Network network(radio);

    // Address of our node
    const uint16_t this_node = 0;

    // Address of the other node
    uint16_t other_node = 1;

    byte inByte;

    // Structure of our payload
    struct payload_t
    {
    uint16_t nodeID;
    boolean mode;
    };

    void setup(void)
    {
    Serial.begin(115200);
    // printf_begin();
    //Serial.println("RF24Network/examples/helloworld_rx/");

    SPI.begin();
    radio.begin();
    network.begin(/*channel*/ 90, /*node address*/ this_node);
    }

    void loop(void)
    {
    // Pump the network regularly
    network.update();

    if (Serial.available())
    {
    inByte = Serial.read();

    payload_t payload = { inByte, 1 };

    RF24NetworkHeader header(/*to node*/ other_node);

    bool ok = network.write(header,&payload,sizeof(payload));

    if (ok)
    Serial.println("ok.");
    else
    Serial.println("failed.");

    }
    // Is there anything ready for us?
    while ( network.available() )
    {
    // If so, grab it and print it out
    RF24NetworkHeader header;
    payload_t payload;
    network.read(header,&payload,sizeof(payload));
    Serial.print("Received from ");
    Serial.print(payload.nodeID);
    Serial.print(" Mode: ");
    Serial.println(payload.mode);

    }
    }

  17. #17
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Mat and Kian, you are the best !
    Indeed, i had a wiring problem ! and maybe a software problem too...
    So now i got the Teensy printing the good model number and communicating ! well, almost

    I still have a problem but it seems to be from the Redboard.

    I made some tests and each one is getting me to the same result : All the tests are with the sketch you posted above, which seems to work both for the sender and receiver - just swapping the this_node and other_node variables -, right ?
    Redboard -> Fio : Fio receives the messages, but Redboard marks "failed" (i guess Fio didn't sent the acknowledgment)
    Fio -> Redboard : Redboard doesn't receive and Fio marks "failed"
    Redboard -> Teensy : Teensy receives the messages, but Redboard marks "failed" (same as Fio)
    Teensy -> Redboard : Redboard doesn't receive and Teensy marks "failed"

    I did these tests twice, so i could switch the rf24 modules from the boards. Same result no matter which module is connected to which board.

    But there is hope

    To finish, some questions :
    - Currently, the two module are very close to each other, since i'm working on my laptop with both boards connected so there is less than one meter between the modules. Is it potentially a problem ?
    - Some times, when the setup is working and i can send data from the Redboard to the Teensy, some packets are not received. Sometimes it's one among many, but sometimes the fail rate is really high (like half packets are not received). Is there something to get better results ?
    - When a packet is received, the Teensy logs multiple lines for the same message : with your sketch, when i press one letter and send it to the Redboard serial, the Teensy shows that :
    Received from 122 Mode: 1
    Received from 122 Mode: 1
    Received from 122 Mode: 1
    Received from 122 Mode: 1
    Received from 122 Mode: 1

    The first time i tested your sketch, i received only one message, then 4 message in the row, then 5 (like above). Is it a behavior your had or still have ?


    Thanks for this amazing support, when this is all done i will be glad to show you my project and add you to the "thank you very much" part !

    Ben
    Last edited by benkuper; 05-30-2013 at 08:51 AM.

  18. #18
    Yes, you just need to swap the numbers in the variables "this_node" and "that_node".

    I don't think you should have a problem with the range of the modules. I have tested them and they work up to more than 10m.

    My results so far are pretty consistent and fairly reliable. I don't have the issue with receiving multiple messages. The failure rate in transmission is probably less than 5%. But I am using a nrf24l01+ with power amplifier and external antenna as the receiver. So it might have contributed to a better reception.

    My codes are exactly taken from the examples: RF24Network/examples/helloworld_tx with minor modifications. U should load in the example TX and RX codes and work from there.

  19. #19
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Hello there, making good progress with this !

    I've got more teensy 3.0 to play with, so i got my hands on it.

    I've got 2 Teensy 3.0 talking just fine on one direction, but never the other way, even when changing roles..
    I think it's got something to do with the RX and TX addresses. When the TX address is also the RX Address n0 of the second, the message is well sent and well received, but otherwise there seems to be a problem. (like when the TX address is the RX Address n1 of the receiving teensy).

    On the picture, the left window (port 8) is the teensy that receives well but can't send right, and on the right (port 22) is the teensy that send ok but doesn't receive anything.
    We can see that TX-ADDR of teensy-right = RX ADDR 0 of teensy-left --> works ! whereas TX-ADDR of teensy-left = RX ADDR 1 of teensy-right -> fail !


    Click image for larger version. 

Name:	teensy and rf24.png 
Views:	1137 
Size:	82.5 KB 
ID:	538

    I know that these addresses are set up with the "this_node" and "other_node" parameters, but how can i test them further and force them to a chosen, "fixed" value so i can digg further ?

    Thanks in advance,

    Ben
    Last edited by benkuper; 06-03-2013 at 02:20 PM.

  20. #20
    Senior Member
    Join Date
    Jan 2013
    Location
    San Francisco Bay Area
    Posts
    650
    This sounds cool for about $4/each.

    I wouldn't mind creating a bluetooth->RF relay base station, so that a tablet or phone could connect and then control something over a longer distance with RF.

    For bluetooth($8), ($8 for 2x RFN), and a couple of t3's you could be controlling/communicating with something quite far with your tablet's accelerometer, voice-command, etc.

  21. #21
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    I'm actually working on a full compatible version of maniacsbug RF24 library that works with arduino/due/Teensy3 with printf support (thanks to stevec for his solution). I hope to test it tomorrow so I can post in github.
    I think that RF24Network library has been developed for one server and many clients and apparently it's based on RF24 that it's more flexible. I've used mirf but looks like it missed some error check and it's less reliable.

  22. #22
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Fantastic sumotoy !
    Where are you with that ?

  23. #23
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    I will test with Teensy 3 tonight, already tested the Arduino side and works, hope to post a link later. I want to keep the full compatibility so I'm find a way to modify examples as less it's possible, but unfortunately actually some small change it's needed. I just added an option in the config file to disable completely, during compilation, any printf call so the final code will be much smaller and a new function that test chip without use any printf.
    Maniacsbug done excellent work for this chip but probably he's quite busy and it's not updated recently. I found many forks and loosed a lot of time to figure out timing issues since this chip come in 3 different variations and there's an unknown quantity of compatible ones.
    I buy 5 of this cards (+ variation) for less than 1 dollar each just 1 week ago...

  24. #24
    Junior Member
    Join Date
    May 2013
    Posts
    9
    Very cool,
    i' looking forward to test it !

  25. #25
    Junior Member VoltVisionFrenchy's Avatar
    Join Date
    Feb 2013
    Location
    Warren, PA
    Posts
    13
    [bump]

    Hello! Is anyone still interested in these NRF24L01+ modules with the Teensy3? The pricing of these is very, very intriguing and people seem to love them from a technical standpoint because of their ease of use and special features. The most interesting (and recently updated) software I have seen for the Teensy is here, but he doesn't say if its for the Teensy2 or Teensy3 (maybe it doesnt matter?)

    Paul, what is your recommendation for a low-cost zigbee-esque, xbee replacement type solution?
    Thanks!
    frenchy

Posting Permissions

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