Added dynamic memory allocation of the average readings buffer.