Added averaging function for sensor data