Refactor `to_dict` into util

`to_dict` now accepts arbitrary objects. Add repr and str support for
sensor readings and packets.