...
- SCLK: Serial Clock (output from master)
- MOSI: Master Output Slave Input, or Master Out Slave In (data output from master)
- MISO: Master Input Slave Output, or Master In Slave Out (data output from slave)
- SS: Slave Select (often active low, output from master)
Hookup
2- Use the following ESP32 pin configuration for wairing ESP32 to nRF24L01+
CE -> GPIO17 GPIO
CSN -> GPIO05 VSPI SS
MISO -> GPIO19 VSPI MISO
MOSI -> GPIO23 VSPI MOSI
CLK -> GPIO18 VSPI CLK
IRQ-> unconnected
Sample TX Code
Code Block |
---|
#include <SPI.h> #include "RF24.h" /* * Sample Transmitter * * CLK 14 * MOSI 13 * MISO 12 * CS 15 * CE 8 */ #define CE_PIN 8 #define CS_PIN 15 RF24 radio(CE_PIN,CS_PIN); byte addresses[][6] = {"i8-00","I8-00"}; char buf[1]; int bufsize=1; void setup() { Serial.begin(115200); Serial.println(F("\n\ni8 Tx Started")); Serial.println(F("*** PRESS 'B-G' to represent button")); radio.begin(); // Set the PA Level low to prevent power supply related issues. radio.setPALevel(RF24_PA_LOW); radio.setRetries(15,15); radio.setPayloadSize(8); radio.setDataRate(RF24_1MBPS); radio.setAutoAck(1); // Ensure autoACK is enabled radio.openWritingPipe(addresses[0]); radio.stopListening(); } void loop() { // process serial requests if ( Serial.available() ) { char c = toupper(Serial.read()); //'B', 'C', 'D', 'E', 'F', 'G' if(c >= 'B' && c <= 'G'){ Serial.printf("> %c \n",c); buf[0]=c; int v = radio.write(&buf, bufsize); buf[0]=tolower(c); v = radio.write(&buf, bufsize); } } } |
...