Hi all,
I am pulling whatever is left of my hair on this.
I can make the nRF work fine on my ESP8266 if I set it up with radio(2,4)
I want to attach an LCD with I2C to the ESP and need to move the CE of the NRF to another pin as the I2C has to be attached to D1 and D2.
As soon as I change to another pin (ex: radio(0,4)
or radio(8,4)
) it fails.
I read and tried many things (pull-down, pull-up resistors, Wire library to reassign the I2C reserved pins, etc.) with no luck.
What am I missing.
Below is the code that works. As soon as I change the CE pin for the nRF module, it fails: radio.begin()
returns false and nothing is received.
Thanks
#include <SPI.h>
#include <RF24.h>
RF24 radio(2, 4); // using pin 2 for the CE pin, and pin 4 for the CSN pin
uint8_t address[][6] = { "1Test", "2Test" };
#define PAYLOADSIZE 32 // max payload size of NRF24 data
void setup() {
Serial.begin(115200);
Serial.println("boot sequence started");
Serial.println("Initializing radio");
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
}
radio.setPALevel(RF24_PA_LOW);
radio.setPayloadSize(PAYLOADSIZE);
radio.setChannel(100);
radio.openWritingPipe(address[0]);
radio.openReadingPipe(0, address[1]);
radio.startListening();
//radio.printPrettyDetails();
Serial.println("Init complete");
}
void loop() {
uint8_t pipe;
if (radio.available(&pipe)) {
uint8_t bytes = radio.getPayloadSize();
char radioMsg[PAYLOADSIZE] = "";
radio.read(&radioMsg, bytes);
Serial.print(F("Received "));
Serial.print(bytes);
Serial.print(F(" bytes on pipe "));
Serial.print(pipe);
Serial.print(F(": *"));
Serial.print(radioMsg);
Serial.println(F("*"));
String name = String(radioMsg);
String value = name.substring(name.indexOf(":")+1);
name = name.substring(0,name.indexOf(":"));
Serial.print("name:");
Serial.print(name);
Serial.print("\tvalue:");
Serial.println(value);
}
}