From 8a54c70a94574463ac33d7e41b6c192e14652275 Mon Sep 17 00:00:00 2001 From: Arturo Guadalupi Date: Fri, 5 Jun 2015 11:30:35 +0200 Subject: [PATCH] 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 --- .../examples/TemperatureWebPanel/TemperatureWebPanel.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino index a5c9b9670..fa881b533 100644 --- a/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino +++ b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino @@ -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);