Title: **Project 3: Can't understand voltage to temperature formula**

Post by:**Furkidd** on **Jul 19, 2014, 03:37 am**

Post by:

Hello All and thanks for the help in advance

As mentioned in the book (page 48), every 10 millivolt represents 1 Celsius, which's mean to get the temperature, I write the following formula:

Instead, it's written in the book as following:

Could someone please explain why?

As mentioned in the book (page 48), every 10 millivolt represents 1 Celsius, which's mean to get the temperature, I write the following formula:

Code: [Select]

`float temperature = voltage * 0.01;`

Instead, it's written in the book as following:

Code: [Select]

`float temperature = (voltage - 0.5) * 100;`

Could someone please explain why?

Title: **Re: Project 3: Can't understand voltage to temperature formula**

Post by:**Hackscribble** on **Jul 19, 2014, 10:51 am**

Post by:

Hello Furkidd

You need to multiply by 100, not divide by 100, to convert 10mV (0.010V) to 1 degree.

Subtracting 0.5 from the voltage is to correct for a 500mV offset voltage on the sensor output.

Regards

Ray

You need to multiply by 100, not divide by 100, to convert 10mV (0.010V) to 1 degree.

Subtracting 0.5 from the voltage is to correct for a 500mV offset voltage on the sensor output.

Regards

Ray

Title: **Re: Project 3: Can't understand voltage to temperature formula**

Post by:**photopig** on **Sep 19, 2015, 03:44 pm**

Post by:

Hello Ray

Thanks for the explanation but I can't seem to figure out what you mean and where to figure out the 500mV offset voltage.

The book explains this -.5 is needed in the formula because it needs to offset the values below freezing.

I can't seem to understand either your or the book's explanation.

Thanks guys

Thanks for the explanation but I can't seem to figure out what you mean and where to figure out the 500mV offset voltage.

The book explains this -.5 is needed in the formula because it needs to offset the values below freezing.

I can't seem to understand either your or the book's explanation.

Thanks guys

Title: **Re: Project 3: Can't understand voltage to temperature formula**

Post by:**BootyBump** on **Sep 20, 2015, 03:08 am**

Post by:

I found the temperature conversion stated in the book was incorrect, or maybe just gave F values when it claimed to give C values. Tbh, there are a few errors or typos in the book and I am just up to Chapter 3..not sure if this is due to my starter kit being the Arduino SRL version.

I ended up changing the code to:

which gave the correct Celcius values.

I ended up changing the code to:

Code: [Select]

`// convert the voltage to temperature, then from degrees F to C`

float temperature = ((((voltage - 0.5) * 100) - 32) * 5) /9;

which gave the correct Celcius values.

Title: **Re: Project 3: Can't understand voltage to temperature formula**

Post by:**mzca** on **Oct 26, 2015, 11:18 am**

Post by:

You should lookup the datasheet for your specific temperature sensor online - they typically show charts indicating the voltage and corresponding temperature. For the TMP36 (which is what came with my kit), the data-sheet shows that they report 0.75 volts at 25C, and the chart shows a linear relationship between voltage and temperature. So 0.75 - 0.5 will give you 0.25. When you multiply that by 100 you get 25 (which is the temperature in C). If you saw a voltage of 0.80, that would correspond to another 5C above that (since 10 mV per C would be an additional 5C above 25C, which adds up nicely).

Here's a link to the TMP36 datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf

Hope that helps

Here's a link to the TMP36 datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf

Hope that helps