Write a function to read data from a sensor and handle possible errors. Model each sensor attempt as a dictionary with ok and, when successful, value; return the first successful value within max_attempts, or None if every allowed attempt fails. Implement read_sensor(readings, max_attempts) without attempting reads beyond the retry limit.
ok booleanvaluedef read_sensor(readings, max_attempts):