Exit a loop in a Function

I am back again.
I am inching along with this project of mine. The sketch works fine, but now I am stuck in a loop within a Function. The Function is printing the correct voltage from a voltage divider ( a feat in itself), as it should be, and as you probably figured, I can not escape the loop. I have tried using break; (in various locations), well that is not working.

The error that I am receiving is "exit status 1 expected unqualified-id before 'break'

Sorry about being a pain!!
Thanks again,

The loop is in the "ReadSensors" Function.

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>

#define NUM_SAMPLES 50          // Voltage - number of samples to take

int sum = 0;                    // Voltage - sum of samples taken
unsigned char sample_count = 0; // Voltage - current sample number
float voltage = 0.0;            // Voltage - calculated voltage 

void setup() 
{
  Serial.begin(9600);
  while (!Serial) ; // wait for serial
  delay(200);  
}

void loop() 
{
   tmElements_t tm;

  if (RTC.read(tm))
   
    if ((tm.Second) == 01)  // using Second for testing
    
    {
    Serial.println("Second 01 code");
    Serial.println();
    delay(1000);
    SaveDataToPi(); // This function will save the hourly sensor data to the SQLdB on the Raspberry Pi
    }
    
    if ((tm.Second) == 55)  // using Second for testing
  
    {
    Serial.println("Second 55 code"); 
    Serial.println();
    delay(1000);
    ReadSensors(); // This function will read the sensors for current hourly data 
    } 
       
   else 
   
    { 
     Serial.println("else part of  code,  ");
     Serial.println();    
     if ((tm.Second) != 01)
     delay(1000);
    }
}   
void ReadSensors() //Read sensor function
 {
  Serial.println("<<<<< Reading_Sensors >>>>>>");
  Serial.println();  
  // This function will start reading the sensors for current hourly data 

{
    
    while (sample_count < NUM_SAMPLES) // add up sample count    
    {
        sum += analogRead(A2);
        sample_count++;
    }
    voltage = ((float)sum / (float)NUM_SAMPLES * 5.015) / 1024.0;
    Serial.print(voltage * 11.132);
    Serial.println (" V");
    sample_count = 0;
    sum = 0;        
  
   } 

 }

 void SaveDataToPi() // Save sensor data to Pi dB function
 {
  Serial.println("<<<<<< Saving_Sensor_Data to the Pi >>>>>>");
  Serial.println();  
  // This function will save the hourly sensor data to the SQLdB on the Raspberry Pi 
 }

Which function is giving you problems?
Have you tried return() instead of break;? (I think that break is only valid in a switch statement).

BRAINDEAD!!!

At 2 AM I could not sleep and looked at the forum on my phone. I saw the comments that the break could not be found, well, I forgot to include the code. I inserted the code first thing this morning, so that I would not forget AGAIN, sorry.

OK, I left the break; in the "ReadSensors" Function. The program is caught in this loop.

I also want to thank you for the "Control +T" to align the code tip. What a GREAT option, helps the brain a lot. Is there a page with a list of these types of TIPS?

Thanks again,

Don

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>

#define NUM_SAMPLES 50          // Voltage - number of samples to take

int sum = 0;                    // Voltage - sum of samples taken
unsigned char sample_count = 0; // Voltage - current sample number
float voltage = 0.0;            // Voltage - calculated voltage

void setup()
{
  Serial.begin(9600);
  while (!Serial) ; // wait for serial
  //  delay(200);
}

void loop()
{
  tmElements_t tm;

  if (RTC.read(tm))

    if ((tm.Second) == 01)  // using Second for testing

    {
      Serial.println("Second 01 code");
      Serial.println();
      delay(1000);
      SaveDataToPi(); // This function will save the hourly sensor data to the SQLdB on the Raspberry Pi
    }

  if ((tm.Second) == 55)  // using Second for testing

  {
    Serial.println("Second 55 code");
    Serial.println();
    delay(1000);
    ReadSensors(); // This function will read the Temperature/Humidity/Voltage sensors for current hourly data
  }

  else

  {
    Serial.println("else part of  code,  ");
    Serial.println();
    if ((tm.Second) != 01)
      delay(1000);
  }
}
void ReadSensors() //Read sensor function
{
  Serial.println("<<<<< Reading_Sensors >>>>>>");
  Serial.println();
  // This function will start reading the sensors for current hourly data

  {

    while (sample_count < NUM_SAMPLES)                                           // Voltage - add up sample count
    {
      sum += analogRead(A2);                                                           // Voltage
      sample_count++;                                                                    // Voltage
    }
    voltage = ((float)sum / (float)NUM_SAMPLES * 5.015) / 1024.0;       // Voltage
    Serial.print(voltage * 11.132);                                     // Voltage
    Serial.println (" V");                                                                  // Voltage
    sample_count = 0;                                                                   // Voltage
    sum = 0;                                                                                // Voltage
    break;
  }

}

void SaveDataToPi() // Save sensor data to Pi dB function
{
  Serial.println("<<<<<< Saving_Sensor_Data to the Pi >>>>>>");
  Serial.println();
  // This function will save the hourly sensor data to the SQLdB on the Raspberry Pi
}

STOP!!!!!
After removing break; and doing "Control + T", it is now exiting the ReadSensor's Function.

Now on to adding temperature sensors and humidity sensors.

I will post the working code for others as I go along. Probably should add to the projects section also.

Thank you,