Improved temperature writing to db