Commit everything before going to sleep. Need to write background thread to read and write sensor values