def open_data_file(self):
        self.logFilename = tempfile.mktemp()
        self.env.log("Saving sensor data to {}".format(self.logFilename))
        self.first_write = True
        try:
            self.logFile = open(self.logFilename, 'r+')
        except IOError:
            self.env.log("Failed to open file: {}".format(self.logFilename))
            self.logFile = None