Answer the question
In order to leave comments, you need to log in
How to remove the floating point in the temperature value from the sensor in Arduino?
Good evening!
There is a code that converts the analog value from the thermistor to resistance and then to temperature.
reading_temp = analogRead(A0); // Write thermistor data to variable
// Convert Data to Resistance Thermistor
reading_temp = (1023 / reading_temp) - 1;
reading_temp = SERIESRESISTOR / reading_temp;
// Convert Resistance to Temperature
temp_data = reading_temp / THERMISTORNOMINAL; // (R/Ro) -> Data / Nominal Thermistor (10k)
temp_data = log(temp_data); // ln(R/Ro) Logarifm
temp_data /= BCOEFFICIENT; // 1/B * ln(R/Ro)
temp_data += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temp_data = 1.0 / temp_data; // Inverting
temp_data -= 273.15; // Converting to Temp *C
Answer the question
In order to leave comments, you need to log in
Nonsense about both sprintf() and String.
And most likely, you just
need Serial.println(1.23456, 0) to print "1"
0 - the number of decimal places to print.
float x = 4.567;
int z = (int) x; // z == 4
#include <math.h>
z = (int) roundf(x); // z == 5
convert the floating point number to an array of bytes and pass it serially with Serial.write(). On the other side, collect and convert back. Here is the data type to convert:
union cvt {
float val;
unsigned char b[4];
} x;
На отправителе:
x.val = 22.2;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question