import 'dart:io'; void main() { while (true) { final String raw = new File('/sys/bus/w1/devices/28-0000076b2ff7/w1_slave').readAsStringSync(); final List lines = raw.split('\n'); if (lines.isEmpty) throw 'no data from thermal sensor'; if (lines[0].length < 27) throw 'incomplete data from thermal sensor'; if (lines[0][27] != ':') throw 'incorrect format of crc check from thermal sensor'; if (lines[0].substring(36) != 'YES') throw 'thermal sensor data crc mismatch'; if (lines[1].substring(27, 29) != 't=') throw 'incorrect format of data from thermal sensor'; double celsius = int.parse(lines[1].substring(29)) / 1000.0; print('${new DateTime.now()}: ${celsius.toStringAsFixed(1)}°C'); } }