Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Audio / Re: New Library: RF24Audio - Realtime Audio Streaming, Multicasting and More on: August 25, 2014, 07:20:32 pm
Well, not really. It may be possible to do so, but would probably be a bit difficult at high bitrates.
2  Using Arduino / Networking, Protocols, and Devices / Re: a simple example of how to TX and RX char array maniacbug RF24 NRF24L01+ modules on: August 24, 2014, 12:22:36 am
The addressing assignments were initially incorrect. Both posts have been updated.
3  Using Arduino / Networking, Protocols, and Devices / Re: a simple example of how to TX and RX char array maniacbug RF24 NRF24L01+ modules on: August 18, 2014, 09:06:02 pm
Hey, thanks! In my initial post, I made a mistake in the code, but basically the addresses should be opposite, so one device transmits to the others reading address and vice versa:

Code:
 if(sender == 0){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
    radio.startListening();
  }else{
    radio.openWritingPipe(addresses[0]);    //*Edit to correct address assignments
    radio.openReadingPipe(1,addresses[1]);
    radio.stopListening();
  }


I think that should solve the issue, sorry about the mistake  smiley-confuse
4  Using Arduino / Networking, Protocols, and Devices / Re: [nrf24l01+] one base station broadcast to multiple receiver and wait for reply on: August 16, 2014, 10:13:16 am

It looks like there are 3 things keeping it from working properly. One of them is a bug that I've been noticing, and this post helped me to identify it fully:

1. There is (was) a problem with the libraries that would only really cause issues when using multicast writes, with two or more nodes, when pipe0 was not assigned a reading address - This has just been fixed in my fork, see https://github.com/TMRh20/RF24/archive/master.zip
2. You need to enableDynamicAck(); per the code below, or disable auto-ack altogether when using multicast.
3. The while(available()) is not needed, and can throw things off a bit

Re-installing the library from the above link and using the minor changes in the code below should fix the issue.

Code:
/*
 Copyright (C) 2011 James Coliz, Jr. <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.
 */

/**
 * Example RF Radio Ping Pair
 *
 * This is an example of how to use the RF24 class.  Write this sketch to two different nodes,
 * connect the role_pin to ground on one.  The ping node sends the current time to the pong node,
 * which responds by sending the value back.  The ping node can then see how long the whole cycle
 * took.
 */

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

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 8 & 9

RF24 radio(9,10);

// sets the role of this unit in hardware.  Connect to GND to be the 'pong' receiver
// Leave open to be the 'ping' transmitter
const int role_pin = 7;

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xABCDABCDE1LL, 0xABCDABCDD2LL };

//
// Role management
//
// Set up role.  This sketch uses the same software for all the nodes
// in this system.  Doing so greatly simplifies testing.  The hardware itself specifies
// which node it is.
//
// This is done through the role_pin
//

// The various roles supported by this sketch
typedef enum { role_ping_out = 1, role_pong_back } role_e;

// The debug-friendly names of those roles
const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};

// The role of the current running sketch
role_e role;

void setup(void)
{
  //
  // Role
  //

  // set up the role pin
  pinMode(role_pin, INPUT);
  digitalWrite(role_pin,HIGH);
  delay(20); // Just to get a solid reading on the role pin

  // read the address pin, establish our role
  if ( ! digitalRead(role_pin) )
    role = role_ping_out;
  else
    role = role_pong_back;

  //
  // Print preamble
  //

  Serial.begin(57600);
  printf_begin();
  printf("\n\rRF24/examples/pingpair/\n\r");
  printf("ROLE: %s\n\r",role_friendly_name[role]);

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  // radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
  // radio.setPayloadSize(8);

  //
  // Open pipes to other nodes for communication
  //

  // This simple sketch opens two pipes for these two nodes to communicate
  // back and forth.
  // Open 'our' pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

  if ( role == role_ping_out )
  {
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
  }
  else
  {
    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1,pipes[0]);
  }

  //
  // Start listening
  //
  // if( radio.setDataRate( RF24_250KBPS ) ) {
  //   printf( "Data rate 250KBPS set!\n\r" ) ;
  // } else {
  //   printf( "Data rate 250KBPS set FAILED!!\n\r" ) ;
  // }
  // radio.setDataRate( RF24_2MBPS ) ;
  // radio.setPALevel( RF24_PA_MAX ) ;
  radio.enableDynamicPayloads() ;
  radio.enableDynamicAck();
  //radio.setAutoAck( false ) ;
  //radio.powerUp() ;
  radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

  radio.printDetails();
}

char sendBuffer[33];
uint8_t counter = 1;

void loop(void)
{
  //
  // Ping out role.  Repeatedly send the current time
  //

  if (role == role_ping_out)
  {
   
    // send it.  This will block until complete
    sprintf(sendBuffer, "%d|root", counter);
   
    // First, stop listening so we can talk.
    radio.stopListening();

    printf("Now sending %s...", sendBuffer);
    bool ok = radio.write( sendBuffer, strlen(sendBuffer), true );

    if (ok) printf("ok...\r\n");
    else printf("no ack, failed...\r\n");
   
    counter++;
   
    // wait for reply
    radio.startListening();
   
    unsigned long time_started_waiting = millis();
    uint8_t pipe_num;
    bool timeout = false;
    while( !timeout ) {
     
      if (radio.available(&pipe_num)) {
       
        uint8_t len = radio.getDynamicPayloadSize();
        char backPayload[33];
       
        radio.read( backPayload, len );
        backPayload[len] = 0;
       
        printf("Got reply \"%s\" from pipe \"%d\".\r\n", backPayload, pipe_num);
       
      }
     
      if ( (millis() - time_started_waiting) > 3000 ) {
          timeout = true;
          printf("This round is over.\r\n\r\n");
      }
     
    }

    // Try again 1s later
    delay(1000);
  }

  //
  // Pong back role.  Receive each packet, dump it out, and send it back
  //

  if ( role == role_pong_back )
  {
    uint8_t pipe_num;
    //printf("counter = %d\r\n", counter);
   
    // if there is data ready
    if ( radio.available(&pipe_num) && pipe_num == 1)
    {
      // Dump the payloads until we've gotten everything
      char receivePayload[33];
      bool done = false;
      uint8_t len = radio.getDynamicPayloadSize();
     
      //while (radio.available())
      //{
        // Fetch the payload, and see if this was the last one.
        radio.read( receivePayload, len );
      //}
     
      receivePayload[len] = 0;

      printf("received pipe: %d, \"%s\".\n\r", pipe_num, receivePayload);

      strcat(receivePayload, "|node2");
     
      radio.stopListening();
      radio.openWritingPipe(pipes[1]);
     
      delay(random(10, 20)*3);
      radio.write(receivePayload, strlen(receivePayload), true);
     
      radio.startListening();
    }
   
  }
}

5  Using Arduino / Networking, Protocols, and Devices / Re: a simple example of how to TX and RX char array maniacbug RF24 NRF24L01+ modules on: August 14, 2014, 04:38:43 am
This is about as simple as it gets:

Code:
#include <SPI.h>
#include "RF24.h"

// Your chosen radio CE,CS pins
RF24 radio(7,8);

uint64_t addresses[] = {0xABABABABABLL, 0xC3C3C3C3C3LL};

/****** Configure this for sender or receiver *****/
boolean sender = 0; // Change this from 0 to 1 to switch between sending or receiving sketch


void setup() {
  
  Serial.begin(57600);
  radio.begin();
  
  if(sender == 0){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
    radio.startListening();
  }else{
    radio.openWritingPipe(addresses[0]);    //*Edit to correct address assignments
    radio.openReadingPipe(1,addresses[1]);
    radio.stopListening();
  }
  
}

char myArray[] = "This is not a test";

void loop() {
    
  if(sender == 0){
      if(radio.available()){
        char tmpArray[19];                                               // This generally should be the same size as the sending array
        radio.read(&tmpArray,sizeof(tmpArray));  // Reading 19 bytes of payload (18 characters + NULL character)
        Serial.println(tmpArray);                                   // Prints only the received characters because the array is NULL terminated
        
      }
    
  }else{
  
      bool ok = radio.write(&myArray,sizeof(myArray));
  
      if(ok){ Serial.println("Transfer OK");
      }else { Serial.println("Transfer Fail");
      }
      delay(1000);
  }

}

There is really no need for the receiver to reply manually, it does automatically, so the transmitter knows if the payload was received. The char array is NULL terminated, so it is easily printed at the receiver without knowing the length.

A more complicated example using dynamic payload sizes is shown at: http://tmrh20.github.io/RF24/pingpair_dyn_8ino-example.html .

Of course, if using the RF24 libs, I would also recommend using one of the current forks at https://github.com/stanleyseow/RF24 or https://github.com/tmrh20/RF24  

6  Using Arduino / Audio / Re: tmrpcm - abnormal problem on: August 14, 2014, 03:39:28 am
What kind of board are you running this on?

I'm not really sure on this, but a couple things you could try:
1. Connect the 100Ohm resistor between the speaker and pin9. SD cards can draw quite a bit of power, so this may help with the issue if the speaker is drawing too much power.
2. Open the pcmConfig.h file included with the library and uncomment the line: #define DISABLE_SPEAKER2 just in case there is something weird going on with pin 10. I don't understand why connecting a resistor would change things.
3. Reformat the SD card and reload the wav files, they can get corrupted easily when running on breadboards sometimes. I like to double-up on connecting wires where possible when using SD cards on breadboards as well. 

7  Using Arduino / Networking, Protocols, and Devices / Re: RF24Network question on: August 06, 2014, 02:27:40 pm
It looks like it is probably just a small issue with the addressing.

The RF24Network addresses must be specified in Octal format.

In order to specify an octal number, it must begin with a 0.


Incorrect Addressing:


Code:
const uint16_t node11 = 11;    // This sets the address to the decimal value 11
const uint16_t node1 = 1;       // This sets the address to the decimal value 1
const uint16_t node12 = 12;   // This sets the address to the decimal value 12

Correct addressing:

Code:
const uint16_t node11 = 011;    // This sets the address to the decimal value 9
const uint16_t node1 = 01;       // This sets the address to the decimal value 1
const uint16_t node12 = 012;   // This sets the address to the decimal value 10

8  Using Arduino / Networking, Protocols, and Devices / Re: RF24Network question on: August 06, 2014, 04:15:40 am
All you should need in the loop is network.update(); for a relay node. Probably best to test all the nodes, double check addressing, etc.
9  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. " ...

...so it may work by opening the included pcmConfig.h file with a text editor, and un-comment the line
Code:
#define DISABLE_SPEAKER2
- that should disable the audio output on pin10

10  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:

http://tmrh20.github.io/RF24Network/Tuning.html

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.
11  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:

Transmitter:

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

RF24 radio(9,10);

const uint64_t pipe = 0xF0F0F0F0E1LL;

void setup(void) {
 
  Serial.begin(57600);
  radio.begin();
  //radio.setRetries(15,15);
  radio.openWritingPipe(pipe);
  
}


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


Receiver:

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

RF24 radio(9,10);

const uint64_t pipe = 0xF0F0F0F0E1LL;

void setup(void) {
 
  Serial.begin(57600);  
  radio.begin();
  //radio.setRetries(15,15);
  radio.openReadingPipe(1,pipe);
  radio.openWritingPipe(pipe);
  radio.startListening();
  Serial.println("Ready!");
  
}


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


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: https://github.com/TMRh20/RF24/archive/master.zip
12  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:

Code:
radio.openWritingPipe(pipe);

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.
13  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: http://tmrh20.github.io/RF24/GettingStarted_CallResponse_8ino-example.html   It may not work very well with the original library though.

14  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:
http://www.robotshop.com/ca/en/video-experimenter-arduino-compatible-shield.html
http://www.seeedstudio.com/depot/Video-Overlay-Shield-p-1232.html

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.
15  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

See https://github.com/TMRh20/TMRpcm/issues/3


Pages: [1] 2 3 ... 6