# Can you explain what the 3300.0, 450.0 and the 19.5 stands for?

Can you please let me know how to change the numbers for the formula shown below in order to get the temperature in Fahrenheit° and additionally add a 1.13 degree offset? Can you explain what the 3300.0, 450.0 and the 19.5 stands for?

``````    /// Gets the temperature in celsius from the onboard sensor.
public double GetTemperature() => (this.analog.Read(4) * 3300.0 - 450.0) / 19.5;
``````

Thanks

I’d say that this formula is calculating the temperature based on the sensor that is used on the Fez Hat.
analog.Read(4) is the raw number that the analog sensor is outputting, and the formula then adjusts this back to a temperature. The sensor is MCP9701 - Thermal Management - Analog Temperature Sensors and you can look at the details there, including section 4 of the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/20001942G.pdf which talks about the calculations.

To convert C to F, just use a standard formula. Multiply by 9, then divide by 5, then add 32. And if you need to offset, then you can simply add that yourself.

3300.0 Sound like 3300mV.
If Read Returns 0…1 then by multiplying with 3300 gives you mV.
I guess 450 is the voltage in mV at 0°C
Then 19.5 would be mV per °K

@ Cristaleja - @ Brett and @ Reinhard Ostermeier are correct. Those values are derived from Figure 2-16 in the datasheet Brett provided.

Is this where the value 450 comes from?

@ Cristaleja - Yes.

Do you think there is any relation with this temperature reading being so "Jumpy? Can you take a look at this video and tell me why this value does not seem to want to settle down and provide a steady Temp reading.

This value is coming from a Thermistor (Resistance 31.52 KΩ at room temperature 85.3 F°) which is making contact with the heating element.

The Thermistor is wired to the Fez board through a 10KΩ resistor.

I included video for the FezHat also to show the onboard temperature sensor also being pretty jumpy, the code used here comes directly from this class: (converted to F°)

/// Gets the temperature in celsius from the onboard sensor.
public double GetTemperature() => (this.analog.Read(4) * 3300.0 - 450.0) / 19.5;

Is there anything I can do to get a steady temp reading?

@ Cristaleja - The jumpiness you are seeing is expected. The temperature sensor is a simple analog sensor, so there will always be some noise in the less significant bits because it is analog. It is not meant to be very precise nor have we calibrated it or the analog chip for any particular scenario. You may need to provide your own filtering function and there may be advanced features or calibration functions on the chips that you can explore and configure. The driver we provide is meant to be a very simple getting started driver suitable for most basic uses.

@ John

That’s all I needed to know. Thanks…

I tried to make my application live with this jumpy value but it seems too annoying to ignore it, specially when the analog value being measured is temperature which in real live does not jump 1 to 3 degrees up and down every second.

Question:
Can you provide your customers, with this filtering or smoothing code you talked about.?

I have not idea how to go about programming sometime like this from scratch. But since you are in this business you surely must have the need to come up with this C# code before.

Thanks!!!

You can contact GHI via their Consulting Services.
Or you just look around in the Internet how smoothing algorithm,s work.
I’m quite sure you can find some C# implementation online too.
Entering “c# measurement value smoothing” into my search engine, I get a ton of hits.

@ Cristaleja - We don’t have a specific sample available, but something like the quick code below can get you started:

``````
var total = 0.0;
var rounds = 25;

for (var i = 0; i < rounds; i++) {
total += hat.GetTemperature();

}

return Math.Round(total / rounds, 2);

``````

This code takes 25 readings spaced 1ms apart. You can customize the number of readings and the delay to suit your needs. The delay may not be needed. It averages these 25 readings and then rounds the result to 2 decimal points.

@ John - Thanks it worked. Problem Solved!!!

@ John:

Thanks for your help, I finally published my project:

https://www.kickstarter.com/projects/691671111/automatic-pressure-cooker-for-those-who-never-cook

Andy

1 Like