user17234: Why does this throw the error: "void value not ignored as it ought to be
returning = printTemperature(returnLine);"
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
     return 0;
  } else {
    return tempC;
  }
}


void loop(){

   delay(2000);
   feeding = printTemperature(feedLine);
   returning = printTemperature(returnLine);
    mySql;
    feeding = 0;
    returning = 0;
}

Both 'feeding' and 'returning' are declared as a float too.

user18478: First of all: In C/C++ world void means "empty" as in "no value".
As the method is declared void it is saying that it does not return a value.
But the code sets the value and also assigns the return value to a variable.
Logically that does not make sense.
In the old days a void method returned an int (I'm not sure whether that is still the case) but it has never been a good idea to make a value returning method a void returning method.
So technically in the old days it made sense but it still was "not a good idea"
Nowadays compilers will return an error when you return a value in a void method. This can be turned off by using the -fpermissive compiler directive.
This directive might be useful in some template cases. I advice not to use it.

user313: printTemperature() is declared void (i.e., nothing returned) but it contains a return statement, and you've attempted to assign the (void) value. You probably meant to declare the function as 'float'.

17234: <p>Why does this throw the error: "void value not ignored as it ought to be</p>

<p>returning = printTemperature(returnLine);"</p>

<pre><code>void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
     return 0;
  } else {
    return tempC;
  }
}


void loop(){

   delay(2000);
   feeding = printTemperature(feedLine);
   returning = printTemperature(returnLine);
    mySql;
    feeding = 0;
    returning = 0;
}
</code></pre>

<p>Both 'feeding' and 'returning' are declared as a float too.</p>
 18478: <p>First of all: In C/C++ world void means "empty" as in "no value".</p>

<p>As the method is declared void it is saying that it does not return a value.
But the code sets the value and also assigns the return value to a variable.
Logically that does not make sense.</p>

<p>In the old days a void method returned an int (I'm not sure whether that is still the case) but it has never been a good idea to make a value returning method a void returning method.
So technically in the old days it made sense but it still was "not a good idea"</p>

<p>Nowadays compilers will return an error when you return a value in a void method. This can be turned off by using the -fpermissive compiler directive.
This directive might be useful in some template cases. I advice not to use it.</p>
 313: <p>printTemperature() is declared void (i.e., nothing returned) but it contains a return statement, and you've attempted to assign the (void) value. You probably meant to declare the function as 'float'.</p>
