Pages: [1]   Go Down
Author Topic: NRF24L01 can not be initialized  (Read 1824 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,

I've bought 2 NRF24L01 (the green ones with 10 Pins) on ebay and I connected them that way:

NRF24L01             Arduino Uno Pin              Arduino Mega 1280 Pin
VCC                             3,3V                                          3,3V
CE                                 9                                              48
CSN                             10                                              49
SCK                             13                                              52
MO                              12                                              50
MI                                11                                             51
IRQ                              -                                                -
GND                            GND                                           GND

I use the RF24 Library and the GettingStarted Sketch

Uno:
Code:
RF24 radio(9,10);

Mega:
Code:
RF24 radio(48,49);

(For Serial Output see attatchments)

The output of the Mega is very similar to the uno's.

The screenshots are taken with only one device up! And it does not change if I have both up (one is transmitting and one responding/receiving).
When both were running I scanned with my phone for available Bluetooth Devices but nothing was found.



* uno.png (14.38 KB, 527x423 - viewed 56 times.)

* uno2.png (10.26 KB, 520x275 - viewed 46 times.)
« Last Edit: August 19, 2012, 03:21:41 am by seaking » Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 94
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your screenshot seems to indicate the device is not getting detected properly.
It should display the correct addressing on boot:     RX_ADDR_P0-1   = 0xf0f0f0f0d2 0xf0f0f0f0e1


I can recreate your issue by reversing the following line:

RF24 radio(49,48);


My best bet is that you just have a couple wires reversed.
Logged

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

Unfortunately this was not the solution and I tried a slightly different Pin config from another website but the zeros in the config stay. 
Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of IDE are you using?

I still use 0018 with spi.h because when SPI.H was included with Arduino IDE package eveything stopped working

I have used NRF24l01's without problems,

TMRh20 is right CE & CSN are the wrong way round, I do remember having to define CSN in my code and remember to make it an OUTPUT

NRF24l01's work out of the box so theres no real need to mess with the registers unless you know what your doing
Logged

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

I use the current IDE 1.0.1 wit SPI.h
I do remember having to define CSN in my code and remember to make it an OUTPUT
Well I cannot use radio.csn(int bla) because is defined as private in the header file or do you mean to change it in the header file?
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


When both were running I scanned with my phone for available Bluetooth Devices but nothing was found.



The nRF24L01 is not a bluetooth device.
Logged


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


The nRF24L01 is not a bluetooth device.
Sure my mistake

@P18F4550 my 1.0.1 IDE SPI.h :
Code:
/*
 * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
 * SPI Master library for arduino.
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of either the GNU General Public License version 2
 * or the GNU Lesser General Public License version 2.1, both as
 * published by the Free Software Foundation.
 */

#ifndef _SPI_H_INCLUDED
#define _SPI_H_INCLUDED

#include <stdio.h>
#include <Arduino.h>
#include <avr/pgmspace.h>

#define SPI_CLOCK_DIV4 0x00
#define SPI_CLOCK_DIV16 0x01
#define SPI_CLOCK_DIV64 0x02
#define SPI_CLOCK_DIV128 0x03
#define SPI_CLOCK_DIV2 0x04
#define SPI_CLOCK_DIV8 0x05
#define SPI_CLOCK_DIV32 0x06
//#define SPI_CLOCK_DIV64 0x07

#define SPI_MODE0 0x00
#define SPI_MODE1 0x04
#define SPI_MODE2 0x08
#define SPI_MODE3 0x0C

#define SPI_MODE_MASK 0x0C  // CPOL = bit 3, CPHA = bit 2 on SPCR
#define SPI_CLOCK_MASK 0x03  // SPR1 = bit 1, SPR0 = bit 0 on SPCR
#define SPI_2XCLOCK_MASK 0x01  // SPI2X = bit 0 on SPSR

class SPIClass {
public:
  inline static byte transfer(byte _data);

  // SPI Configuration methods

  inline static void attachInterrupt();
  inline static void detachInterrupt(); // Default

  static void begin(); // Default
  static void end();

  static void setBitOrder(uint8_t);
  static void setDataMode(uint8_t);
  static void setClockDivider(uint8_t);
};

extern SPIClass SPI;

byte SPIClass::transfer(byte _data) {
  SPDR = _data;
  while (!(SPSR & _BV(SPIF)))
    ;
  return SPDR;
}

void SPIClass::attachInterrupt() {
  SPCR |= _BV(SPIE);
}

void SPIClass::detachInterrupt() {
  SPCR &= ~_BV(SPIE);
}

#endif
Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've started using different radio's now, not used nrf24l01's for a while, but when i did this is what i did

Code:
#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

int l=65;   // Cant remember what this was
int ledPin =  8;
void setup()
{
//  Serial.begin(9600);
    pinMode(ledPin, OUTPUT);

  Mirf.init();
  Mirf.setRADDR((byte *)"clie1");
  Mirf.payload = sizeof(int);
  Mirf.config();

}

void loop()
{
 // byte data[Mirf.payload];
  Mirf.setTADDR((byte *)"serv1");
 
  int temp = analogRead(0);  // read analog 0
  Mirf.send((byte *) &temp); // send the value
 
  while(Mirf.isSending())
  {
  }

  digitalWrite(ledPin, HIGH);  // blip the led to say it's sent
  delay(50);               
  digitalWrite(ledPin, LOW);   
  delay(950);     

}
Logged

Offline Offline
Jr. Member
**
Karma: 6
Posts: 94
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my pin configuration, it seems to differ slightly from what you posted initially, so thought it might be worth posting:

Mega:
48 (CE), 49 (CSN), 50 (MISO), 51 (MOSI), 52 (SCK)

RF24 radio(48,49);


Nano/Uno:

9 (CE), 10 (CSN), 11(MOSI), 12(MISO), 13(SCK)

RF24 radio(9,10);
Logged

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

Here is my pin configuration, it seems to differ slightly from what you posted initially, so thought it might be worth posting:

Mega:
48 (CE), 49 (CSN), 50 (MISO), 51 (MOSI), 52 (SCK)

RF24 radio(48,49);


Nano/Uno:

9 (CE), 10 (CSN), 11(MOSI), 12(MISO), 13(SCK)

RF24 radio(9,10);


I do have the exact same Pin Config smiley-wink and It does not work, now I tried the Mirf libraray but this does not even compile the examples :
Code:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp: In member function ‘void Nrf24l::init()’:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:85: error: ‘OUTPUT’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:85: error: ‘pinMode’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp: In member function ‘void Nrf24l::ceHi()’:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:285: error: ‘HIGH’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:285: error: ‘digitalWrite’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp: In member function ‘void Nrf24l::ceLow()’:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:289: error: ‘LOW’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:289: error: ‘digitalWrite’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp: In member function ‘void Nrf24l::csnHi()’:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:293: error: ‘HIGH’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:293: error: ‘digitalWrite’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp: In member function ‘void Nrf24l::csnLow()’:
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:297: error: ‘LOW’ was not declared in this scope
.../arduino-1.0.1/libraries/Mirf/Mirf.cpp:297: error: ‘digitalWrite’ was not declared in this scope
an it seem that the Mirf.ce() and Mirf.csn() set funtions had been removed.
Logged

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

add:

#include <Arduino.h>

underneath:

#include <WProgram.h>

in Mirf.h in the library files

Maayan Dreamer 
Logged

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

 smiley
add:
#include <Arduino.h>
underneath:
#include <WProgram.h>
in Mirf.h in the library files
Maayan Dreamer

====== it's ok and Solve my problem======
Logged

Pages: [1]   Go Up
Jump to: