nRF24L01

nRF24L01

This page is to Setup and Config nRF24L01

Hardware and Software

Hardware

nRF24L01

Software

Arduino IDE

Notes

    • Connect Arduino nano

    • CE and CSN can change to any PIN

    • Library Download

    • http://www.airspayce.com/mikem/arduino/RadioHead/index.html

    • https://github.com/TMRh20/RF24

Examples

This example is .Receive

Examples

This example is Send

            1. #include <SPI.h>

            2. #include "nRF24L01.h"

            3. #include "RF24.h"

            4. RF24 radio(7, 8);

            5. const byte rxAddr[6] = "00001";

            6. void setup()

            7. {

            8. while (!Serial);

            9. Serial.begin(9600);

            10. radio.begin();

            11. radio.openReadingPipe(0, rxAddr);

            12. radio.startListening();

            13. }

            14. void loop()

            15. {

            16. if (radio.available())

            17. {

            18. char text[32] = {0};

            19. radio.read(&text, sizeof(text));

            20. Serial.print("Received : ");

            21. Serial.println(text);

            22. } else {

            23. #include <SPI.h>

            24. //Serial.println("No Singal");

            25. //delay(500);

            26. #include "nRF24L01.h"

            27. }

            28. #include "RF24.h"

            29. }

            30. int msg[1];

            31. RF24 radio(7, 8);

            32. const byte rxAddr[6] = "00001";

            33. void setup()

            34. {

            35. Serial.begin(9600);

            36. Serial.println("Start....");

            37. radio.begin();

            38. radio.setRetries(15, 15);

            39. radio.openWritingPipe(rxAddr);

            40. radio.stopListening();

            41. }

            42. char text[] = "Hello Sanki I'm Here !!";

            43. int counter = 0;

            44. void loop()

            45. {

            46. if (counter <10) {

            47. text[0] = '0';

            48. text[1] = char(counter + 97);

            49. counter++;

            50. } else {

            51. counter = 0;

            52. }

            53. Serial.print("Sending.....");

            54. radio.write(&text, sizeof(text));

            55. Serial.print("OK : ");

            56. Serial.println(text[1]);

            57. delay(500);

            58. }