Pages: [1]   Go Down
Author Topic: Arduino Mega with NRF24L01+ and NRF24L01+ with Atmega328p  (Read 2495 times)
0 Members and 1 Guest are viewing this topic.
Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

im here, trying to get help to get myself out of misery... I've been searching for info on how to achieve my goal, but i still couldn't find :S

Basically i have an Arduino Mega 2560, 2x NRF24L01+ (5v capable) and an Atmega328p on a breadboard...
I would like to know the connections i should make, since i have already found several versions and none worked...
I know that this post asks for a lot, but im quite desperate...

First Step:

NRF24L01+ / Arduino Mega
1-GND             GND
2-VCC             VCC
3-CE                 ?
4-CSN               ?
5-SCK               ?
6-MOSI              ?
7-MISO              ?
8-IRQ                ?

Can you fill the ? please

Second Step:

NRF24L01+ / Atmega328p (breadboard with 16mhz crystal)

1-GND             GND
2-VCC             VCC
3-CE                 ?
4-CSN               ?
5-SCK               ?
6-MOSI              ?
7-MISO              ?
8-IRQ                ?

Can you fill the ? please

The purpose of this is to use the arduino to activate a relay on the breadboard and then receive the completed order

If i know that the hardware part is correct, i can go and deal only with the software part

Thanks in advance

Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

5-SCK               ?
6-MOSI              ?
7-MISO              ?

Those connect to the Mega/Mega328 pins with the same name.

All the others will depend on the driver you want to use.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

5-SCK               ?
6-MOSI              ?
7-MISO              ?

Those connect to the Mega/Mega328 pins with the same name.

All the others will depend on the driver you want to use.


Thank you for the reply... in that case, i should first get the "code" part.
I'll get by when i have more work done on that matter

Again, Thanks
Logged

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i chose the RF24 library to go to.
RF24 radio(9,10); these would be the CSN and CE?

9 and 10 would be on arduino side, and on the uC?
« Last Edit: May 12, 2013, 05:20:04 pm by Maks » Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i chose the RF24 library to go to.
RF24 radio(9,10); these would be the CSN and CE?

9 and 10 would be on arduino side, and on the uC?

I haven't used that library but it looks like it, yes.

The IRQ pin isn't needed to make it work. You can leave it unconnected.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the answers, i'll update this thread if needed
Logged

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunatly i'm back with some bad news :S

first of all, ill post my code on each side then the connections...

Arduino Side (tx)

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.
 */

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

// nRF24L01(+) radio attached using Getting Started board
RF24 radio(49,53);
 
// Network uses that radio
RF24Network network(radio);
 
// Address of our node
const uint16_t this_node = 1;
 
// Address of the other node
const uint16_t other_node = 0;
 
// How often to send 'hello world to the other unit
const unsigned long interval = 2000; //ms
 
// When did we last send?
unsigned long last_sent;
 
// How many have we sent already
unsigned long packets_sent;
 
// Structure of our payload
struct payload_t
{
  unsigned long ms;
  unsigned long counter;
};


void setup(void)
{
  Serial.begin(57600);
  Serial.println("RF24Network/examples/helloworld_tx/");
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}


void loop(void)
{
  // Pump the network regularly
  network.update();
 
  // If it's time to send a message, send it!
  unsigned long now = millis();
  if ( now - last_sent >= interval  )
  {
    last_sent = now;
 
    Serial.print("Sending...");
    payload_t payload = { millis(), packets_sent++ };
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
  }
}

Connections:

nrf24l01+          Arduino Mega 2560

1-GND               GND
2-VCC               5v
3-CE                 53 or 49
4-CSN               49 or 53
5-SCK               52
6-MOSI              51
7-MISO              48


ATMega328p on breadboard (RX)

Code:
//RX

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

// nRF24L01(+) radio attached using Getting Started board
RF24 radio(49,53);
 
// Network uses that radio
RF24Network network(radio);
 
// Address of our node
const uint16_t this_node = 0;
 
// Address of the other node
const uint16_t other_node = 1;
 
// How often to send 'hello world to the other unit
const unsigned long interval = 2000; //ms
 
// When did we last send?
unsigned long last_sent;
 
// How many have we sent already
unsigned long packets_sent;
 
// Structure of our payload
struct payload_t
{
  unsigned long ms;
  unsigned long counter;
};



void setup(void)
{
  Serial.begin(57600);
  Serial.println("RF24Network/examples/helloworld_tx/");
 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}


void loop(void)
{
  // Pump the network regularly
  network.update();
 
  // Is there anything ready for us?
  while ( network.available() )
  {
    // If so, grab it and print it out
    RF24NetworkHeader header;
    payload_t payload;
    network.read(header,&payload,sizeof(payload));
    Serial.print("Received packet #");
    Serial.print(payload.counter);
    Serial.print(" at ");
    Serial.println(payload.ms);
  }
}

Connections:

nrf24l01+          ATMega328p

1-GND               GND
2-VCC               5v
3-CE                 14
4-CSN               15
5-SCK               19
6-MOSI              17
7-MISO              18


Results:

On Arduino (tx)

with CE on 53 and CSN on 49
Code:
RF24Network/examples/helloworld_tx/
Sending...failed.
Sending...failed.
Sending...failed.

only with CSN on 49
Code:
Sending...RF24Network/examples/helloworld_tx/
Sending...failed.
Sending...failed.
Sending...failed.

Without CE or CSN
Code:
RF24Network/examples/helloworld_tx/
Sending...ok.
Sending...ok.

Something must be wrong and im too blind/newb to see. Maybe the pins on ATMega328p (breadboard)? maybe arduino? maybe both?

I tried to be as explicit as possible and btw, the code was from http://maniacbug.wordpress.com/2012/03/30/rf24network/

Thanks in advance
Logged

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just so you know, i'm not asking for you to check the code, but the pin assignment, cause that's what i'm really struggling. I've never worked with uC before, so this is mostly new to me
Logged

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

got it working now... My problem was the connections, they were wrong.

Thanks for the help
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What in the pins was wrong? The assignments in your list? Or did you plug in wrong?
Logged

Portugal
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the problem was on the mega side... i was connecting it wrong...
if i recall correctly, (i made a pause o the project, lack of time) i use the pins 49, 50, 51 and 52, the power/gnd and the assigned pins for comms
Logged

Pages: [1]   Go Up
Jump to: