nRF24L01+ returns 'ovf'?

Hello everybody,

Been doing a project where i can get temperatures from different places in my garden.
The 'master' is an MKR 1400 GSM and the 'slave' is an arduino Nano.
Communication happens with nRF24L01+.

My problem is the 'slave' is constantly sending the temperature, but all I get at the 'master' side is "ovf"....?

I also made sure I am sending a float from the slave and trying to read it as a float at the master side.

My 'slave' code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>

/*
   Misc
*/
#define LED 6
#define RELAY 5
float startTemp = -4.0; //-4.0
float stopTemp = 2.0; //2.0
bool branderGestart = true;

/*
   Radio info
*/
RF24 radio(7, 8); // CE, CNS
const byte b1[6] = "00sb1";
const byte b1Send[6] = "00bb1";

/*
  SENSOR INFO
*/

// Data wire is plugged into digital pin 2 on the Arduino
/* TEMPERATURE PRECISION
   9 bit => 0.5°C
   10 bit => 0.25°C
   11 bit => 0.125°C
   12 bit => 0.0625°C
*/

#define OWpin 4
#define TEMPERATURE_PRECISION 12
OneWire oneWire(OWpin);
DallasTemperature sensors(&oneWire);




void setup() {
  sensors.begin();
  sensors.setResolution(0, TEMPERATURE_PRECISION);
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
  pinMode(RELAY, OUTPUT);

  radio.begin();
  radio.openReadingPipe(0, b1);
  radio.openWritingPipe(b1Send);
  radio.setPALevel(RF24_PA_MIN);

}

void loop() {
  char text[32];
  float temp;

  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);
  Serial.println(sensors.getTempCByIndex(0));
  if (temp <= startTemp) {
    tempTeLaag(true);
  } else if ((temp > startTemp) && (temp >= stopTemp)) {
    tempTeLaag(false);
  }

  radio.stopListening();
  radio.write(&temp, sizeof(temp));
  radio.startListening();
  if (radio.available()) {
    radio.read(&text, sizeof(text));
    branderStuff(text[0]);
    digitalWrite(LED, HIGH);
    delay(1500);
  }
  digitalWrite(LED, LOW);

  
}

My 'master' code:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <GSM.h>
#include <MKRGSM.h>
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <nRF24L01.h>
#include <RF24.h>

/*
  SENSOR INFO
*/

// Data wire is plugged into digital pin 2 on the Arduino
/* TEMPERATURE PRECISION
   9 bit => 0.5°C
   10 bit => 0.25°C
   11 bit => 0.125°C
   12 bit => 0.0625°C
*/

#define OWpin 2
#define TEMPERATURE_PRECISION 12
OneWire oneWire(OWpin);
DallasTemperature sensors(&oneWire);

/*
  GSM INFO
*/
#define PINNUMBER ""
#define LUC "*DELETED*"
#define JAN "*DELETED*"
char senderNumber[20]; //Nummer ontvanger
GSM gsm;
GSM_SMS sms;
bool notConnected = true;

/*
  nRF24L01+ INFO
*/

RF24 radio(7, 6);  // CE, CSN - MKR GSM 1400
const byte b1[] = "00sb1";
const byte b1Send[6] = "00bb1";


/*
  SEN0193 HUMIDITY SENSOR INFO
*/

const int rainPin = A2;

/*
  GENERAL INFO
*/
bool activateKast = false;
bool activateAlarm = true;
int alarmRepeatTime = 20000;
double tempAlarm = 0.0;
double tempStart_Brander1 = -4.0;
double tempStop_Brander1 = 2.0;
bool branderGestart = true;

String startupSMS = "OK! \nVersie 09/01/22 \nAlarm geactiveerd op " + (String)tempAlarm + " gr. \nStuur M voor menu.";


/********************************SETUP************************************************/
void setup() {
  sensors.begin();
  sensors.setResolution(0, TEMPERATURE_PRECISION);

  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.openWritingPipe(b1);
  radio.openReadingPipe(0, b1Send);

  Serial.begin(9600);
  delay(2000);
  Serial.println(gsm.begin(PINNUMBER));
  Serial.println("Sim(3) -> OK!");
  Serial.println("Temp sensor -> OK!");

  //Is pin nummer ok?
  while (notConnected) {
    if (gsm.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
      /*sms.beginSMS(LUC);
        sms.print(startupSMS);
        sms.endSMS();*/
      sms.beginSMS(JAN);
      sms.print(startupSMS);
      sms.endSMS();
      Serial.println("PIN OK");
    }
    else {
      Serial.println("Not connected");
    }
  }

  Serial.println("LETS GO");

}

/************************************LOOP********************************************/
void loop() {
  float tempRF24_B1;
  radio.startListening();

  sensors.requestTemperatures();

  //Als gemeten temperatuur onder grens valt, stuur alarm!
  if ((sensors.getTempCByIndex(0) <= tempAlarm) && activateAlarm) {
    stuurAlarm();
    sms.flush();
  }

  // Wachten op SMS
  if (sms.available()) {
    smsGedoe();
  }

  if (radio.available()) {
    radio.read(&tempRF24_B1, sizeof(tempRF24_B1));
    Serial.println(tempRF24_B1);
    //sms.beginSMS(senderNumber);
    //sms.print(String(receivedRF24));
    //sms.endSMS();
  }

  delay(10);
}

Monitor output:


22:32:36.554 -> ovf
22:32:37.479 -> ovf
22:32:38.393 -> ovf
22:32:39.316 -> ovf
22:32:40.208 -> ovf
22:32:41.119 -> ovf
22:32:42.060 -> ovf
22:32:42.967 -> ovf
22:32:43.878 -> ovf
22:32:44.785 -> ovf
22:32:45.691 -> ovf

Is the size of a float on these two platforms the same ?

Both have undefined length.

I'm sending to master

float temp;

and reading in master code

float tempRF24_B1;

The float length will be defined somewhere, how could functions using float calculations operate without it .........

I meant undefined before being sent.

The 'temp' variable is the length that the temperature sensor gives it and it is AT MOST 6 characters.
(ex. 25.00 or -20.00).

As you can see in the code of the slave and master, the float length is not predefined:

float temp;

  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);
  
radio.stopListening();
  radio.write(&temp, sizeof(temp));

and in master:

float tempRF24_B1;

  radio.startListening();
if (radio.available()) {
    radio.read(&tempRF24_B1, sizeof(tempRF24_B1));
}

I think not. Remember that if you print a float with no second parameter it prints 2 decimal places by default

Try Serial.println(sizeof(float)); on both boards to see how many bytes a float takes on each

monitor from slave

11:40:52.281 -> 24.50
11:40:52.315 -> 4
11:40:52.853 -> 24.50
11:40:52.887 -> 4
11:40:53.422 -> 24.50
11:40:53.455 -> 4
11:40:53.993 -> 24.50
11:40:54.027 -> 4
11:40:54.560 -> 24.50
11:40:54.593 -> 4

monitor from master:

11:50:49.502 -> 4
11:50:50.409 -> ovf
11:50:50.409 -> 4
11:50:51.315 -> ovf
11:50:51.315 -> 4
11:50:52.257 -> ovf
11:50:52.257 -> 4
11:50:53.161 -> ovf
11:50:53.161 -> 4

Same length.
Which is weird I guess, seeing he does not count the '.'
And he is receiving "ovf", which counts 3 chars.

Problem still not resolved.
It's probably something stupid, but I can't find it.

Did you

Yes, look post #7