Now could you help me with this?
Ok well done posting code as code-sections
need a litlle time to add serial debug-output to your code.....
EDIT: Your code is simplified as much as possible. Which is simplified too much.
Your code does not evaluate if sending was successful
try this code
Transmitter
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}
Receiver
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
open the serial monitor and watch what is printed to the serial monitor
At transmitter end:-
Data Sent Message 0 Acknowledge received
Data Sent Message 1 Acknowledge received
Data Sent Message 2 Acknowledge received
Data Sent Message 3 Acknowledge received
Data Sent Message 4 Acknowledge received
Data Sent Message 5 Acknowledge received
Data Sent Message 6 Acknowledge received
Data Sent Message 7 Acknowledge received
Data Sent Message 8 Acknowledge received
Data Sent Message 9 Acknowledge received
Data Sent Message 0 Acknowledge received
At receiver end:-
SimpleRx Starting
Data received Message 7
Data received Message 8
Data received Message 9
Data received Message 0
Data received Message 1
Data received Message 2
Data received Message 3
Data received Message 4
Data received Message 5
Data received Message 6
Data received Message 7
Data received Message 8
Data received Message 9
both are wrong IMHO.
How to correct it
Help me to correct code by which both servo can be cotrolled each with potentiometer. Please help.
please add to codes printing the sending values on transmitter and received values on receiver
and show the result
I will record video tomorrow and show that to you but please wait till tomorrow....
Thank you
?????
You dont know how to use Serial.print?
Is it serious?
You can always read the manual and learn it.
I do not think that the video can help.
Your other identical topic has been locked
@
The othertopic has been locked as it is the identical to this one
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Thank you.
No worries as I already told I am new to forum that's why most of the guidelines I don't know. But for now I just want to say that I won't repeat this again
@shrayanshsharma
Thank you
I don't see any major mistakes.
I don't know how but when I use Serial.begin() and Serial.printIn the issue is soved now thank you buddy very much......
If you did not address the above, you are up for interesting debugging.
You don't use the address you think you are using,
but content from memory location 0x31 to 0x35.
How would you guarantee that both nodes have the same content at that area?
If you had enabled warnings, the compiler would give you a hint, probably.
@Whandall However problem is solved for now but then also can you tell me how to correct that line. Please!!
No, will not correct your code.
openReadingPipe is documented here
https://nrf24.github.io/RF24/classRF24.html#a9edc910ccc1ffcff56814b08faca5535
What parameters types do you pass, and which are expected?
@Whandall Is this correct :-
Transmitter
const byte address[6] = "00001";
radio.openWritingPipe(address);
Receiver
const byte address[6] = "00001";
radio.openReadingPipe(0, address);
Yes, this guarantees identical pipe address on both nodes.
Using pipe 0 for reception adds avoidable overhead while switching from transmit to receive,
if you only use one pipe, I would prefer pipe 1.
I think that there is no use of this line. Am I right?
No,
it contains superfluous braces,
a superfluous while,
a delay in the receiving code,
and it does not moderate the sending speed to some sensible rate.
You seem to be not interested in the outcome of the transmission, why?
The serial rate is only a PITA.
Yes, it seems to be a relict.
I think a constant for a single pipe can be a literal in the open call.