Commit 8c0e9f80 authored by TMRh20's avatar TMRh20

Merge pull request #21 from reixd/examples

Select a standard pin layout for the examples and update README files.
parents d3e5c4e5 51a71bca
......@@ -38,4 +38,25 @@ Supported Boards:
* ARM (Arduino Due) via extended SPI methods
* ATTiny 24/44/84 25/45/85
* Raspberry Pi
* See the [documentation](http://tmrh20.github.io/) for more info
\ No newline at end of file
* See the [documentation](http://tmrh20.github.io/) for more info
## Pin layout
The table below shows how to connect the the pins of the NRF24L01(+) to different boards.
CE and CSN are configurable.
| PIN | NRF24L01 | Arduino UNO | ATtiny25/45/85 [0] | ATtiny44/84 [1] |
|-----|----------|-------------|--------------------|-----------------|
| 1 | GND | GND | pin 4 | pin 14 |
| 2 | VCC | 3.3V | pin 8 | pin 1 |
| 3 | CE | digIO 7 | pin 2 | pin 12 |
| 4 | CSN | digIO 8 | pin 3 | pin 11 |
| 5 | SCK | digIO 13 | pin 7 | pin 9 |
| 6 | MOSI | digIO 11 | pin 6 | pin 7 |
| 7 | MISO | digIO 12 | pin 5 | pin 8 |
| 8 | IRQ | - | - | - |
[0] https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints
[1] http://highlowtech.org/?p=1695
......@@ -50,7 +50,7 @@ const uint64_t pipes[6] =
//RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);
// Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_8MHZ);
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
int main(int argc, char** argv)
......
......@@ -42,7 +42,7 @@ using namespace std;
//RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);
// Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_8MHZ);
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
//
......
......@@ -84,15 +84,16 @@ Choose any RPi output pin for radio CE pin.
**Pins:**
| NRF24L01 | RPI | P1 Connector |
|----------|------------|--------------|
| VCC | rpi-3v3 | (17) |
| GND | rpi-gnd | (25) |
| CE | rpi-gpio22 | (15) |
| CSN | rpi-gpio8 | (24) |
| SCK | rpi-sckl | (23) |
| MOSI | rpi-mosi | (19) |
| MISO | rpi-miso | (21) |
| PIN | NRF24L01 | RPI | RPi -P1 Connector |
|-----|----------|------------|-------------------|
| 1 | GND | rpi-gnd | (25) |
| 2 | VCC | rpi-3v3 | (17) |
| 3 | CE | rpi-gpio22 | (15) |
| 4 | CSN | rpi-gpio8 | (24) |
| 5 | SCK | rpi-sckl | (23) |
| 6 | MOSI | rpi-mosi | (19) |
| 7 | MISO | rpi-miso | (21) |
| 8 | IRQ | - | - |
See http://www.airspayce.com/mikem/bcm2835/index.html for BCM2835 class documentation.
......
# Optimized Raspberry Pi RF24 and RF24 Network Libraries
General Documentation: http://tmrh20.github.io
Library functions are mostly the same.
See the included examples for RPi specific usage
## Raspberry Pi - PreConfig
### Possible pre-configuration:
If SPI is not already enabled, load it on boot:
sudo raspi-config
A. Update the tool via the menu as required
B. Select Advanced and enable the SPI kernel module
C. Update other software and libraries:
sudo apt-get update
sudo apt-get upgrade
# RPi - RF24 Quick-Start
A. Make a directory to contain the RF24 and possibly RF24Network lib and enter it:
mkdir ~/rf24libs
cd ~/rf24libs
B. Clone the RF24 Repo
git clone https://github.com/tmrh20/RF24.git rtemp
C. Copy the RPi library folder to the current directory, and delete the rest
mv rtemp/RPi/RF24 ./
rm -r rtemp
cd RF24
D. Build the library, and run an example file:
sudo make install
cd examples
make
sudo ./gettingstarted
# RPi - RF24Network Quick-Start
A. Enter the same directory that contains the RF24 library folder
cd ~/rf24libs
B. Clone the RF24Network Repo
git clone https://github.com/tmrh20/RF24Network.git ntemp
C. Copy the RF24Network folder to the current directory, and delete the rest
mv ntemp/RPi/RF24Network ./
rm -r ntemp
cd RF24Network
D. Build the library
sudo make install
cd examples
make
sudo ./helloworld_rx OR sudo ./helloworld_tx
# Connection Info
Using pin 15/GPIO 22 for CE, pin 24/GPIO8 (CE0) for CSN
Can use either RPi CE0 or CE1 pins for radio CSN.
Choose any RPi output pin for radio CE pin.
**Constructor:**
RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ);
or
RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS1, BCM2835_SPI_SPEED_8MHZ);
**Pins:**
| NRF24L01 | RPI | P1 Connector |
|----------|------------|--------------|
| VCC | rpi-3v3 | (17) |
| GND | rpi-gnd | (25) |
| CE | rpi-gpio22 | (15) |
| CSN | rpi-gpio8 | (24) |
| SCK | rpi-sckl | (23) |
| MOSI | rpi-mosi | (19) |
| MISO | rpi-miso | (21) |
See http://www.airspayce.com/mikem/bcm2835/index.html for BCM2835 class documentation.
Note: The BCM library has been customized slightly to allow use of hardware CE pins not
in use for SPI, and to include a millis() function.
****************
Based on the arduino lib from J. Coliz <maniacbug@ymail.com>.
the library was berryfied by Purinda Gunasekara <purinda@gmail.com>.
then forked from github stanleyseow/RF24 to https://github.com/jscrane/RF24-rpi
Network lib also based on https://github.com/farconada/RF24Network
Currently optimized and aligned with Arduino fork of libraries by TMRh20:
https://github.com/tmrh20/RF24/RPi and https://github.com/tmrh20/RF24Network/RPi
Documentation: http://tmrh20.github.io
See RPi/RF24/readme.md
......@@ -24,7 +24,7 @@
#include "RF24.h"
#include "printf.h"
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8);
byte addresses[][6] = {"1Node","2Node"};
......@@ -134,4 +134,4 @@ void loop(void){
radio.openReadingPipe(1,addresses[0]);
}
}
}
\ No newline at end of file
}
......@@ -17,7 +17,7 @@
#include "RF24.h"
#include "printf.h"
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8);
// Topology
byte addresses[][6] = {"1Node","2Node"}; // Radio pipe addresses for the 2 nodes to communicate.
......
......@@ -26,7 +26,7 @@ TMRh20 2014
/************* USER Configuration *****************************/
RF24 radio(48,49); // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8); // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
unsigned long timeoutPeriod = 3000; // Set a user-defined timeout period. With auto-retransmit set to (15,15) retransmission will take up to 60ms and as little as 7.5ms with it set to (1,15).
// With a timeout period of 1000, the radio will retry each payload for up to 1 second before giving up on the transmission and starting over
......
......@@ -19,7 +19,7 @@
#include "RF24.h"
#include "printf.h"
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8);
// Topology
......
......@@ -21,7 +21,7 @@
// Hardware configuration
//
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8);
......@@ -229,4 +229,4 @@ void loop(void)
}
}
}
// vim:cin:ai:sts=2 sw=2 ft=cpp
\ No newline at end of file
// vim:cin:ai:sts=2 sw=2 ft=cpp
......@@ -25,7 +25,7 @@
#include <avr/power.h>
// Hardware configuration
RF24 radio(7,8); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(7,8); // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
const short role_pin = 5; // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
// Leave open to be the 'ping' transmitter
......
......@@ -32,7 +32,7 @@
#include "printf.h"
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(7,8);
// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
......
......@@ -26,9 +26,9 @@
// Hardware configuration
//
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
// Set up nRF24L01 radio on SPI bus plus pins 7 & 8
RF24 radio(9,10);
RF24 radio(7,8);
//
// Channel info
......@@ -123,4 +123,4 @@ void loop(void)
printf("\n\r");
}
// vim:ai:cin:sts=2 sw=2 ft=cpp
\ No newline at end of file
// vim:ai:cin:sts=2 sw=2 ft=cpp
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment