1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-01 03:47:23 +03:00

Merge pull request #3294 from agdl/TemperatureWebPanelFix

Added literal float to improve precision
This commit is contained in:
Federico Fissore
2015-06-05 12:45:59 +02:00

View File

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