Posts: 15
Joined: Fri May 15, 2015 10:27 am

Analog measuring (Temperature with thermistor)

Fri May 15, 2015 10:35 am

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:

http://raspberrypi.powersbrewery.com/pr ... 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?

User avatar
Posts: 2817
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Analog measuring (Temperature with thermistor)

Fri May 15, 2015 2:07 pm

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

http://www.mikronauts.com/raspberry-pi/ ... and-howto/
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Posts: 15
Joined: Fri May 15, 2015 10:27 am

Re: Analog measuring (Temperature with thermistor)

Tue May 26, 2015 8:11 am

Finally I managed a solution working with uF and Valuechanged, I made a post http://bit.ly/1cWcUJO 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.

Posts: 15
Joined: Fri May 15, 2015 10:27 am

Re: Analog measuring (Temperature with thermistor)

Mon Jun 01, 2015 9:42 am

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.

Return to “Windows 10 for IoT”