I recently bought two "SparkFun Transceiver Breakout - nRF24L01+ (RP-SMA)" and the antenna. I am using an Arduino Uno to receive, and an ATtiny85 @8Mhz to send, just very basic communication. My Arduino receiving code is below with the hookup in it.
/*
Getting Started example sketch for nRF24L01+ radios
This is a very basic example of how to send data from one node to another
Updated: Dec 2014 by TMRh20
*****PINOUT*****
VCC - 5Vdc
CE - Arduino pin 7
CSN - Arduino pin 8
SCK - Arduino pin 13
MOSI - Arduino pin 11
MISO - Arduino pin 12
IRQ -
GND - GND
*****PINOUT*****
*/
#include <SPI.h>
#include "RF24.h"
/****************** User Config ***************************/
/*** Set this radio as radio number 0 or 1 ***/
int radioNumber = 0;
const int CE_PIN = 7;
const int CSN_PIN = 8;
/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(CE_PIN, CSN_PIN);
/**********************************************************/
byte addresses[][6] = {"1Node", "2Node"};
int datarecv;
void setup() {
Serial.begin(9600);
Serial.println("RF24/examples/GettingStarted");
radio.begin();
radio.setChannel(108);
// Set the PA Level low to prevent power supply related issues since this is a
// getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
radio.setPALevel(RF24_PA_LOW);
if (radioNumber == 0) {
radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses
radio.openReadingPipe(1, addresses[0]); // Open a reading pipe on address 0, pipe 1
} else {
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
}
// Start the radio listening for data
radio.startListening();
}
void loop() {
if (radio.available())
{
while (radio.available())
{
radio.read( &datarecv, sizeof(datarecv) );
}
Serial.print("DATE RECIVED: ");
Serial.println(datarecv);
}
}
My ATtiny85 sending code is below. I am using the first pinout hookup.
/*
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.
rf24ping85.ino by tong67 ( https://github.com/tong67 )
This is an example of how to use the RF24 class to communicate with ATtiny85 and other node.
Write this sketch to an ATtiny85. It will act like the 'transmit' mode of GettingStarted.ino
Write GettingStarted.ino sketch to UNO (or other board or RPi) and put the node in 'receiver' mode.
The ATtiny85 will transmit a counting number every second starting from 1.
The ATtiny85 uses the tiny-core by CodingBadly (https://code.google.com/p/arduino-tiny/)
When direct use of 3v3 does not work (UNO boards have bad 3v3 line) use 5v with LED (1.8V ~ 2.2V drop)
For low power consumption solutions floating pins (SCK and MOSI) should be pulled high or low with eg. 10K
** Hardware configuration **
ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 4
+-\/-+
NC PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 --- LED --- 5V
nRF24L01 CE, pin3 --- PB3 2| |7 PB2 --- nRF24L01 SCK, pin5
nRF24L01 CSN, pin4 --- PB4 3| |6 PB1 --- nRF24L01 MOSI, pin7
nRF24L01 GND, pin1 --- GND 4| |5 PB0 --- nRF24L01 MISO, pin6
+----+
ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 3 => PB3 and PB4 are free to use for application
Circuit idea from http://nerdralph.blogspot.ca/2014/01/nrf24l01-control-with-3-attiny85-pins.html
Original RC combination was 1K/100nF. 22K/10nF combination worked better.
For best settletime delay value in RF24::csn() the timingSearch3pin.ino scatch can be used.
This configuration is enabled when CE_PIN and CSN_PIN are equal, e.g. both 3
Because CE is always high the power consumption is higher than for 5 pins solution
^^
+-\/-+ nRF24L01 CE, pin3 ------| //
PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 ------x----------x--|<|-- 5V
NC PB3 2| |7 PB2 --- nRF24L01 SCK, pin5 --|<|---x-[22k]--| LED
NC PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6 1n4148 |
nRF24L01 GND, pin1 -x- GND 4| |5 PB0 --- nRF24L01 MISO, pin7 |
| +----+ |
|-----------------------------------------------||----x-- nRF24L01 CSN, pin4
10nF
ATtiny24/44/84 Pin map with CE_PIN 8 and CSN_PIN 7
Schematic provided and successfully tested by Carmine Pastore (https://github.com/Carminepz)
+-\/-+
nRF24L01 VCC, pin2 --- VCC 1|o |14 GND --- nRF24L01 GND, pin1
PB0 2| |13 AREF
PB1 3| |12 PA1
PB3 4| |11 PA2 --- nRF24L01 CE, pin3
PB2 5| |10 PA3 --- nRF24L01 CSN, pin4
PA7 6| |9 PA4 --- nRF24L01 SCK, pin5
nRF24L01 MOSI, pin7 --- PA6 7| |8 PA5 --- nRF24L01 MISO, pin6
+----+
*/
#include "RF24.h"
// CE and CSN are configurable, specified values for ATtiny85 as connected above
#define CE_PIN 3
#define CSN_PIN 4
//#define CSN_PIN 3 // uncomment for ATtiny85 3 pins solution
/*** Set this radio as radio number 0 or 1 ***/
int radioNumber = 1;
int i = 0;
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = {"1Node", "2Node"};
unsigned long payload = 0;
void setup() {
// Setup and configure rf radio
radio.begin(); // Start up the radio
radio.setChannel(108);
radio.setPALevel(RF24_PA_LOW);
if (radioNumber == 0) {
radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses
radio.openReadingPipe(1, addresses[0]); // Open a reading pipe on address 0, pipe 1
} else {
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
}
radio.startListening(); // Start listening
}
void loop(void) {
radio.stopListening();
radio.write( i, sizeof(i) );
i++;
delay(1000);
}
The first problem is that the flow of data is not there. In serial monitor it displays one then nothing, or displays 10 very fast then nothing.
The second problem, and more concerning to me, is that the breakout hooked up to the Arduino is hot to the touch. I am not sure it is hooked up correctly.
Can I define, MOSI, MISO, IRQ, and SCK pins to verify correct pinout? This article, https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo#lib , talks about intermittent operation and lack of current. But, I am using an 80 W power supply and the amperage reading is only 0.3 peak, with an ATtiny85 and two RF breakouts on it.