Hi guys
I`m trying to convert float value to text in order to be displayed correctly in Nextion display.
Nextion is Integer math and does not accept float unless is in text format.
I`m not so sure how the "dtostrf" works.
Can you please help me solving this?
Thanks
void Voltmeter(void)
{
for (int i = 0; i < SensorSampling; i++) value += analogRead(VoltageInput); // return 0..1023 representing 0..5V
value = value / SensorSampling;
// CONVERT TO VOLTAGE
// float vout = (5.0 * value) / 1023; // voltage = 0..5V; we do the math in millivolts!!
pinMode(VoltageInput, INPUT);
// read the value at analog input
vout = (value * 5.0) / 1024.0;
vin = vout / (R2 / (R1 + R2));
if (vin < 0.09) {
vin = 0.0; //statement to quash undesired reading !
}
dtostrf(vin, 4, 6, buff);
Serial.println(vin, 1);
Serial1.print("t1.text=");
Serial1.print(vin, 1);
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
}