# Open-Source Magnetometer for Characterizing Magnetic Fields in Ultracold Experiments
## 4 Measurement of Magnetic Fields
With the completed sequence, we can obtain the stray field values (Figure 4a) and the sensor offset (Figure 4b) at each position of the sensor for all three axes (\(x\), \(y\) and \(z\)). Once the user has confirmed the requested operation, the MOSFET-based power switch is turned on to let the current flow through the set of coils (this is redundant for the permanent magnets). The stepper motor is then driven in the reverse direction and again for each position (always corresponding to a position where stray fields have been measured), and magnetic field readouts are obtained, one for each direction of the sensor polarization, until the Hall sensor reaches the initial (starting) position of the sequence. It is worth noting that, in the permanent mode, we observe a backlash of about 0.3 mm due to the change in the direction of motion. This issue is not present when the measurements are performed in the coil mode as the change in the direction of motion does not take place. In this second run, the Hall sensor readouts are equal to the sum of the magnetic field generated by the set of coils, the stray magnetic field and the sensor offset. Equation (4a) and the data obtained with the coils off let us extract the \(x\),\(y\) and \(z\) components of the magnetic field, as can be seen in Figure 3a,c. The latter figure shows a non-negligible variation in the \(x\) and \(z\) components of the magnetic field. We have minimized these variations before recording the data used to prepare Figures 3a,c and 4 by adjusting the orientation of the coil assembly to identify the axis of symmetry of the coils. In the ideal case, the field along the \(x\) and \(z\) axes would be zero. We believe that the main reason for the observed asymmetries is that the coils are not exactly the same: they became slightly deformed during winding and are not ideally parallel. All these factors are hard to control when winding coils in house. In reality, however, these small differences are rarely an issue in actual experiments. To characterize sets of assembled coils, one would, ideally, perform measurements by moving the sensor also along the remaining axes. For this purpose, the ability to monitor all three components of the magnetic field is unnecessary if the translation is possible only in one direction. However, thanks to the modularity of the presented design, it can be rather easily extended by adding two additional stepper motors to enable full three-dimensional magnetic field mapping and by modifying the part of the code that is responsible for the stepper motor control. This would not require any further modifications to the remaining parts of the software nor the hardware. The ability to measure the magnetic field along all three axes can be, however, used for assessing how well a set of coils has been assembled, and this information could guide  
Figure 4: **(a)** Stray field and **(b)** Hall sensor offset extracted from the same dataset as the one used to calculate the magnetic field of an anti-Helmholtz configuration shown in Figure 3a,c. In **(b)**, full circles (empty circles) correspond to the offset determined when the coils are turned off (turned on). Each data point is an average of 30 measurements. Magnetic field projections along the sensor axes \(x\), \(y\) and \(z\) are color-coded with red, green and blue, respectively. adjustments if deemed necessary. We illustrate this by reassembling the coils to minimize the variation in the field along axes \(x\) and \(z\), which are perpendicular to the direction of the sensor displacement. We run the current through the first coil already attached to the coils mount and adjust its orientation to maximize the \(y\) component of the field while minimizing the values along the remaining axes. The coil mount is then secured in place, and the sensor is moved (via GUI) to the expected location of the center of the second, which is then aligned in the exact same way as the first one. In this step, the current flows exclusively through the second coil.