Hello guys, it's Nicholas again. I was working on testing on the nrf24L01 module and when i test it. There is nothing received in the receiver. I use the RF24 library by TMHR20 and i think that maybe all of the online instructions are from 2014 to 2017 so if you guys have newer instruction about this library i would love to see it. Also i think the main problem is in the code because many of these instructions online has nothing fit into my library even having the same name. Well anyway, please help me to solve this problem.
Here is my code.
transmitter:
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
RF24 radio(7,8);
int text=A2;
int textValue;
struct Data{
byte textValue;
};
byte address1[1]="00001";
Data data;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address1);
radio.setChannel(100);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.stopListening();
pinMode(text, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
radio.write(&data, sizeof(Data));
textValue=analogRead(text);
Serial.println(textValue);
delay(500);
}
Receive:
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
RF24 radio(7, 8);
struct Data{
byte textValue;
};
Data data;
int textValue;
byte address1[1]="00001";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, address1);
radio.setChannel(100);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
if(radio.available()){
radio.read(&data, sizeof(Data));
Serial.println(textValue);
delay(500);
}
}
Also, one more thing that i use the nrf24L01 module with antenna( not the none antenna) and board Arduino UNO R3 SMD. The purpose of this code is to send value of pin A2 to the receiver and read it in the serial monitor.
Schematic of the transmitter and the receiver is the sameone.