One of the more popular projects i build with kids is my Arduino Morse radio, so i started to wonder whether the nRF24L01 can also transmit sound. That’s how i found the excellent RF24Audio library. This library includes all basic functionality for a walkie talkie, so the sketch is extremely simple, included below.

img_20161111_113900069

I connected the nRF24L01 the usual way, on the SPI pins D11,D12,D13 and 2 extra: D7 and D8. The audio library works on top of the RF24 library, which i also updated to the optimised version from the same source. For maximum reach, i configured the userConfig.h file in the library folder, to the lowest speed RF24_250KBPS and a sample rate of 16kHz which should be fine for speech. I tried higher settings to transfer music, putting my phone’s headphone output on A0 but the quality was rather low; good enough to recognise the song but not pleasant to listen to (noise/distortion).

I include a basic wiring diagram below, showing the 2 LEDs and transmit button:

  • the LED on D6 goes on while a signal is received
  • the LED on the button (A1) goes on while sending
  • the MIC is an amplified electret microphone
  • the speaker is a cheap 8ohm 0.5W speaker

img_20161111_114029798

In this application the nRF24L01 seems to draw more power than usual, so i needed to add a large capacitor on the 3.3V line as decoupling capacitor; anything from 470uF upwards seems to work. (note: when i used an Arduino Nano for another nRF24 project it did not provide enough power at the 3.3V pin so i ended up using a separate 3.3V regulator; other solutions mentioned here).

With this simple setup, we get about 20 meters reach, or less with concrete walls in between. Enough to play with, but for a useful project you probably need an external antenna on the nRF24L01 and/or a better 3.3V supply.

The code is below (same sketch for both sides), including the printf.h file that you have to put inside the sketch’s folder, for the radio.printDetails() function to work (handy diagnostics).


/* Arduino UNO with nRF24L01 module
 * Tom Tobback Nov 2016 - BuffaloLabs
 * 
 * WALKIE TALKIE:
 * -press button on A1 to transmit, LED on, speak into the mic
 * -other LED goes on when receiving
 * 
 * Need large capacitor on 3.3V line
 * 
 * nRF24L01 connected to SPI D10,D11,D12 and D7,D8 
 * button connected on A1 is taken care of by library
 * LED on D6 (receiving) is taken care of by library
 * 
 * RF24 Audio Library TMRh20 2014
This sketch is intended to demonstrate the most basic functionality of the audio library.

Requirements:
2 Arduinos (Uno,Nano,Mega, etc supported)
2 NRF24LO1 Radio Modules
1 or more input devices (microphone, ipod, etc)
1 or more output devices (speaker, amplifier, etc)
1 or more external buttons or switches to control recording/volume/etc.

Setup:
1. Change the CE,CS pins below to match your chosen pins (I use 7,8 on 328 boards, and 48,49 on Mega boards)
2. Connect buttons as desired to the button pins listed below.
2. Upload this sketch to two or more devices
3. Use external buttons to control all devices

Default Pin Selections:
Speaker: pins 9,10 on UNO, Nano, pins 11,12 on Mega 2560
Input/Microphone: Analog pin A0 on all boards

Transmit button: Pin A1
VolumeUp button: Pin A2
VolumeDn button: Pin A3
Remote Transmission: Pin A4

Note: See http://arduino.cc/en/Tutorial/InputPullupSerial for info on how to wire the buttons to the pins
Note: Pin selections can be overridden by modifying the userConfig.h file included with the library
*/


#include <RF24.h>
#include <SPI.h>
#include <RF24Audio.h>
#include "printf.h" // General includes for radio and audio lib

RF24 radio(7,8); // Set radio up using pins 7 (CE) 8 (CS)
RF24Audio rfAudio(radio,1); // Set up the audio using the radio, and set to radio number 0.
 // Setting the radio number is only important if one-to-one communication is desired
 // in a multi-node radio group. See the privateBroadcast() function.

void setup() { 
 Serial.begin(115200); // Enable Arduino serial library
 
 printf_begin(); // Radio library uses printf to output debug info 
 radio.begin(); // Must start the radio here, only if we want to print debug info
 radio.printDetails(); // Print the info
 
 rfAudio.begin(); // Start up the radio and audio libararies

// rfAudio.transmit();
 rfAudio.receive();
 rfAudio.setVolume(7); // max vol
}

void loop() {
 
 // Audio playback and button handling is all managed internally.
 // In this example, the radio is controlled by external buttons, so there is nothing to do here
 
}

/* Documentation and References:

References:
All Library documentation: http://tmrh20.github.io/
New (2014) RF24 Audio Library: https://github.com/TMRh20/RF24Audio
Optimized (2014) RF24 Lib Source Code: https://github.com/TMRh20/RF24 
Optimized (2014) RF24 Network Lib: https://github.com/TMRh20/RF24Network

*/
 

And the printf.h file:

/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */
 
/**
 * @file printf.h
 *
 * Setup necessary to direct stdout to the Arduino Serial library, which
 * enables 'printf'
 */

#ifndef __PRINTF_H__
#define __PRINTF_H__

#ifdef ARDUINO

int serial_putc( char c, FILE * ) 
{
  Serial.write( c );

  return c;
} 

void printf_begin(void)
{
  fdevopen( &serial_putc, 0 );
}

#else
#error This example is only for use on Arduino.
#endif // ARDUINO

#endif // __PRINTF_H__
Arduino walkie talkie with nRF24L01

77 thoughts on “Arduino walkie talkie with nRF24L01

  • 16/11/2016 at 22:13
    Permalink

    first great project, i want to give it a try.
    but quick question do you upload the same sketch to both Arduinos?
    do you know if a pro-mini would also work?

    Reply
    • 18/11/2016 at 07:59
      Permalink

      Hi, yes same sketch goes on both Arduinos. i assume a ProMini will also work, it’s the same atmega328 chip.

      Reply
      • 15/08/2018 at 13:32
        Permalink

        can we connect 8 to 10 walkie talkie to gether for sqaud conversation ?
        plz rply

        Reply
        • 10/09/2018 at 08:50
          Permalink

          hi, yes if you don’t set the channel you will have broadcast so anybody can hear. however, as i mentioned in the post, the reach of these standard radio modules is quite poor for this application, about 10-20 meters or so, so you will probably have to improve that if you want it to be useful. i’m not sure what you can get with 2.4GHz, it would make more sense to use a lower frequency module.

          Reply
  • 06/01/2017 at 23:31
    Permalink

    is there any beep noise while talking with this walkie talkie ?
    i have it. a bad beep during talk into my walkie talkie.
    how can i fix it ?

    Reply
    • 07/01/2017 at 09:28
      Permalink

      i don’t remember any beeping sound; are you using an amplified electret microphone similar to mine?

      Reply
  • 14/01/2017 at 18:22
    Permalink

    imy girlfriend has tow arduino uno r3. are these good for this project ?
    i wanna make another walkie talkie for her.

    Reply
  • 14/01/2017 at 18:29
    Permalink

    Sorry. those arduinos are Mega. is it good for ?

    Reply
    • 16/01/2017 at 07:49
      Permalink

      Yes Mega will work too, just need to use other pins for the speaker as mentioned in the top section of the code: pin 11 and 12

      Reply
  • 15/01/2017 at 16:22
    Permalink

    Hi. what about pin number 8 on nRF24L01 ? where should be connect ?

    Reply
    • 16/01/2017 at 07:53
      Permalink

      pin 8 (IRQ) not used for this application

      Reply
  • 18/01/2017 at 00:12
    Permalink

    I have one leonardo and one uno. These are not working together. K
    I think because pins on leonardo are deferent. And i dont know witch one

    Reply
  • 19/04/2017 at 02:23
    Permalink

    Hi
    arduino IDE has an error.

    “””
    Arduino: 1.8.1 (Windows 10), Board: “Arduino/Genuino Uno”

    \\\\Arduino\libraries\RF24Audio-master\RF24Audio.cpp: In function ‘void __vector_11()’:

    \\\\Arduino\libraries\RF24Audio-master\RF24Audio.cpp:460:9: error: ‘class RF24’ has no member named ‘writeFast’

    radi.writeFast(&buffer[a],32);

    ^

    exit status 1
    Error compiling for board Arduino/Genuino Uno.
    “”””
    can you help me about that?

    Reply
    • 20/04/2017 at 11:32
      Permalink

      Hi Amir, i have just tried to compile the code again in IDE 1.8.2 and it works for me. Maybe you have not installed the RF24 library from the same source as the RF24Audio? There are a few different versions of RF24, you need the one from the same author.

      Reply
  • 28/09/2017 at 18:34
    Permalink

    hi to all
    I have a bad noise on speaker
    I work with nano arduino and lm386 amplifire
    I have a 3.7batteri li,polimer
    what I do for this problem??

    Reply
    • 02/10/2017 at 12:04
      Permalink

      have you tried connecting the speaker straight to the 2 Arduino pins as in the example? does this give you the same noise, or is the noise only there with the LM386? the sound output uses the 2 Arduino pins, have you connected them to pin2 and pin3 of the LM386?
      do you connect the LiPo 3.7V to the Nano’s 5V? i don’t think the 3V3 regulator on the Nano is LDO so that might not work well, the 3.7V input might be too low to get a stable 3.3V. better use a separate LDO voltage regulator to get a stable 3.3V and connect this to the Nano’s 5V and also power the nRF from this line (not from the Nano’s 3V3 pin).

      Reply
  • 25/10/2017 at 09:05
    Permalink

    Friend you did it with arduino one and in what version of arduino you did it

    Reply
  • 14/11/2017 at 14:08
    Permalink

    You did a nice project and i suggest you to replace your hand made sketch with a Fritzing diagram. You can find it here and its free http://fritzing.org/home/.

    Reply
    • 15/11/2017 at 09:40
      Permalink

      Hi Amit, i’m familiar with Fritzing and use it sometimes. however, i use this kind of sketches for my kids’ classes, printed on paper. Fritzing looks good on a screen, but is less ideal for printing, and i prefer the simple level of abstraction of my ‘maps’.

      Reply
  • 23/11/2017 at 22:42
    Permalink

    Can you communicate more than two Arduinos?

    Reply
    • 01/01/2018 at 16:37
      Permalink

      Hi Luis, if i recall correctly, i’m using the broadcast mode, not channel to channel, so the broadcast is received by all systems within reach.

      Reply
  • 23/12/2017 at 00:08
    Permalink

    hi, the communication is bidirectional?

    Reply
    • 01/01/2018 at 16:31
      Permalink

      yes both sides run same code and can send/receive

      Reply
  • Pingback:Walkie talkie Arduino - Сайт для радиолюбителей

  • 29/12/2017 at 14:24
    Permalink

    Hello,we did the same things what you wrote, the circuit works but after some time(10s-2 min) we need to reset the arduinos in order to rework it. Did it happen to you? What do you think?Why did it happen? Thank you.

    Reply
    • 01/01/2018 at 16:41
      Permalink

      Hi, Uchi, not sure why your Arduinos get stuck, my guess would be the power supply to the radio modules as mentioned in my post. so i’d suggest to use a proper 3.3V regulator to power the radio and see if that solves your issue. it may be interesting to add a diagnostic LED to the project to indicate the radio status, i’ll have a look at that.

      Reply
      • 03/01/2018 at 15:25
        Permalink

        I have added an LED on D3 for the status, and changed the loop to this:

        wdt_reset();
        delay(800);
        if (radio.getPALevel() < 3) { Serial.println("radio error"); digitalWrite(3, HIGH); } else { digitalWrite(3, LOW); } It seems the radio fails from time to time, but then i restores itself. I'm not sure it really fails, maybe just the status command fails. But it definitely fails if the wiring is not correct. I have also added a watchdog timer with wdt_enable(WDTO_1S); in the setup. It triggers occasionally, sometimes not for 10min. I added at the end of setup: radio.setPALevel(RF24_PA_MAX); // rfAudio.begin seems to put this to PA_MIN I tested the range with a proper 3.3V voltage regulator but that did not make a difference. So the only way to get a better range i think is using a module with external antenna.

        Reply
  • 27/01/2018 at 06:53
    Permalink

    I Rebuild this whole Circuit ans put it in 2 Boxes. Now im Facing the issue that Theres only Noise/distortion both LEDs react äß expected ans im also getting Sound when i blow at the mic just no Real speach

    Reply
    • 02/02/2018 at 07:47
      Permalink

      Hi Stan, are you using an amplified mic pcb as in my pictures? if your using a non-amplified mic, the signal is too weak. maybe your amplifier is too strong, in that case you could put a voltage divider on its output, or a pot (GND, A0, mic output).

      Reply
  • 11/03/2018 at 20:44
    Permalink

    Dear Tom!
    Thank you for your article.
    I would like to ask: how could it be modified to be “full-duplex”? So i mean to be two-way communication simultanously? So talking to each other WITHOUT need to press any button, just use it like a phone call?
    Thank you for your answer,
    Ati

    Reply
  • 15/04/2018 at 12:32
    Permalink

    Should i make the same connections and upload the same code to both the arduinos?
    Will it transmit and receive the sound?

    Reply
    • 08/05/2018 at 14:01
      Permalink

      yes same code on both arduinos. press the button while speaking to transmit

      Reply
  • 27/11/2018 at 08:47
    Permalink

    I am putting on a walkie talkie workshop at school. We will build this project. There will be several pairs of walkie talkies functioning at the same time. How do I address or set channels? I want each group to be able to have private communication without interference from the other group’s walkie talkies. I tried radio.setChannel(108); in the void setup() section. Loaded this code to both walkie talkies. This did not work for me. Any thoughts?

    thanks much

    Reply
  • 27/11/2018 at 22:20
    Permalink

    Re: Full Duplex – the simplest way is by imitation.

    If you use a paired MCU+radio module for each half of the ‘Plex (1 pair for Rx, 1 pair for Tx), you can effectively mirror an AVR equiv to the old Pye PF1 – but by having isolated radio and audio chains, and split-frequency operation, you could set up group ops easily.
    Have Rx listening for broadcast, Tx on a lower freq or reverse if preferred.

    Repeator Mode – Then, with a bit of thought and elaboration, you could use a central repeater and all operators on portable/mobile sets. I’ll leave you to research that, but it’s neither complex or hard (that said, I’ve been involved in radio comma for half my life, so my perception of easy is relative – compared to my youth days era tech means, super easy).

    Super Advanced – with some work, you could develop a proper packet transmission based digipeater based networked repeater op.

    But regardless of how you go – your two immediate elaborations should be using either higher ERP radio modules, preferably not using PCB etched antennas, or (using low ERP or higher ERP modules), use efficient antennas – remember that your onboard etched antennas are negative gain – you’re aiming for unity gain or positive gain on the antenna front. With a little effort, you could build coax co-linears for good positive gain and still be omnidirectional or helically wound collinear at reduced positive gain efficiency.

    Remember, particularly on the Rx side, stronger (within Rx tolerance) signals directly received via efficient means beats compensating for poor passive gain via Rx preamps.

    Note – if you dig deep, you can find digital telephony/voice configured modules for ISM or permit-free allocations that all you need add is the smart bit (I.e. MCU for control and data modes, driving displays etc).

    Reply
  • 01/01/2019 at 10:00
    Permalink

    Hi tom.
    I made the circuit. When i press the button i get some feedback on the other speaker. This means that my circuits are working. But it’s not transmitting and sound from microphone. I checked with two different microphone.

    Secondly after few seconds arduino stops working and i need to restart it.

    Reply
    • 15/01/2019 at 07:33
      Permalink

      hi, the microphone is an amplified electret mic; it won’t work without the amplifier as the output would be to low.
      if your system gets stuck, my guess is that the 3.3V power supply is not sufficient; are you using a large capacitor on 3V3/GND?
      also, there are a lot of fake nRF24L01 modules around of varying quality

      Reply
  • 23/03/2019 at 02:37
    Permalink

    Dear Tom,
    I would like to thank you for this article, I have a couple of questions I am thinking to do a similar project but instead of using nRF24L01 I am planning to use Arduino Ethernet Shield V1,
    so I want to record my voice in my Arduino and send it to another Arduino (in the same Room), then hear it
    do you think it’s possible to do it with the Ethernet Shield ?
    thx.

    Reply
  • 25/04/2019 at 21:13
    Permalink

    Which pins is the speaker connected to??

    Reply
    • 29/04/2019 at 10:31
      Permalink

      it says on the drawing and in the code, D9 and D10

      Reply
  • 05/05/2019 at 13:19
    Permalink

    Sir please can you give me all connections properly to connect present I’m working on this project I should complete this project soon so please can you give me connections with neat circuit diagram

    Reply
    • 14/05/2019 at 11:16
      Permalink

      hi, i think the wiring diagram representing the breadboard in the picture should be clear; i build this project with 7-8 year olds and they can figure it out. just make sure you have an amplified mic board.

      Reply
  • 08/07/2019 at 16:04
    Permalink

    I tried this code on ATMEGA238P(Arduino Uno) but its not working. same code uploaded on both boards.

    Reply
    • 16/08/2019 at 16:14
      Permalink

      if your arduino really says ATMEGA238P then i would not expect much to work

      Reply
  • 16/08/2019 at 15:50
    Permalink

    Hi Tom,
    I am able to get the two RF24L01s communicated with each other by using two UNO boards with exactly the same sketch and circuit from this web page. However, the noise (or interference I am not sure) generated by the module itself makes this pair of walkie talkie almost unusable even though they are only 5 feet apart. I tried to move all the components inside a confined space but the situation remained the same. Is there anything I can do to reduce that unwanted noise? Thanks a lot.
    Sam

    Reply
    • 16/08/2019 at 16:11
      Permalink

      hi, i regularly make this project with groups of kids i teach, and while it is definitely not useful as a real walkietalkie (quality, range), it does work well enough to illustrate voice over radio waves. a good indicator to see whether it works is pressing the send button on unit 1, then the receive LED should light up on unit 2. if that does not work, the radio(s) are not working. if that works, maybe the noise comes from the microphone; maybe its gain is too high. if you have access to an oscilloscope, have a look at the mic output to check if it is relatively clean. or maybe to test you can connect A0 to GND instead of the mic, to see if you still get the noise.

      Reply
      • 18/08/2019 at 15:57
        Permalink

        Hi Tom,
        Actually, the LED (instead of ON perminantly) blinked on unit 2 according to the audio level while the button on unit 1 was being pressed. I was pretty sure the transmission was working properly. In fact, I could still hear 10% of the voice from unit 1 amongst 90% of background noise. The same problem occured when unit 1 acted as an receiver.
        By grounding A0 on the transmitter side as you had suggested, there was a complete silence on the receiver side. I don’t have an oscilloscope and frankly speaking, I don’t understand how it works. Could you tell me what I should do next?
        Regards,
        Sam

        Reply
        • 19/08/2019 at 09:44
          Permalink

          what microphone unit are you using? i’m using one that has a built-in amplifier MAX9812, which gives a good output range for the Arduino’s analog pin. if you have a microphone without proper amplification you may get a lot of noise. my setup is a bit of a hack, because we’re not supposed to draw much current from the 3V3 pin, and we’re connecting the nRF24 pins to 5V GPIO. If you want a more stable system you probably need to use level shifters (3V3 – 5V) and a good power supply. have a look at this blog post of the library author, i think he’s using level shifters and 7.2V batteries http://tmrh20.blogspot.com/2014/03/arduino-radiointercomwireless-audio.html

          Reply
          • 19/08/2019 at 19:13
            Permalink

            Hi Tom,
            The microphones I used was exactly the same as yours with a VCC, GND and an OUT pin (connected to A0). Since I didn’t have any powerful wall transformers, all components drawed their powers from the arduino uno board (either 5V and 3.3V) respectively. I once replaced the 100uf capacitor with a 1500uf but there was not much improvement. Perhaps I have to source additional power supply before the next adjustment. Anyway, thank you very much for your continuous support.
            Sam

  • 21/08/2019 at 21:45
    Permalink

    Hi Tom,
    Thank you for your instruction. It is quite interesting to find someone making walkie talkie in that way. Nevertheless, those projects definitely require professional knowledge which is beyond my ability at this moment. Certainly, there is no harm reading more concerning RF technology. Meanwhile, I have made an order for a more powerful wall transformer from Amazon and hopefully it will work.
    Regards,
    Sam

    Reply
  • 30/11/2019 at 22:06
    Permalink

    Hi Tom,
    Excellent project. I am trying to do it at home. But, for now, I have two questions. The first one: Why is not necessary to program what the button does? The second one: I do not have a speaker, my idea is to use a 3.5mm jack to connect some headphones, would it work? Or should I change the code?. Thank you very much.

    Reply
    • 02/12/2019 at 08:11
      Permalink

      hi, the buttons are handled within the library code. yes headphones will also work, on the same pin.

      Reply
      • 02/12/2019 at 21:19
        Permalink

        My last question, why in the code the line that says “rfAudio.transmit()” is commented? Do i have to uncomment it in order to upload the code?

        Reply
  • 02/02/2020 at 20:42
    Permalink

    I am a ham radio operator and designed a wireless cw(morse code) key using arduino nanos. I’m running a 100% wireless radio setup but the latency(delay) of hearing the cw is about 250 ms. I’m looking at he RF24 library as a means of wireless headphones with low latency. Any idea what kind of latency I will encounter?
    Thanks

    Reply
    • 03/02/2020 at 11:20
      Permalink

      hi, i’m not familiar with ham. do you really need to transmit the CW (3kHz?) or would it be acceptable to transfer just one bit (on/off) and ‘decode’ it on the headphone receiver into a beep? i think that will give the best latency results (a few milliseconds? https://forum.arduino.cc/index.php?topic=570511.0) and will not add any hardware. for the RF24audio library, as far as i can see the buffSize is 32 bytes so i think the latency will be similar, but the audio quality might give you a headache.

      Reply
  • 18/03/2020 at 03:58
    Permalink

    Hey cool project… Did you understand all functionalities of the library when you did this project. Like you had any idea of what each commands in the library does?

    Reply
  • 07/04/2020 at 20:10
    Permalink

    you begin with this 115200 bits per second.
    Serial.begin(115200);
    My question is , if i reduce 115200 to 9600 is any thing happen in my audio or transmitting signal.

    Reply
    • 07/04/2020 at 20:31
      Permalink

      and please upload the schematic design or pcb design for this circuit

      Reply
    • 10/04/2020 at 16:33
      Permalink

      yes you can use 9600 baud, it only affects the speed of the Serial print over USB

      Reply
  • 18/04/2020 at 00:34
    Permalink

    Good morning friend, I made the connection as it appears but I cannot transmit the sound, it is only heard static, is it necessary to place the capacitor between gnd and VCC of the nfr24l01?

    Reply
    • 20/04/2020 at 09:06
      Permalink

      hi, yes the capacitor will improve stability (decoupling cap): the Arduino UNO’s 3.3V pin cannot deliver much current so the capacitor will help to smooth the peak current draw from the radio. without that cap, the radio does not work for me.

      Reply
      • 20/04/2020 at 20:33
        Permalink

        Hi.

        Thanks for the tip, I added the capacitor and changed one of the two arduino (it was failing) and managed to send and receive sound, but it is not of very good quality, any advice to improve the sound?

        Reply
      • 21/04/2020 at 03:28
        Permalink

        Hi.

        where the sentences are placed
        #define SAMPLE_RATE 16000
        #define RF_SPEED RF24_250KBPS

        Reply
        • 06/05/2020 at 20:05
          Permalink

          That’s in the userConfig file

          Reply
  • 06/05/2020 at 20:04
    Permalink

    Hi, somebody can explain me how can i transfer in privately?

    Hola, alguien puede explicarme cómo puedo transmitir en privado?

    Reply
    • 27/05/2020 at 10:14
      Permalink

      Hola Daniel, lograste hacer funcionar el proyecto, yo no lo logro aún

      Reply
      • 03/06/2020 at 01:37
        Permalink

        Sí Manuel, con dos Arduinos UNO

        Reply
        • 21/06/2020 at 22:28
          Permalink

          Que tal daniel, lograste, minimizar el sonido de fondo, es muy molesto, como un pitido

          Reply
          • 06/07/2020 at 18:54
            Permalink

            Hola Manuel, el pitido no conseguí eliminarlo pero cumplen su función.

Leave a Reply to Tom Cancel reply

Your email address will not be published. Required fields are marked *