Skip to content

Commit 8a54c70

Browse files
committed
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
1 parent cdae13c commit 8a54c70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ void loop() {
9898
Serial.println(timeString);
9999
int sensorValue = analogRead(A1);
100100
// convert the reading to millivolts:
101-
float voltage = sensorValue * (5000 / 1024);
101+
float voltage = sensorValue * (5000.0f / 1024.0f);
102102
// convert the millivolts to temperature celsius:
103-
float temperature = (voltage - 500) / 10;
103+
float temperature = (voltage - 500.0f) / 10.0f;
104104
// print the temperature:
105105
client.print("Current time on the Yún: ");
106106
client.println(timeString);

0 commit comments

Comments
 (0)