Code Monkey home page Code Monkey logo

rf24audio's Introduction

Arduino Wireless Audio/Data Library

This library allows streaming of data/audio from analog inputs via NRF24L01 radio modules See the documentation section for more info.

Only AVR devices are supported. For ESP32 and Arduino Due, see AutoAnalogAudio, a more versatile audio input/output library.

rf24audio's People

Contributors

2bndy5 avatar tmrh20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rf24audio's Issues

Disabling complimentary Mode

Hello, Is it possible to turn off the complimentary mode, instead of using 9 and 10, is it possibel to use 9 and Ground? Thank you!

Problems with NRF24L01 mini module

I'm working on a wireless walkie talkie with atmega328p 3.3V 8Mhz and I need the circuit board to be as small as possible so I designed my board to use the NRF24L01 mini module which is supposedly the same as the standard module but with smaller footprint size.
With the standard module everything worked fine at 1MBPS speed and 24000 sampling rate, but when I switched to the mini module I had to decrease the speed to 250kbps and sampling rate to make it work, also the range decreased a lot to only a few meters.
Is there any way to increase the transmit power by software ? Any hardware modifications for increasing the range ?
Regards.

measuring ellapsed time for transmission

Hello there,

I was currently reviewing the data sheet for the NRF24L01 + version, It has the enhanced shockburst format. Is this supported in this RF24 Audio code or is it only shockburst format? .. I need to know this because I'm trying to evaluate packet timing.

running @8MHz internal oscillator

Hi there and thanks in advance for your work.
Is it possible to run this library on 3,3V avr chips @8MHz internal oscillator?

I guess there's some counter that is clockwise for 16MHz, disabling operation for lowly clocked chips.

Thanks again

NRF24L01 Analog Output for Speaker

Hello there. I tried to read the output of a receiver and the signal looked digitized. Is there anyway to output it in analog form?

And yes I tested it with a normal speaker and it sounds fine but the signal I receive on the oscilloscope looked like a pwm signal

Data hum/buzz

Hi, Thanks for the library. There is a buzz in the recieved data. Any ideas why?

The received data in a quiet environment looks like this:
Screen Shot 2020-01-21 at 8 54 33 PM

If I read the mic directly with analogRead (no streaming) there's no hum.

SETUP

Transmitter: Similar to examples/GettingStarted.

/*
Transmitter
*/
#include <SPI.h>
#include <RF24.h>
#include <RF24Audio.h>


RF24 radio(7, 8);    // CE, CSN
RF24Audio rfAudio(radio,0);

void setup(){
    radio.begin();
    rfAudio.begin();
}

void loop(){
    rfAudio.transmit();
    delay(1000);
}

Receiver: Similar to examples/USB_Audio.

/*
Receiver
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


RF24 radio(7, 8);    // CE, CSN
const int PAYLOAD_SZ = 32;            // payload can be 1-32 bytes
const uint64_t addresses[2] = { 0xABCDABCD71LL, 0x544d52687CLL};

void setup(){
    while (!Serial);
        Serial.begin(115200);              // 9600, 14400, 19200, 28800, 31250, 38400, 57600, 115200
    radio.begin();
    radio.setChannel(1);
    radio.setAutoAck(0);
    radio.setCRCLength(RF24_CRC_8);       // Only use 8bit CRC for audio
    //radio.setDataRate(RF24_1MBPS);      // Library default is RF24_1MBPS for RF24 and RF24Audio
    radio.openWritingPipe(addresses[0]);  // Set up reading and writing pipes. 
    radio.openReadingPipe(1,addresses[1]);// All of the radios listen by default to the same multicast pipe  
    radio.printDetails();
    radio.startListening();               // Need to start the radio listening
}

byte data[PAYLOAD_SZ];
void loop(){
    if (radio.available()){
        radio.read(&data, PAYLOAD_SZ);
        for (int i=0; i<PAYLOAD_SZ; i++){
            Serial.println(data[i]);
        }
        Serial.println("");
    }
}

Devices

Thanks

Audio multi broadcast

Hi,

What I want to do is I would like to have 2 master nodes and one in each master node. There will be 5 more sub nodes.
Is it possible for each sub nodes to communicate across the master node?

Now I can only communicate with each other within the same group.

WM8731 codec ( audio codec shield ? )

Just wondered how hard it would be to add a codec support like the WM8731 to RF24Audio?
would be nice to have to have 24bit 48k audio streamed from one arduino Due / RF24Audio to
another arduino / RF24Audio?

I found this https://github.com/delsauce/ArduinoDueHiFi which I think supports the codecs I2S over I2C

might be a nice addon for people that want more than 8bit audio ?

Some documentation tweaks

Quick notes on Doxygen docs:
In the Constructor, the note might say "radioNum is only needed..."
broadcast seems kind of oddly named (turns OFF broadcasting except for 255)
Example for setVolume uses .volume()

Overall, really cool project!

[Question] what about streaming I2S data?

I've been looking into porting this library to my circuitpython-nrf24l01 library, and I noticed that many of the platforms that run on CircuitPython firmware natively support I2S protocol for digital audio via the builtin audiocore module.

So, is there any usefulness to adding an I2S version of the RF24Audio class? Perceptually, I'm imagining just transmitting the I2S data line and leave the WS (Word Select AKA Channel Select) line implied by requiring that RX & TX nRF24L01 nodes have a matching startup configuration (concerning total number of channels, sample rate, and 8-bit vs 16-bit).

See also the I2S specs and the Arduino I2S library

The RPi -- version 1B+ and later -- needs I2S activated, but it does have a dedicated I2S bus. However, CircuitPython's audiocore is not available on Linux SoCs (rightfully so). But I have a feeling this library always had limited compatibility with the RPi due to lack of ADC builtin (concerning real-time audio input) and only 2 hardware-driven PWM GPIO pins (concerning audio output).

Use without buttons

Hello,
I'd like to build an in-ear monitor system (I'm a musician) and I'd like to use this library to transmit audio over 2 NRF24L01 Arduino Nano. I'd only want a TX mode (I know I can achieve this) but I would also like a continuous stream (not pressing any button). Is there a way to achieve this (I also don't need the volume buttons)

Thank you

USB_Audio

Hello,

I know this may have been slightly covered in another thread, but I wanted to ask for assistance using the USB_Audio.ino connected through USB to a raspberry pi.
I am running a python script to attempt to capture the audio data and save to a wave file. Howver all I get is a bunch of garbled noise.

I have two mini pro's, and I have verified that they are communicating over the radio correctly.

In my python code , I am doing a serial read and I get data like this

I then use the python WAVE module to write those frames to a file

import serial, time
import pyaudio
import wave


import time
timeout = time.time() + 10   

FORMAT = pyaudio.paInt8
CHANNELS = 1
RATE = 24000

WAVE_OUTPUT_FILENAME = "file.wav"

audio = pyaudio.PyAudio()

ser = serial.Serial(port='/dev/ttyUSB0', baudrate=115200,
                        parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,
                        bytesize=serial.EIGHTBITS, timeout=0.5)
frames = []
while 1:
    print "recording..."
    serial_line = ser.read(1)
    if time.time() > timeout:
        break
    frames.append(serial_line)


waveFile = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
waveFile.setnchannels(CHANNELS)
waveFile.setsampwidth(audio.get_sample_size(FORMAT))
waveFile.setframerate(RATE)
waveFile.writeframes(b''.join(frames))
waveFile.close()
ser.close()

print(frames)


exit()

However when I play the wave file I get this
https://www.dropbox.com/s/tfeycxces815nyo/file.wav?dl=0

Any ideas or tips that may point me in the right direction?

CT Sensor to Arduino Uno

I am currently trying to interface my CT Sensor with my Arduino Uno, and it comes with an Audio Jack connector, so I purchased a little TRRS breakout module with Pins named: Sleeve, Ring2, Ring 1, and Tip.
I am wondering what pins on the Arduino I would connect these to, so I can read current from my CT Sensor.

IMG_20210818_203443
IMG_20210818_203457
IMG_20210818_203431

Audio Receiver/Radio Transmitter on Single RF Module

This is a questions about using RF24Audio and RF24 library in same Arduino sketch.
On node A, I want to transmit data (non-audio) to node B then receive audio data on node A from node B.
This is being attempted using one NRF24L01+ module on node A and one NRF24L01+ module on node B.
Is it possible to do both tasks on same RF module:

  1. Use RF24 library to transmit non-audio data to node B
  2. Use RF24Audio library to receive audio data from node A

Right now I'm trying to just test task 1 after calling rfAudio.begin(), but when I add a call to rfAudio.begin() in setup() task 1 no longer receives correct response from node B.

Node B shows it received the expected payload, but node A now always gets null response:
Sent 56924, Got response 0, Round-trip delay 14928 microseconds

Node A (Arduino) Code
RF24 radio(7,8);
RF24Audio rfAudio(radio,1);
const uint64_t addresses[2] = { 0xABCDABCD71LL, 0x544d52687CLL};

void setup() {
Serial.begin(115200);
printf_begin();
rfAudio.begin();
radio.begin();
radio.setPALevel(RF24_PA_MAX);
/* Set our radio options to the audio library defaults */
radio.setChannel(1);
radio.setAutoAck(0);
radio.setCRCLength(RF24_CRC_8);
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
radio.printDetails();
radio.startListening();

Serial.println("Setup OK. Begin transmission of audio");

radio.stopListening();

Serial.println(F("Now sending"));

unsigned long start_time = micros();
if (!radio.write( &start_time, sizeof(unsigned long) )) {
Serial.println(F("failed"));
}

radio.startListening(); // Now, continue listening

unsigned long started_waiting_at = micros();
boolean timeout = false;

while ( ! radio.available() ) { // While nothing is received
if (micros() - started_waiting_at > 200000 ) { // If waited longer than 200ms, indicate timeout and exit while loop
timeout = true;
break;
}
}
rfAudio.begin();
if ( timeout ) { // Describe the results
Serial.println(F("Failed, response timed out."));
} else {
unsigned long got_time;
radio.read( &got_time, sizeof(unsigned long) );
unsigned long end_time = micros();

Serial.print(F("Sent "));
Serial.print(start_time);
Serial.print(F(", Got response "));
Serial.print(got_time);
Serial.print(F(", Round-trip delay "));
Serial.print(end_time - start_time);
Serial.println(F(" microseconds"));
}
}

Node B (RPi) Code
I'm using gettingstarted.cpp example that came with RF24 with 2 changes:

// Radio pipe addresses for the 2 nodes to communicate.
//const uint8_t pipes[][6] = {"1Node","2Node"};
const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL};

main()
/* Set our radio options to the audio library defaults */
radio.setChannel(1);
radio.setAutoAck(0);
radio.setCRCLength(RF24_CRC_8);

Both libraries at the same time ? (nRF24 and RF24Audio)

Can I use this library using audio transmission (rfAudio.transmit(); and rfAudio.receive(); ) together with information transmission (radio.write(&State, sizeof(State)); and radio.read(&State, sizeof(State));) for example to activate a led ?

maybe trying some code like this?

#include <RF24.h>
#include <SPI.h>
#include <RF24Audio.h>
#include "printf.h"  
RF24 radio(7,8);   
RF24Audio rfAudio(radio,0); 
int talk= 3;
int optionR=4;
boolean Estado = 0;
void setup() {      
  Serial.begin(115200);
  printf_begin();
radio.begin();
  radio.printDetails();
  rfAudio.begin();
  pinMode(talk, INPUT);
  pinMode(optionR, INPUT);
  attachInterrupt(digitalPinToInterrupt(talk), Talk, CHANGE);
  rfAudio.receive();
}
void Talk()
{
  if (digitalRead(talk)){ 
  rfAudio.transmit();
  }
    else if (digitalRead(talk) && digitalRead(optionR) ){ 
        Estado = digitalRead(opcionR);
  radio.write(&State, sizeof(State));
  }
     else{
  rfAudio.receive();

  }
}

void loop()
{
  
}

Nice code, but one problem I can't handle

Hi @TMRh20

I have used your sketch (Minimal.ino) and my Arduino Walkie Talkie dream Come TURE! Thank you very much!
My problem is that, I have two Walkie Talkies' Transmit buttons( Pin A1) pushed, of course they are not working now, then I get there, sometimes that one of my Walkie Talkie come into 'silence mode', I try pushing the button and light the led on Arduino mini but the buzz not changes pitch, the other Walkie Talkie has no sound out. If I RESET the Arduino, its back to normal.
This question has perplexed me for a long time.
Thanks!

Customize Buttons

Why is it when I disable the button handing it (my term) kills all the pins. For example, I have an external LED connected to pins 2 & 3 that activates when I start transmitting. Pins 2 & 3 are not used by the Minimal example but when I disable button handling they no longer work. Seeing these pins are not used, it seems to me, they should not be effected but that is not the case. In fact it seems to affect all the pins.

Even if I try to reprogram the pins they still don't work.

Thanks
Ralph

Audio codec

Could you implement one of the lightweight codec in your program?
Like G.711. Here is good overview about it.

Programmable Volume Adjustment

I am having trouble setting the volume programmable. I tried editing the RF24Audio.h by changing the default setting from 4 to 7 (fAudio.volume(4)) but it didn't seem to make any difference. Can you tell me if I need to do something else. Thanks to all the help you have provided my project is working almost perfect but need to solve the volume problem.

Thanks
Ralph

deploy documentation using Github Pages

This issue is part of an effort to start hosting nRF24 org repos' docs on github per individual repo instead of uploading all RF24* lib's docs to tmrh20.github.io.

I've created a github workflow that builds the docs on every commit. This same workflow will upload the generated HTML files to the "gh-pages" branch upon publishing a new release. Notice I've already taken the liberty to create the "gh-pages" branch for this repo.

  1. For this workflow to work properly, this repo's settings needs to have the "gh-pages" branch set to the Github Pages Source option:
    image
    After enabling this option, I expect the first deployment to Github Pages to render an error message.

  2. Additionally, it would less visually noisy if the "packages" & "environments" sections are hidden in the repo's sidebar settings:
    image

When these stipulations have been met in the repo settings I will submit a PR

Best way to do TX and RX at the same time

I'm trying to do some research into this system for a walkie-talkie style system where people can talk over each other (for good reason).

I was thinking the simplest way to it would be to have a pair of nRFs in each transceiver module (there would be networking involved, but that would happen separately over serial i think). But now I'm wondering how many I can use before I run out of room.

The other method I though of would be to remain by default in a receiving state, and use audio-in (with a minimum threshold) as an interrupt (or just switching on the next packet). However that would mean switching to between rx and tx really quickly. Is that reasonable?

Can not play music, only noise.

Run \ examples \ RPi-linux \ audio, no problem, but pass a * .WAV sound file to Pi, replace houston24.wav, Arduino no play music only noise, why?

fix it (ADCSRB | ADTS bits)

in line 580, you commented that adc auto trigger is set on TIMER1 Capture interrupt flag.
it require ADTS[2:0] to set 1 but in the code you just set ADTS0 twice.
please tell if the code is ok and comment need to be updated. tnx

ADCSRB |= _BV(ADTS0) | _BV(ADTS0) | _BV(ADTS2); //Attach ADC start to TIMER1 Capture interrupt flag

Using "Gettingstarted" example but not working

Dear,
I have used your sketch (getting started.ino). Modified 1 to receiver and 1 to transmitter by replace all of code in loop() with rfAudio.transmit() (for transmitter) and rfAudio.receive() (for receiver). After upload code to arduino nano. It not work! So, what is wrong in my testing code.
Thanks!

PrivateChannels Not Working?

Hi,

I have uploaded the PrivateChannels sketch to 2 radios, first with radio = 0, and second with radio = 1. In this case radio 0 has the audio source to transmit.

However, it looks like radio 1 is always receiving the audio, no matter how I control radio 0 via serial (i.e. typing '2' for radio 2 private channel). Any configuration and it still receives the audio.

Any ideas?

Issue with Private Channels

So i have set up two communicating transceivers using broadcast. but when I set up another pair of transceivers there is so much interference :( !.. how to avoid this?

Hearing audio back on PC

Hello (posting in the right page),

I am working with windows PC and Intel edison.I want to just transfer audio to the PC using wireless nrf24 and via USB. How do I hear the audio on the PC or edison back. I understand that you have provided MRAA support but how do I hear live audio on the windows PC or Intel edison.I see that there is a file named USB audio. What does this file do?

multi receiver headphone

Hi Guys
could i ask, how many receiver could i use with one tx ?
i want to create a wireless headphone system with about 80 receiver headphone

is it possible ?

thank you

How is the sound quality of this.

I saw a video on youtube with a single speaker and it doesn't sound so well.

I'm thinking of building a set of receiver and transmitter to stream live audio like from a guitar to an amp.
Or use it as a monitor system for the singer to hear himself back from the mixtable.

Would this project be suitable for that?

Achieve longer range ?

Hi @TMRh20

I'm just wonder how far could we go with NRF24L01 for audio streaming with these configurations:

  • 16KHz sampling rate
  • 250Kbps data rate
  • 5dbi antenna
  • LOS view

Can we have this up to 600 meters

Regards.
IMAN.

Is IRQ pin used? Not getting sound

I don't want to post a generic "it's not working" question since I just got it all hooked up ;) I noticed in the wiring diagrams the IRQ pin is not connected to anything. Is this correct? I'm just getting a high pitched whine on my speaker and on my other board (Nano) the TX and RX lights are constantly lit.

how can output audio?

I use rfAudio.receive() to receive audio from another device
but I want know how can I set the output pin that let audio can output to speaker
is there any answer?

Regarding Fpwm Frequency for Arduino Nano using NRF24L01+

Hello there,

I have used the audio library on arduino nano for quite some time and it works very well. I'm doing this for my project and I'm wondering what is the default PWM frequency for audio sampling on the default output D9?. As well, how to change the PWM frequency or access it from the RF24Audio library?..

RF24Audio with TRRS Audio Jack for use with Headphones?

Hello, I was wondering how this diagram:
image
can be modified to instead have the TRRS 3.5mm Jack be utilized for audio output and input.

The jack has four pins: Sleeve, Ring2, Ring1 and Tip.
image
What would I change in the sample diagram to get it so that Audio is outputted to the connected headphones and the mic from those headphones are used as an input when transmitting?

Nothing is working for me. Please help!

I dont understand, I cant get anything to work. I have tried many different setups. Arduino UNO, Arduino Nano, Arduino Mega, all have the same result: silence...

Im using the GettingStarted sketch.

I know the Radios are hooked up good because I get real results on radio.printDetails():

SPI Speedz = 10 Mhz
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x544d52687c 0xabcdabcd71
RX_ADDR_P2-5 = 0x32 0xc4 0xc5 0xc6
TX_ADDR = 0x544d52687c
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
ARC = 0

Is there some trick to RF24Audio rfAudio(radio,0)?

Do I set one to 0 and one to 1? Ive tried every combo: Both on 0, Both on 1, one on 0, one on 1. Nothing...

I set one to "transmit" by sending an "r" on the serial monitor, and the other to "receive" by sending an "s" on the serial monitor, and just nothing happens. evrrything is dead. No LED activity, no sound, nothing...

Please help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.