Main Site Documentation

Thermometer problem


I’ve a Panda II that is reading from a thermometer ( e-block).
I’ve some trouble with data readed: it reportd 7 to 11 degrees, but we have 25 to 30.
Where is the error?


This is the code (basically the demo project from the Web site):

            // Initialize the e-blocks
            thermometer = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An2);
            thermometer.SetLinearScale(-22, 56);


      temp = thermometer.Read();

                 Debug.Print("Temperature: " + temp + " C");



Power must be +5V and calibrate with another thermometer in driver


The SetLinearScale call parameters don’t look right. I haven’t used this specific thermometer, but since it’s analog I’m guessing it’s a thermistor. Voltage does not equal temperature on a thermistor. You’ll have to do a conversion. There are data tables to do that, but I’m not sure where… maybe someone else can chime in, or provide some working code.


Are you using the driver?


The thermomether is this:

yes, its a thermistore, and I’m using the demo code provided by GHI. I also think there is something wrong with the scale used reading data, but I’m using the provided sample code (that is the same included in the driver) so I think it’s strange I may find different scale parameters…



I have used that thermometer before to monitor my fish tank’s temperature.
The temperature was calculated correctly.
I was using the celsius value, not the fahrenheit.


So, may I think that the sensor is broken? Or may I find a “custom scale” to rearrange data I read to real temperature?

(I also uses Celsius, as my code reports)


You must use the driver functions that scale the value to Celsius. If you use Analog Read you must scale by yourself. See the example in the downloads tab at the catalog.


I’m using the drivers and I’m reading Celisus (that, BTW, the “driver” reads raw input from analog in: “return adc.Read();”)

so, from

temp = Thermometer.GetTemperatureCelsius();

I’m reading 10°, but we have about 25°… :frowning:


here’s a test. Hold the thermistor to heat it up, does the temperature your application reports go up? Put it in some warm water, same deal does the temp go up? Put it in the freezer, does the temp go down?

As you can see from the driver, the thermistor is a very simple device; it simply changes resistance as temperature changes. The Fez is simply reading the voltage through the thermistor that is connected to the ADC.

adc.SetLinearScale(-22, 56);

That scales the values from the ADC. The ADC resolution means you can read from 0 to 1023, or 1024 steps. That means that each step is (56 - -22)/1023 or 78/1023, or 0.076246 degrees per step. 10 degrees means the ADC is reading between 420 and 432 (depending on how the rounding is being handled, it could be +/-6 I guess).

You could try commenting out the scaling statement and find what the return values are to confirm that.

You could adjust the scaling to return the right value for you. The challenge is that to accurately do this adjustment you need to calculate the value at at least two different points. Really you need to do a LOT of sampling, at multiple known temperatures, so you can get an accurate model of the thermistor’s response. But doing a couple of tests and comparing the returned value and a quick calculation can tell you how to set the scaling.


Another question: which voltage is this thermometer connected to?
5v? 3,3v?


After removing the linear scale setting the device is reading 430, you are right.

The device is connected using the pre-connected 3 pin e-block, to the connect shield. I’m really a newbie and I don’t know if this connector is 3.3 or 5 (I think 3.3). It’s connected to the An2 however (I’ve the light sensor to the An3).

I can make some sampling and calibrate the sensor, but is this normal? I mean: I have the “official prebuilded” sensor from GHI (FEZ ultimate kit), is it normal I may to calibrate the software as the single specific sensor requires?



See the attached picture for selecting 5V vs 3.3V on the FEZ Connect Shield.


Thank you! :stuck_out_tongue:
My shield is arrived with 3.3V selected. I selected 5V as you suggested, and now thermometer is reading values as aspected (or, at least, they are plausible… 21°. I’ve not an other thermometer here now)!
Is good to leave 3.3V for the shield? Why GHI is releasing with 5V as default? The jumper updates voltage for the entire shield and every port, doesn’t it?

(I don’t know if light sensor now is reading well now, because I’ve not a reference… it reports values lover than running 5V, but it can be ok)



Take a look at the User Guide for the FEZ Connect Shield (link below). Page 1 states “Jumper to choose the VCC source (5V or 3.3V) at An3 and An2 JST connectors” So the voltage selection is just for the An3 and An2 JST connectors and not the entire shield.


and also “If you are not sure what to use, always keep the jumper in the 5V position.” :slight_smile:



Glad yo got it solved, seemed more and more like a voltage problem :stuck_out_tongue: