Getting ovf in Serial Moniter

For some reason I am getting "ovf" for float x = measureTemp(). I have tried moving measureTemp() into void loop() with no success.

//  Uses nRF24 lib from here (unzip into "/home/<username>/Arduino/libraries"):
//  https://github.com/nRF24/RF24


#include <printf.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
// for the set of available functions see:
// https://github.com/nRF24/RF24/blob/master/RF24.h




RF24 radio(10, 9); // CE, CSN
const unsigned char id[] = "test1"; // 5 bytes




#include <dht_nonblocking.h>
#define DHT_SENSOR_TYPE DHT_TYPE_11


static const int DHT_SENSOR_PIN = 8;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );




void setup() {
  Serial.begin(115200);
  printf_begin();
  
  delay(1000);
  if(!radio.begin()){};//module did not respond // defaults to channel 76;
  radio.setPALevel(RF24_PA_MAX);//RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
  radio.setRetries(0,1);//setRetries(uint8_t delay, uint8_t count)
  radio.setDataRate(RF24_1MBPS);//RF24_250KBPS (does not work), RF24_1MBPS, RF24_2MBPS
  radio.setChannel(70);// 0..125
  radio.enableDynamicPayloads();
  radio.enableAckPayload();
  radio.setAddressWidth(5);


  if(radio.isChipConnected())Serial.println("RF24 connected");else Serial.println("no RF24");
  if(radio.testCarrier())Serial.println("testCarrier = true");else Serial.println("testCarrier = false");
  if(radio.testRPD())Serial.println("testRPD() = true");else Serial.println("testRPD() = false");
  if(radio.isPVariant())Serial.println("isPVariant() = true");else Serial.println("isPVariant() = false");
  radio.printDetails();
  
  radio.openWritingPipe(id);
  radio.stopListening();    
  Serial.println("start");
}




//measures every 4 seconds
static bool measure_environment( float *temperature, float *humidity )
{
  static unsigned long measurement_timestamp = millis( );
  
  if( millis( ) - measurement_timestamp > 3000ul ) 
  {
    if( dht_sensor.measure( temperature, humidity ) == true )
    {
      measurement_timestamp = millis( );
      return( true );
    }
  }
  return( false );
}




float measureTemp(){
    float temperature;
    float humidity;
    delay(1000);
    if(measure_environment(&temperature, &humidity) == true)
    {
        return temperature;
    }
}






void loop() {


  
  float x = measureTemp();//this is producing ovr for some reason???
  Serial.println(x);


  
///////////////////////////////////////////////////////////////////////////
  float y = 11.00; //this is test 
 
  bool b = radio.write(&y, sizeof(y));// = false if error, true if delivered
  if(!b){
     Serial.println("write failed");
    }else{
     //Serial.print("write ok ... ");
     if (radio.isAckPayloadAvailable()) {
         // read ack payload and copy data to relevant remoteNodeData array
         radio.read(&y, sizeof(y));
         Serial.print("ack = ");
         //Serial.println(y);
        }else{
         Serial.println("no ack payload available.");
        }
      }
  delay(1000);
}

How does this relate to "Website and Forum"; the subtitle is "Improvements for the web system, applications to moderator, spam, etc. Use GITHUB for official reports."

Please click the "report to moderator" link under your post and ask a moderator to move it to a more suitable section.

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