function with temperature sensor malfunctions

Hi guys

first of all here is the code:

int temperatureMeasure(byte sensorPinLocal, int timerLocal) {

readValue = analogRead(sensorPinLocal); voltage = readValue * 5 / 1024; temperature = (voltage - 500) / 10;

Serial.print( "The voltage is " + String(voltage, 2) + ", this value is a temperature of " + String(temperature, 1) + ".");

return temperatuur;

delay(timerLocal); }

If I open my serial monitor to take a look at the values, my voltage is 0.00 and my temperature -50.0. I can't seem to find my mistake, any help?

my voltage and temperature are floats.

my voltage and temperature are floats.

But the values used in computing them are all ints.

voltage = readValue * 5.0 / 1024.0;

This:

  return temperatuur;

Indicates that your code is unlikely to compile, or has a bug in it.

It would be interesting to know what readValue is, no?

it works, thank you Paul.

readValue is an integer I use for my value that comes in the analog input.

  return temperatuur;

  delay(timerLocal); }

That delay will never be executed.

Rossouw: it works, thank you Paul.

readValue is an integer I use for my value that comes in the analog input.

Indeed. Finding out what value it holds might be useful information to debug with.