{"id":10220,"date":"2015-08-31T16:23:57","date_gmt":"2015-08-31T16:23:57","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=10220"},"modified":"2019-04-02T10:23:34","modified_gmt":"2019-04-02T10:23:34","slug":"nrf24l01-2-4ghz-rf-transceiver-module-with-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/nrf24l01-2-4ghz-rf-transceiver-module-with-arduino\/","title":{"rendered":"Complete Guide for nRF24L01 &#8211; 2.4GHz RF Transceiver Module With Arduino"},"content":{"rendered":"<p>This post aims to be a complete guide for nRF24L01 &#8211; 2.4GHz RF Transceiver module. I\u2019ll explain what it does, show its specs\u00a0and share an Arduino project example that you can take and apply to your own projects.<!--more--><\/p>\n<p><a href=\"http:\/\/ebay.to\/1LF6DPk\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-11048\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf-where-to-buy.jpg?resize=351%2C254&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"nrf where to buy\" width=\"351\" height=\"254\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf-where-to-buy.jpg?w=550&amp;quality=100&amp;strip=all&amp;ssl=1 550w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf-where-to-buy.jpg?resize=300%2C217&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/a><\/p>\n<p>I have more\u00a0complete guides for other popular sensors, check them below:<\/p>\n<ul>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/complete-guide-for-ultrasonic-sensor-hc-sr04\/\">Complete Guide for Ultrasonic Sensor HC-SR04<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino\/\">Complete Guide for DHT11\/DHT22 Humidity and Temperature Sensor<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/rf-433mhz-transmitter-receiver-module-with-arduino\/\">Complete Guide for RF 433MHz Transmitter\/Receiver Module<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/arduino-with-pir-motion-sensor\/\">Arduino with PIR Motion Sensor<\/a><\/li>\n<\/ul>\n<h3>Description<\/h3>\n<p>These RF\u00a0modules are very\u00a0popular among the Arduino tinkerers. The nRF24L01 is used on a wide variety of applications that require wireless control. They are\u00a0transceivers which this means that each module can transmit and receive data.<\/p>\n<p>These modules are very cheap and you can use them with\u00a0any microcontroller (MCU).<\/p>\n<p><strong>Specifications nRF24L01 &#8211; 2.4GHz RF Transceiver<\/strong><\/p>\n<ul>\n<li>Low cost single-chip 2.4GHz GFSK RF transceiver IC<\/li>\n<li>Range with Antenna:\u00a0250Kb rate (Open area) &gt;1000 meter<\/li>\n<li>Power: Ultra low power consumption<\/li>\n<li>Input Voltage: 3.3V<\/li>\n<li>Pins: 5V tolerant<\/li>\n<li>Price: $2<\/li>\n<\/ul>\n<h3>Where to buy?<\/h3>\n<p>You can purchase these modules for just a few dollars.\u00a0<a href=\"https:\/\/makeradvisor.com\/tools\/nrf24l01-2-4ghz-rf\/\" target=\"_blank\" rel=\"noopener noreferrer\">Click here\u00a0to compare the\u00a0nRF24L01 module<\/a>\u00a0on several stores and find the best price. They come in two versions with external antenna (more range) or built-in antenna (less range).<\/p>\n<div class=\"code-block code-block-2\"><p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p><\/div>\n<h3>Arduino with nRF24L01<\/h3>\n<p>You need the following components to make this example:<\/p>\n<ul>\n<li>2x Arduino (<a href=\"http:\/\/ebay.to\/1EJbhZE\" target=\"_blank\" rel=\"noopener noreferrer\">eBay<\/a>)<\/li>\n<li>2x nRF24L01 &#8211; 2.4GHz RF Transceiver (<a href=\"http:\/\/ebay.to\/1LF6DPk\" target=\"_blank\" rel=\"noopener noreferrer\">eBay<\/a>)<\/li>\n<li>Breadboard\u00a0(<a href=\"http:\/\/ebay.to\/1I2mPti\" target=\"_blank\" rel=\"noopener noreferrer\">eBay<\/a>)<\/li>\n<\/ul>\n<h3>Library download<\/h3>\n<p>Here\u2019s the library\u00a0you need for this project:<\/p>\n<ol>\n<li>Download the <strong><a href=\"http:\/\/www.airspayce.com\/mikem\/arduino\/RadioHead\/RadioHead-1.46.zip\" target=\"_blank\" rel=\"noopener noreferrer\">RadioHead\u00a0library<\/a><\/strong><\/li>\n<li>Unzip the RadioHead\u00a0library<\/li>\n<li>Install the RadioHead\u00a0library in your Arduino IDE<\/li>\n<li>Restart your Arduino IDE<\/li>\n<\/ol>\n<p>The RadioHead library is great and it works with almost all RF modules in the market. You can read more about this project <a href=\"http:\/\/www.airspayce.com\/mikem\/arduino\/RadioHead\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h2>Pinout<\/h2>\n<figure id=\"attachment_11052\" aria-describedby=\"caption-attachment-11052\" style=\"width: 618px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"wp-image-11052\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/24L01Pinout-800.jpg?resize=628%2C288&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"24L01Pinout-800\" width=\"628\" height=\"288\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/24L01Pinout-800.jpg?w=800&amp;quality=100&amp;strip=all&amp;ssl=1 800w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/24L01Pinout-800.jpg?resize=300%2C138&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><figcaption id=\"caption-attachment-11052\" class=\"wp-caption-text\">Top view of NRF24L01<\/figcaption><\/figure>\n<h3>Client\u00a0Circuit<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-11050\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=654%2C456&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"nrf24 radiohead with Arduino\" width=\"654\" height=\"456\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?w=1212&amp;quality=100&amp;strip=all&amp;ssl=1 1212w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=300%2C209&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=1024%2C715&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a><span style=\"color: #ff0000;\">Important:<\/span>\u00a0Input voltage\u00a0is of 1.9V~3.6V, do not exceed this voltage, otherwise it will fry your\u00a0module.<\/p>\n<p>Follow the circuit above for your client. Then upload the code below which can be found in your Arduino IDE (after installing\u00a0the RadioHead library).<\/p>\n<p>Go to File &gt; Examples &gt; RadioHead &gt; nrf24 &gt; nrf24_client.<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/\/ nrf24_client\n\n#include &lt;SPI.h&gt;\n#include &lt;RH_NRF24.h&gt;\n\n\/\/ Singleton instance of the radio driver\nRH_NRF24 nrf24;\n\/\/ RH_NRF24 nrf24(8, 7); \/\/ use this to be electrically compatible with Mirf\n\/\/ RH_NRF24 nrf24(8, 10);\/\/ For Leonardo, need explicit SS pin\n\/\/ RH_NRF24 nrf24(8, 7); \/\/ For RFM73 on Anarduino Mini\n\nvoid setup() \n{\n  Serial.begin(9600);\n  while (!Serial) \n    ; \/\/ wait for serial port to connect. Needed for Leonardo only\n  if (!nrf24.init())\n    Serial.println(&quot;init failed&quot;);\n  \/\/ Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm\n  if (!nrf24.setChannel(1))\n    Serial.println(&quot;setChannel failed&quot;);\n  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))\n    Serial.println(&quot;setRF failed&quot;);    \n}\n\n\nvoid loop()\n{\n  Serial.println(&quot;Sending to nrf24_server&quot;);\n  \/\/ Send a message to nrf24_server\n  uint8_t data[] = &quot;Hello World!&quot;;\n  nrf24.send(data, sizeof(data));\n  \n  nrf24.waitPacketSent();\n  \/\/ Now wait for a reply\n  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];\n  uint8_t len = sizeof(buf);\n\n  if (nrf24.waitAvailableTimeout(500))\n  { \n    \/\/ Should be a reply message for us now   \n    if (nrf24.recv(buf, &amp;len))\n    {\n      Serial.print(&quot;got reply: &quot;);\n      Serial.println((char*)buf);\n    }\n    else\n    {\n      Serial.println(&quot;recv failed&quot;);\n    }\n  }\n  else\n  {\n    Serial.println(&quot;No reply, is nrf24_server running?&quot;);\n  }\n  delay(400);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/nrf24_client.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<h3>Server\u00a0Circuit<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-11050\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=653%2C456&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"nrf24 radiohead with Arduino\" width=\"653\" height=\"456\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?w=1212&amp;quality=100&amp;strip=all&amp;ssl=1 1212w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=300%2C209&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?resize=1024%2C715&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/><\/a> <span style=\"color: #ff0000;\">Important:<\/span>\u00a0Input voltage\u00a0is of 1.9V~3.6V, do not exceed this voltage, otherwise it will fry your\u00a0module.<\/p>\n<p>Follow the circuit above for your server. Then upload the code below which can be found in your Arduino IDE (after installing\u00a0the RadioHead library).<\/p>\n<p>Go to File &gt; Examples &gt; RadioHead &gt; nrf24 &gt; nrf24_server.<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/\/ nrf24_server\n\n#include &lt;SPI.h&gt;\n#include &lt;RH_NRF24.h&gt;\n\n\/\/ Singleton instance of the radio driver\nRH_NRF24 nrf24;\n\/\/ RH_NRF24 nrf24(8, 7); \/\/ use this to be electrically compatible with Mirf\n\/\/ RH_NRF24 nrf24(8, 10);\/\/ For Leonardo, need explicit SS pin\n\/\/ RH_NRF24 nrf24(8, 7); \/\/ For RFM73 on Anarduino Mini\n\nvoid setup() \n{\n  Serial.begin(9600);\n  while (!Serial) \n    ; \/\/ wait for serial port to connect. Needed for Leonardo only\n  if (!nrf24.init())\n    Serial.println(&quot;init failed&quot;);\n  \/\/ Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm\n  if (!nrf24.setChannel(1))\n    Serial.println(&quot;setChannel failed&quot;);\n  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))\n    Serial.println(&quot;setRF failed&quot;);    \n}\n\nvoid loop()\n{\n  if (nrf24.available())\n  {\n    \/\/ Should be a message for us now   \n    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];\n    uint8_t len = sizeof(buf);\n    if (nrf24.recv(buf, &amp;len))\n    {\n\/\/      NRF24::printBuffer(&quot;request: &quot;, buf, len);\n      Serial.print(&quot;got request: &quot;);\n      Serial.println((char*)buf);\n      \n      \/\/ Send a reply\n      uint8_t data[] = &quot;And hello back to you&quot;;\n      nrf24.send(data, sizeof(data));\n      nrf24.waitPacketSent();\n      Serial.println(&quot;Sent a reply&quot;);\n    }\n    else\n    {\n      Serial.println(&quot;recv failed&quot;);\n    }\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/nrf24_server.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<h3>Demonstration<\/h3>\n<p>In this project the client\u00a0is sending a message &#8220;Hello World!&#8221; to the server\u00a0via RF and the server is sending back the following message &#8220;And hello back to you&#8221;. Those messages\u00a0are being displayed in the\u00a0serial monitor.\u00a0Here\u2019s what you should see in your\u00a0serial terminal windows (see Figure below).<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11051\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/serial-communication.png?resize=740%2C411&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"serial communication\" width=\"740\" height=\"411\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/serial-communication.png?w=740&amp;quality=100&amp;strip=all&amp;ssl=1 740w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/serial-communication.png?resize=300%2C167&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/p>\n<p>Note: On the left window, I&#8217;m establishing a serial communication with PuTTY.org. On the right window, I&#8217;m using the Arduino IDE Serial Monitor.<\/p>\n<h3>Conclusion<\/h3>\n<p>You need to have some realistic expectations when using this module. They work very well when the receiver and transmitter are quite\u00a0close to each other. If you separate them too far you&#8217;ll loose the communication.<\/p>\n<p>The communication range will vary. It depends on how much noise in your environment, if there&#8217;s any obstacles and if you&#8217;re using an external antenna.<\/p>\n<p>I hope you found this guide useful.<\/p>\n<p><strong>Share this post<\/strong> with a friend that also likes electronics!<\/p>\n<p>You can contact me by leaving a comment. If you like this post probably you might like my next ones, so please support me by <a href=\"https:\/\/randomnerdtutorials.com\/download\">subscribing my blog<\/a> and my Facebook Page.<\/p>\n<p>Thanks for reading,<\/p>\n<p>-Rui Santos<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post aims to be a complete guide for nRF24L01 &#8211; 2.4GHz RF Transceiver module. I\u2019ll explain what it does, show its specs\u00a0and share an Arduino project example that you &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Complete Guide for nRF24L01 &#8211; 2.4GHz RF Transceiver Module With Arduino\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/nrf24l01-2-4ghz-rf-transceiver-module-with-arduino\/#more-10220\" aria-label=\"Read more about Complete Guide for nRF24L01 &#8211; 2.4GHz RF Transceiver Module With Arduino\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":11050,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,302,269,230,223,264,10],"tags":[],"class_list":["post-10220","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-0-guide","category-guide-project","category-guide","category-modules","category-project","category-a-tutorials"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/08\/nrf24-radiohead-with-Arduino.png?fit=1212%2C846&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/10220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=10220"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/10220\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/11050"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=10220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=10220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=10220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}