In particular, create a class for the magnetic sensor, that should hold the read/write methods and have a friendlier API for configuration.