nRF24 / RF24Audio

Arduino library for streaming data/audio from analog inputs via NRF24L01 modules
http://nrf24.github.io/RF24Audio
262 stars 88 forks source link

Data hum/buzz #26

Closed andraugust closed 2 years ago

andraugust commented 4 years ago

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

TMRh20 commented 4 years ago

Based on my experience I assume the humming sound comes from electronic interference.

Whether it has to do with the internal timers, SPI etc, I’m not sure, but it is usually reduced by using batteries instead of USB power.

On Jan 21, 2020, at 22:59, Andrew August notifications@github.com wrote:

 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:

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

SETUP

Transmitter: Similar to examples/GettingStarted.

/ Transmitter /

include

include

include

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

include

include

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

Transmitter and receiver Transmitter is a nano and receiver is uno, both powered by usb. Mic: Electret Microphone Amplifier - MAX9814 with Auto Gain Control. Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

dennisdebel commented 4 years ago

I tried everything. And solved it using 470uF cap on power rails of the rf module, 1000uF on the power rails of my arduino (nano) and change the sample rate to 20khz and datarate to 240kbps. Now even usb power via computer is fine. Good luck (had the exact same noise fingerprint the OP shows, also with proper psu)