I am using the NRF module for remote communucation.I have been many research about nrf but my nrf module is not working This is my tranmistter code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8,4000000); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(115200);
radio.begin();
radio.openWritingPipe(address);
radio.setRetries(15,15);
radio.setPALevel(RF24_PA_HIGH);
}
void loop() {
radio.stopListening();
const char text[32]="Hello world";
if(radio.write(&text,sizeof(text))){
Serial.println("Mesaj gönderildi");
}
delay(1000);
This is my receiver code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8,4000000); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
delay(400);
radio.openReadingPipe(1, address);
radio.setPALevel(RF24_PA_MAX);
// radio.startListening();
pinMode(10,OUTPUT);
}
void loop() {
const char text[32]="";
radio.startListening();
if(radio.available())
{
while(radio.available()){
radio.read(&text[0],sizeof(text[0]));
Serial.println(text);
delay(1000);
}
}
delay(5);
}
ı tried the setPAlevel min but there is no change.In the transmitter side the write function returns true, but I can't get anything on the receiver side. Also, if I replace the cable connected to miso with the cable connected to mosi on the transmistter side, the write function still returns true. I also used adaptor ams1117
radio.read(&text[0],sizeof(text[0]));
This looks odd.sizeof(text[0])
is only one byte.const char text[32]="";
from the receiver also looks odd because this buffer is supposed to be writable. Anyway, use the code from the thread here: forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/… to test your nrf24L01 devices. Most problems with these nrf24L01 devices are related to inadequate power supplies.