-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Describe the bug
A clear and concise description of what the bug is.
When using a Nano v3 to RX or TX to a Nano v3 with version 1.4.1 of the RF24 library, the data is sent and received correctly with acknowledgement.
When switching out the RX Nano v3 for a Nano IoT 33, the RX received is corrupted repeatedly. Switching back to prior setup returns to proper operation.
Rolling back the library to 1.3.5 or earlier allow the Nano IoT 33 to properly RX from the Nano v3 as TX. The issue only comes back when the library is updated to a newer version than 1.3.5. All versions were tested newer than this all with corrupted results.
The Arduinos are both official versions from Arduino.
Results below when using 1.4.1 of library (Expected behavior is that received data matches sent data, but it doesn't)
TX is Nano v3
SimpleTx Starting
Data Sent abcdefghijklmnopqrstuvwxyz Acknowledge received
Data Sent ABCDEFGHIJKLMNOPQRSTUVWXYZ Acknowledge received
Data Sent 012345678901234567890123456789 Acknowledge received
Data Sent abcdefghijklmnopqrstuvwxyz Acknowledge received
Data Sent ABCDEFGHIJKLMNOPQRSTUVWXYZ Acknowledge received
Data Sent 012345678901234567890123456789 Acknowledge received
RX is Nano IoT 33
Data received qssvwww|}��~���xy{{~���|}�
Data received accfggglmoonoooxy{{~���|}�
Data received 89;;>???<=89;;>???<=89;;>???<=
Data received qssvwww|}��~���xy{{~���|}�
Data received accfggglmoonoooxy{{~���|}�
Data received 89;;>???<=89;;>???<=89;;>???<=
Results below when using 1.3.5 of library (Expected Behavior is correct here)
TX is Nano v3
SimpleTx Starting
Data Sent abcdefghijklmnopqrstuvwxyz Acknowledge received
Data Sent ABCDEFGHIJKLMNOPQRSTUVWXYZ Acknowledge received
Data Sent 012345678901234567890123456789 Acknowledge received
Data Sent abcdefghijklmnopqrstuvwxyz Acknowledge received
Data Sent ABCDEFGHIJKLMNOPQRSTUVWXYZ Acknowledge received
Data Sent 012345678901234567890123456789 Acknowledge received
Data Sent abcdefghijklmnopqrstuvwxyz Acknowledge received
RX is Nano IoT 33
Data received abcdefghijklmnopqrstuvwxyz
Data received ABCDEFGHIJKLMNOPQRSTUVWXYZ
Data received 012345678901234567890123456789
Data received abcdefghijklmnopqrstuvwxyz
Data received ABCDEFGHIJKLMNOPQRSTUVWXYZ
Data received 012345678901234567890123456789
Data received abcdefghijklmnopqrstuvwxyz
TX Code
// Special Version.
// Needs matching RX version with char dataReceived[32] instead of char dataReceived[10];
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[3][32] = { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" , "012345678901234567890123456789" } ;
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
Serial.println("SimpleTx Starting");
// const uint32_t SPI_SPEED = 500000 ; // 500000 Hz
// RF24 radio(CE_PIN, CSN_PIN, SPI_SPEED); // existing statement modified
radio.begin();
// radio.setPALevel(RF24_PA_MIN);
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() {
static uint8_t index = 0 ;
bool rslt;
rslt = radio.write( &dataToSend[index ], sizeof(dataToSend[ 0 ] ) );
// 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[ index ] );
if (rslt) {
Serial.println(" Acknowledge received");
}
else {
Serial.println(" Tx failed");
}
if ( ++index == 3 ) index = 0 ;
}RX Code
// SimpleRx - the slave or the receiver 32 byte dataReceived version
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[32]; // this must match dataToSend in the TX ********************
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
// const uint32_t SPI_SPEED = 500000 ; // 500000 Hz
// RF24 radio(CE_PIN, CSN_PIN, SPI_SPEED); // existing statement modified
radio.begin();
// radio.setPALevel(RF24_PA_MIN);
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;
}
}Metadata
Metadata
Assignees
Labels
No labels