started function to write data for alarm to db