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__

33 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
  • 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

Leave a Reply

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