On Arduino I have the following (working) code:

#include <math.h>
void setup()
{
Serial.begin(115200);
}

void loop()
{

``````Serial.print(AnalogValue);
Serial.print(" = ");
Serial.println(Thermistor(AnalogValue)); // display Fahrenheit Serial.println("c");
delay(200);
``````

}

{
double Temp;
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}

In TinyCLR, using the same thermistor, I needed to perform the following:

private static UartController DebugPort = null;

static void Main()
{
int AnalogValue = 0;

``````ConfigDebugPort();

while (true)
{

AnalogValue = (int)((double)AnalogValue / 88.5);

DebugWrite(AnalogValue.ToString());
DebugWrite(" = ");
DebugWrite(Thermistor(AnalogValue) + "\r\n");

}
``````

}

{
double Temp;
Temp = Math.Log((((double)10240000 / (double)RawADC) - (double)10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp)) * Temp);
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}

The problem is the use of the 88.5 value. Why do I need to divide the returned value by this arbitrary value to get the same result as with the Arduino?

5v vs 3.3v?

you say thereâ€™s a â€śproblemâ€ť with dividing by a constant. But the whole thing is just one big calculation using constants, so not sure why you think thatâ€™s a â€śproblemâ€ť? As Gus said it could be as simple as the ADC differences (although I would have thought that would have been an .666666 problem). And differences in platform donâ€™t really equate to a â€śproblemâ€ť, just a difference.

The problem is that through trial and error, I worked out that I needed to divide the raw reading by 88.5 to get the same result as the Arduino. This to me feels like a hack and I want to know if Iâ€™ve just got something wrong.

Yes itâ€™s 5v vs 3.3 and probably different ADC resolution. I was hopeful that someone had done this before and had some hints.

1 Like

there are some of things you could consider for differences

5 vs 3.3
1024 (10 Bit) vs 4096(12 bit)
speed of mcu

1 Like

You should read ratio instead of raw value. This way your coffee will work on any system. If you need the voltage then multiply by 3.3

Is this a tease about a new GHI product? Will decaf be available?

1 Like

Lol. It is a special kind!! It should say code