NRF24L01 do not transfer integer number correctly

Hi everybody,
I learn how to code Arduino with NRF24L01 to transfer various formats of data.
char works well, however integer of float does not show on the receiver the transmitted information.
I want the receiver to respond to the transmitter sending numbers, however when I do not add delay at the
end of the code, the numbers on the serial screen run without any relation to the transmittion.
Please see the codes of both transmitter and receiver.
Thank you for your suppot

2021_03_06_TRANSMITTER_INTEGER-00.ino (965 Bytes)

2021_03_06_RECEIVER_INTEGER-00.ino (781 Bytes)

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
float counter;

void setup() {

  Serial.begin(57600);  //Serial printer display
  radio.openReadingPipe(0, address);   //Setting the address at which we will receive the data

void loop() {
  //if (radio.available())  
  //{          , sizeof(counter)); //Radio receives the transmitted data, counter number
    Serial.print("Counter number = ");

 // else {      Serial.println ("NO TRANSMISSION");

 // }

You want the if, not the else part nor the delay.

void loop() {
  if (radio.available()) {       , sizeof(counter));
    Serial.print(F("Counter number = "));

I would also check the result of the sending operation.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.