I need your support to resolve the below mysterious phenomena:
I am building a Node and Gateway to measure temperature, humidity & CO2.
The Node is Arduino MEGA. The transmitter and the receiver: NRF24L01
When the Gateway is Arduino UNO, then the sketch is working perfectly.
When I change the Gateway to NodeMCU ESP 8266MOD, then
I am getting only one, totally wrong data: 8438000
ran a simple test transmitting text array
RP2040 transmitter
// ESP32 > NRF24L01 transmitter test using a text string
// RP2040 connections
// RP2040 SPIO_SCK pin GP18 goes to NRF24L10_pin SCK
// RP2040 SPIO_RX pin GP16 goes to NRF24L10_pin MISO
// RP2040 SPIO_TX pin GP19 goes to NRF24L10_pin MOSI
// RP2040 pin SPIO_CSn GP17 to NRF24L10 CSN
// RP2040 pin GP20 to NRF24L10 CE
// RP2040 GND and 3.3V to NRF24L10 GND and VCC
#include <SPI.h>
#include "RF24.h"
#define CE_PIN 20
#define CSN_PIN 17
bool radioNumber = 0;
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = { "1Node", "2Node" };
void setup() {
Serial.begin(115200);
Serial.println("\n\nRP2040 > NRF24L01 transmit text");
radio.begin();
if (radio.isChipConnected())
Serial.println("\n\nTransmitter NF24 connected to SPI");
else Serial.println("\n\nNF24 is NOT connected to SPI");
radio.setChannel(125);
radio.setPALevel(RF24_PA_MIN);
radio.powerUp();
radio.setDataRate(RF24_1MBPS);
//radio.setDataRate(RF24_250KBPS);
if (radioNumber) {
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1, addresses[0]);
} else {
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
}
radio.stopListening();
//radio.setPayloadSize(sizeof(Struct1));
}
// loop transmiting data packet
void loop() {
static char testString[10] = "text 0";
radio.write(testString, sizeof(testString));
Serial.print("transmit ");
Serial.println(testString);
delay(1000);
testString[5]++;
}
nano receiver
// Nano > NRF24L01 receiver test using a text string
// UNO/Nano connections
// arduino SCK pin 11 goes to NRF24L10_pin SCK
// arduino MISO pin 12 goes to NRF24L10_pin MI
// arduino MOSI pin 13 goes to NRF24L10_pin MO
// NRF24L10 CE to arduino pin 9
// NRF24L10 CSN to arduino pin10
#include <SPI.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
bool radioNumber = 1;
const uint8_t pipes[][6] = { "1Node", "2Node" };
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Nano > NRF24L01 Receive text");
radio.begin();
if (radio.isChipConnected())
Serial.println("Receiver NF24 connected to SPI");
else {
Serial.println("NF24 is NOT connected to SPI");
while (1)
;
}
radio.setChannel(125);
radio.setDataRate(RF24_1MBPS);
//radio.setDataRate(RF24_250KBPS);
radio.printDetails();
if (!radioNumber) {
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1, pipes[1]);
} else {
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
}
radio.startListening();
// radio.setPayloadSize(sizeof(Struct1));
}
//=============
void loop() {
if (radio.available()) {
char testString[10] = "";
radio.read(testString, sizeof(testString));
Serial.print("Test string: ");
Serial.println(testString);
}
}
RP2040 serial monitor
RP2040 > NRF24L01 transmit text
Transmitter NF24 connected to SPI
transmit text 0
transmit text 1
transmit text 2
transmit text 3
transmit text 4
transmit text 5
nano serial monitor
Nano > NRF24L01 Receive text
Receiver NF24 connected to SPI
Test string: text 0
Test string: text 1
Test string: text 2
Test string: text 3
Test string: text 4
looks OK
EDIT: are you attempting to transmit/receive packets with different contents and of different sizes
if so how do you tell which packet is which?