Hi all,
I am working on a project to measure/calculate temperature from a NTC resistor using MCP3208.
the arduino code works but i have a problem to write it in B4R.
I get different values.
...and this is the B4R Code
any idea?
i have also testet to use the Arduino Code inline but i get an Error at the point
thx for help
I am working on a project to measure/calculate temperature from a NTC resistor using MCP3208.
the arduino code works but i have a problem to write it in B4R.
I get different values.
Arduino Code:
float Rmess = 47;
float a, b, c, Rn;
Rn = 1000;
a = 0.003358;
b = 0.0002242;
c = 0.00000261;
// start sampling
uint16_t raw = adc.read(MCP3208::Channel::SINGLE_0); --> 3915 (3154mv)
float Rt = Rmess * ((4096.0 / (4096 - raw)) - 1); -->1016.60
float v = log(Rt / Rn); -->0.02
float erg = (1 / (a + b * v + c * v * v)) - 273.15; -> 24.32
...and this is the B4R Code
B4X:
Dim Rmess,V,erg As Float
Dim RT As Float
Dim a,b,c,rn As Float
rn = 1000
a = 0.003358
b = 0.0002242
c = 0.00000261
Rmess=47
RT = Rmess * ((4096.0 / (4096 - 3915)) - 1) '-->1016.6022
v= RT/rn
v = Logarithm(V,10) '-->0.0072
erg = (1 / (a + b * v + c * v * v)) - 273.15 '--> 24.54
any idea?
i have also testet to use the Arduino Code inline but i get an Error at the point
is calledfloat v = log(Rt / Rn);
thx for help