Added literal float to improve precision

according to #2922 I added missing float literals to improve the accuracy of the result.

If sensorValue = 1:

Before: voltage = 4

Now: voltage = 4.88
This commit is contained in:
Arturo Guadalupi 2015-06-05 11:30:35 +02:00
parent cdae13c3cc
commit 8a54c70a94
1 changed files with 2 additions and 2 deletions

View File

@ -98,9 +98,9 @@ void loop() {
Serial.println(timeString);
int sensorValue = analogRead(A1);
// convert the reading to millivolts:
float voltage = sensorValue * (5000 / 1024);
float voltage = sensorValue * (5000.0f / 1024.0f);
// convert the millivolts to temperature celsius:
float temperature = (voltage - 500) / 10;
float temperature = (voltage - 500.0f) / 10.0f;
// print the temperature:
client.print("Current time on the Yún: ");
client.println(timeString);