Show Posts
Pages: 1 [2] 3 4 ... 7
16  Using Arduino / Audio / Re: Playing wav file from SD card on Ethernet shield on: August 02, 2014, 06:03:21 am
The audio library uses pins 9 and 10 for speaker output by default, so I think that may be what causes issues with the ethernet shield, but don't have one to test with.

The website says "Both W5200 and SD card communicate with Arduino via SPI bus. Pin 10 and pin 4 are chip select pins for W5200 and SD slot. They cannot be used as general I/O. " ... it may work by opening the included pcmConfig.h file with a text editor, and un-comment the line
- that should disable the audio output on pin10

17  Using Arduino / Networking, Protocols, and Devices / Re: RF24Network NODES on: August 02, 2014, 05:40:27 am
Here is a Topology/Nodes/routing example in RF24Network:

Some of the retry/timing details only apply to the new fork at the above link, but the topology and addressing is exactly the same.
18  Using Arduino / Networking, Protocols, and Devices / Re: Trying to learn basics of NRF24L01+ on: June 25, 2014, 10:54:25 pm
Well, it works ok for me, so we know the the code is fine, here is what I am using:


#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9,10);

const uint64_t pipe = 0xF0F0F0F0E1LL;

void setup(void) {

void loop () {
  unsigned int random_Number = random(0,255);
  Serial.print("Sending: ");
  boolean ok = radio.write( &random_Number, sizeof(random_Number) );
  if (ok) Serial.println("ok...");
  else Serial.println("failed.");


#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9,10);

const uint64_t pipe = 0xF0F0F0F0E1LL;

void setup(void) {

void loop () {
  if ( radio.available() ) {
    Serial.println("radio is available");
    unsigned int data;
    boolean done=false; &data, sizeof(data) );
      Serial.print("Received: ");

So, if you are using that code and it doesn't work, it usually indicates another problem.

To get debugging info, you need to do a few things:
1. Add the printf.h file from one of the examples to your sketch folder
2. Add the line   #include "printf.h" in your sketch
3. Do printf_begin();  right after Serial.begin(57600);
4. Finally, at the end of your setup() function, do a radio.printDetails();

It should look exactly like the attached picture on the receiver with the debug details printed.

Since you say it works fine with the getting started sketch, we know the wiring is ok, and the code works fine for me, so the code is fine, then something odd is usually to blame, but difficult to figure out from my end. Also, power cycle the Arduino, since some settings cannot be undone otherwise, and may interfere if you have been running other example sketches. Not sure what library fork you are using, but of course I am using my fork found here:
19  Using Arduino / Networking, Protocols, and Devices / Re: Trying to learn basics of NRF24L01+ on: June 23, 2014, 01:07:35 pm

1. Use the same pipe for both:  const uint64_t pipe = 0xF0F0F0F0D1LL;
2. Open a writing pipe on the receiver:


Info: The transmitter must transmit to the receiving address of the receiver for the payload to be delivered. In order for the receiver to acknowledge (ACK) transmission, it needs a writing pipe opened to send back the ACK packet.
20  Using Arduino / Networking, Protocols, and Devices / Re: RF24 library with nrf24l01+. Can you receive messages while transmitting? on: May 02, 2014, 02:32:15 pm

Well technically, that is the expected behaviour. The radio modules switch between two primary modes, being primary transmitter and primary receiver.

The radio will not receive any normal payloads while in TX mode, and will not send any normal payloads while in RX mode, however, the radios do support something called ACK payloads.

When a payload is successfully transmitted, the receiving radio responds back with an ACKnowledgement payload. Making use of the ack payload feature allows you to respond back with an ACK payload without havign to manually switch out of receiver mode, and the transmitter can be set to send until an appropriate response is received.

This makes for a much faster call-response scenario, and I believe would suit what you are doing much better than manually switching from TX to RX modes.

Take a look at this example:   It may not work very well with the original library though.

21  Using Arduino / Project Guidance / Re: Arduino & Video? on: April 30, 2014, 08:26:03 pm

I was looking at some of these for video overlay, but have never tried them:

It might be possible to do some overlay directly using just an Arduino, but something like the above would probably be the way to go.
22  Using Arduino / Programming Questions / Re: Need help programming servo movement to audio file from sd card on: April 29, 2014, 07:05:04 pm
I believe that the main problem with your code is that the servo library and the audio library both are trying to use TIMER1 at the same time, so you end up with a few options:

1. Do a  myservo.detach(); before playing audio and do a myservo.attach(servo1_pin); before trying to use the servo
2. Use the timer2 servo library (google it) or a custom servo solution
3. Attempt to use the timer2 option of the TMRpcm library (untested with servo lib) - see the wiki on github to enable
4. Use an audio shield to offload the audio processing from Arduino


23  Using Arduino / Programming Questions / Re: nRF24l01 Not receive data on: April 25, 2014, 09:44:45 pm
Ok, a couple of confusing things here. First, I didn't realize it was an array of integers, so that changes everything.

There are 2 bytes in every integer, so your array would actually be  68*2 bytes ( 136 bytes long), which will require 5 payloads just for the data in one array.

unsigned int Raw[] = {4600,4450,650,1600,650,1600,650,1600,650,500,600,500,650,500,650,500,600,500,650,1600,650,1600,650,1600,650,500,650,450,650,500,650,500,600,500,650,500,600,1650,600,500,650,500,600,500,650,500,600,500,650,500,650,1600,650,500,600,1650,600,1650,600,1650,650,1600,650,1600,650,1600,650};
unsigned int output[16]; // For the payload of nRF24L01 array 30 + 1 for null termination

void setup() {
  //for(int i=0; i< 68; i++){
  //  Raw[i] = i;

void loop() {
  memcpy(&output[1],&Raw,30);      // Copies 30 bytes or 15 integers
  output[0] = 1;                                         // Sets the first integer (2 bytes) to equal 1
  for(int i=0; i<16; i++){
    Serial.println(output[i]); // Print out the 15 integers + 1 start integer
  output[0] = 2;
  for(int i=0; i<16; i++){
  output[0] = 3;
  for(int i=0; i<16; i++){
  output[0] = 4;
  for(int i=0; i<16; i++){
  memcpy(&output[1],&Raw[60],14);   *Edit: Should be 14 not 16
  output[0] = 5;
  for(int i=0; i<8; i++){


The code I posted above shows how to insert the start integer, and ensure that every byte is accounted for. It will actually take 5 transmissions to send all of the data.

When sending, you would still do radio.write(&output,sizeof(output));

Also, your array is 67 integers or 134 bytes long.
24  Using Arduino / Programming Questions / Re: nRF24l01 Not receive data on: April 25, 2014, 03:52:13 pm
Well the pipes vs addressing thing is a bit confusing, so I like to look at it like this:

 const uint64_t addresses[2] = {   0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

Then, to answer your question, yes. As long as the transmitter and receiver are using opposite addresses, it should work fine. The pipe numbers aren't always that important, mainly the addresses.

And i thing you have make you're own rf24 library ... write ? i will do a better read  smiley
Yup, I've created a faster/more efficient fork of the RF24/RF24Network libs that support a wider range of hardware and functionality, mainly to improve my audio library and its capabilities.

if the above it is correct how can i collect the data in Rx side ?

The memcpy looks ok, except the second one should use length 32 instead of 64. In this case you will probably want to use some sort of simple protocol to manage the payloads and re-assembly.

For example, the transmitter could number the payloads by modifying the first or last byte of the payload, so the receiver knows if it has received all of the payloads in the correct sequence. Or you could send a 'start payload' telling the receiver to expect three payloads within a certain timeframe, and indicate that they will need to be re-assembled. I've included an example of the latter method in my library fork:  , but the write method needs to be changed to work with any of the other libs. *Edit to add: It might be easiest to also spread out the data being sent so all the payloads are the same size. Otherwise that needs to be accounted for on the receiving end.

Then on the receiving end, its just a matter of confirming successful transfer, then reversing the operation, and writing the payload data into a 68 byte array, which you could do by reversing your memcpy code, or with a for loop.

25  Using Arduino / Programming Questions / Re: nRF24l01 Not receive data on: April 25, 2014, 07:28:36 am

The code looks ok, but I've almost always had problems with the radio modules when trying to only use 1 pipe/address.

The example uses two as well:

  const uint64_t pipes[2] = {   0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };


 OR for the other radio:


That may work better if the modules test ok.
26  Using Arduino / Audio / Re: How can I create a wave file from an ADC INPUT? on: April 25, 2014, 05:57:56 am

It can be a bit of a complicated thing, since the audio needs to be sampled consistently, generally at a fairly high rate, and written to a file at the same time. I am not an expert in any way with programming on the Due, so can't help a whole lot there, but have worked a bit with wav files on smaller arduinos.

If you take a look at , there is a good visual and technical description of the header. You basically need to write a header, then just add the raw audio sample data after that. The Due can also do 12-bit audio sampling, but it might be easier to start with 8-bit samples, since it only requires one byte per sample.

From my experience, the biggest challenges are getting quality samples at the correct sample rates, and writing to SD card etc with enough speed and/or a big enough data buffer, but this should be much easier on the Due since it has more memory and a faster processor.

27  Using Arduino / Audio / Re: New Library: RF24Audio - Realtime Audio Streaming, Multicasting and More on: April 22, 2014, 02:02:55 pm
Well the answer is yes and no because again, it depends on what exactly you are doing.

I use two separate ISRs along with 'nested interrupts' to due to timing issues.

The TX_0 sketch found here may be easier to look at than the library code, and shows how this is done. This is the sketch I used to develop the libary initially.

All my library documentation can be found here:
My blog is here:
The datasheet is here:
Arduino Reference:

All the information you need is there. Not trying to be rude, but you really need to understand what is going on if you ever hope to write this type of code yourself, and the only way to do that is to put in the effort, and read the documentation and examples provided.
28  Using Arduino / Audio / Re: New Library: RF24Audio - Realtime Audio Streaming, Multicasting and More on: April 21, 2014, 09:56:12 pm

Which is the one last question?

29  Using Arduino / Audio / Re: New Library: RF24Audio - Realtime Audio Streaming, Multicasting and More on: April 21, 2014, 12:55:03 pm
- Where did you say to the arduino to work with port 9 an 10, besides defining them as output, where are you using them?
TCCR1A = _BV(COM1A1)  | _BV(COM1B0) | _BV(COM1B1);  //Enable the timer port/pins as output
OCR1A = OCR1B = ADCL | ADCH << 8;  // Read the ADC values directly into the timer compare register.

Why 2 ports instead of just 1 and GND?

To enable complimentary (push/pull) speaker output instead of push/null.

I just wanted the ADC values somewhere so i could work with them because i don't know where to get them, what should i do?

Either use analogRead() to get the ADC values, or learn how to work with the registers.

I would recommend checking out  and looking at the bitwise &, | and <<     >> (bitshift)  operators if you are not already familiar with them. That will help to understand how to work with binary data.

From there, read the datasheet if you really do want to learn. If you can understand the concepts of working with bits and bytes via the above operators, then its just a matter of writing/reading the correct values to/from the registers to work with or control any aspect of the MCU.

I can lead you to water, but I cannot force you to drink...
30  Using Arduino / Audio / Re: New Library: RF24Audio - Realtime Audio Streaming, Multicasting and More on: April 21, 2014, 12:25:56 am

You either read the ADC registers, or the TIMER1 compare registers. As I said, you're going to have to read the data sheet if you need more help with that code.

Its not as simple as just printing the values in the loop function, since timing is generally important. If I had some idea of what you were trying to do, I could provide an example, but I'm not going to write your code for you.
Pages: 1 [2] 3 4 ... 7