Page 1 of 1

Analog measuring (Temperature with thermistor)

Posted: Fri May 15, 2015 10:35 am
by juanpaexpedite
I am a newbie in the world of Raspberry and I have seen there are several solutions for reading analog, this example for measuring temperature: ... hermistor/ Is is very simple to understand, discharging, wait and charge and read the time takes to charge.

I have made the following code:

Stopwatch pulseLength;
public void Charge()

pulseLength = new Stopwatch();


while(SecondGpio.Read() == GpioPinValue.Low)

Temperature = pulseLength.Elapsed.TotalMilliseconds;


private void Discharge()

public async void Initialize()
await Task.Delay(100);
await Task.Delay(100);

And I get this random values 2.6,2.6,1.9,1.9,2.6,2.6,10.6,10.6 really random.

Might be I need to use ValueChanged, but I am not sure what is the best way to follow, any idea how to solve that?

Re: Analog measuring (Temperature with thermistor)

Posted: Fri May 15, 2015 2:07 pm
by mikronauts
Cheap solution:

PCF8591 module, 8 bit resolution, CHEAP

Medium solution:

MCP3008, 10 bit resolution, easy to hook up and use

Good solution:

MCP3208, 4.096V voltage reference, possibly voltage divider for 8.192V range ... and-howto/

Re: Analog measuring (Temperature with thermistor)

Posted: Tue May 26, 2015 8:11 am
by juanpaexpedite
Finally I managed a solution working with uF and Valuechanged, I made a post in my blog about how to measure temperature with GPIOs in Windows 10 IoT. It is the most accurate I can do. I also have found that is possible to do with a fixed voltage source, but it is more inestable.

It took me a bit of time to know that the Rpi2 has debounce time 0 that means I should use ValueChanged, and that works really well and is a non blocking event so it's great.

Apart thank you for the ADC I am still waiting they arrive.

Re: Analog measuring (Temperature with thermistor)

Posted: Mon Jun 01, 2015 9:42 am
by juanpaexpedite
To begin in the SPI world, I follow the steps in here:

I have followed the steps with a MCP3002 and I have an issue with the values.
I fixed the pot at 5 Kohm and I get the values as follows


I understand there is something wrong in the frecuency it gets the values, but I am new in this and I do not know what
is the best way to follow.