# Nanoscale magnetic field mapping with a single spin scanning probe magnetometer

Loïc Rondin, Jean-Philippe Tetienne, Piernicola Spinicelli, Claudio Dal Savio, Khaled Karrai, Géraldine Dantelle, André Thiaville, Stanislas Rohart, Jean-François Roch, Vincent Jacques

► To cite this version:

Loïc Rondin, Jean-Philippe Tetienne, Piernicola Spinicelli, Claudio Dal Savio, Khaled Karrai, et al. Nanoscale magnetic field mapping with a single spin scanning probe magnetometer. Applied Physics Letters, 2012, 100 (15), pp.153118. 10.1063/1.3703128. hal-04944749

HAL Id: hal-04944749

https://hal.science/hal-04944749v1

Submitted on 27 Feb 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Nanoscale magnetic field mapping with a single spin scanning probe magnetometer

L. Rondin¹, J.-P. Tetienne¹, P. Spinicelli¹, C. Dal Savio², K. Karrai²,

G. Dantelle³, A. Thiaville⁴, S. Rohart⁴, J.-F. Roch¹, and V. Jacques¹*

¹Laboratoire de Photonique Quantique et Moléculaire,
Ecole Normale Supérieure de Cachan and CNRS UMR 8537, 94235 Cachan Cedex, France

²Attocube systems AG, Koeniginstrasse 11A RGB, Munich 80539, Germany

³Laboratoire de Physique de la Matière Condensée,
Ecole Polytechnique and CNRS UMR 7643, 91128 Palaiseau, France and

⁴Laboratoire de Physique des Solides, Université Paris-Sud and CNRS UMR 8502, 91405 Orsay, France

We demonstrate quantitative magnetic field mapping with nanoscale resolution, by applying a lock-in technique on the electron spin resonance frequency of a single nitrogen-vacancy defect placed at the apex of an atomic force microscope tip. In addition, we report an all-optical magnetic imaging technique which is sensitive to large off-axis magnetic fields, thus extending the operation range of diamond-based magnetometry. Both techniques are illustrated by using a magnetic hard disk as a test sample. Owing to the non-perturbing and quantitative nature of the magnetic probe, this work should open up numerous perspectives in nanomagnetism and spintronics.

The ability to map magnetic field distributions with high sensitivity and nanoscale resolution is of crucial importance for fundamental studies ranging from material science to biology, as well as for the development of new applications in spintronics and quantum technology [1–3]. In that context, an ideal scanning probe magnetometer should provide quantitative magnetic field mapping at the nanoscale under ambient conditions. In addition, the magnetic sensor should not introduce a significant magnetic perturbation of the probed sample.

Over the last decades, different roads have been taken towards ultra-sensitive detection of magnetic fields including superconducting quantum interference devices (SQUIDs) [1], semiconductor-based Hall probes [1] and optical magnetometers [2]. Even though extremely high sensitivity has been achieved with these devices, their spatial resolution remains limited at the micron-scale. Prominent approaches to reach nanoscale resolution are scanning-tunneling microscopy [4], mechanical detection of magnetic resonance [5], nanoSQUIDs [6], X-ray microscopy [7] and magnetic force microscopy (MFM) [8]. Since the latter technique operates under ambient conditions without any specific sample preparation, it is now routinely used for mapping magnetic field gradients around magnetic nanostructures. However, besides introducing an inevitable perturbation of the studied magnetic sample owing to the intrinsic magnetic nature of the probe [7], MFM does not provide quantitative information about the magnetic field distribution.

Here we follow a recently proposed approach to magnetic sensing based on optically detected electron spin resonance (ESR) [10]. It was shown that this method applied to a single nitrogen-vacancy (NV) defect in diamond could provide an unprecedented combination of spatial resolution and magnetic sensitivity under ambient conditions [6, 11, 12, 14]. The principle of the measurement

is similar to the one used in optical magnetometers based on the precession of spin-polarized atomic gases [2]. The applied magnetic field is evaluated by measuring the Zeeman shifts of the NV defect spin sublevels. In this article we demonstrate quantitative magnetic field mapping with nanoscale resolution, by applying a lock-in technique on the ESR frequency of a single NV defect placed at the apex of an atomic force microscope (AFM) tip. In addition, we report an all-optical magnetic imaging technique which is sensitive to large off-axis magnetic fields, and relies on magnetic-field-dependent photoluminescence (PL) of the NV defect sensor, induced by spin level mixing.

As depicted in Fig. 1(a), the scanning probe magnetometer combines an optical confocal microscope placed on top of a customized tuning-fork-based AFM (Attocube Systems), all operating under ambient conditions. The atomic-sized magnetic sensor was first engineered by grafting a diamond nanocrystal hosting a single NV defect at the end of the AFM tip [3, 4, 15]. After functionalization, a PL raster scan of the AFM tip shows an isolated spot at its apex (Fig. 1(b)), which corresponds to the collected light emitted by a single NV defect, as verified using photon correlation measurements (Fig. 1(c)).

The magnetic response of the probe was first characterized by sweeping the frequency of a driving microwave (MW) field through the spin resonance while recording the NV defect PL. Owing to spin dependent PL, ESR appears as a drop of the PL signal (Fig. 1(d)) [18]. The spin Hamiltonian of the NV defect reads as [6]

$$ \mathcal{H} = hDS_z^2 + hE(S_x^2 - S_y^2) + \hbar\gamma_e\mathbf{B} \cdot \mathbf{S}, \quad (1) $$

where h is the Planck constant, D and E are the zero-field splitting parameters, z is the NV defect quantization axis, γ_e the electron gyromagnetic ratio, and B the local magnetic field applied to the NV defect electron spin S = 1. For magnetic fields smaller than roughly 10 mT, i.e. such that $\hbar\gamma_e B \ll hD$, the quantization axis is fixed by the NV defect axis itself and the ESR frequencies are given by $\nu_R = D \pm \sqrt{(\gamma_e B_z / 2\pi)^2 + E^2}$, where B_z is the magnetic field amplitude along the NV axis. The spin

<footnote>*Electronic address: vjacques@lpqm.ens-cachan.fr</footnote>
<figure><img src="image_2.png" /><figcaption>FIG. 1: (a)-Simplified scheme of the scanning probe magnetometer. A 20 nm diamond nanocrystal hosting a single NV defect is grafted at the end of an AFM tip. A confocal microscope placed on top of the tip allows us both to excite and collect the NV defect spin-dependent PL. A microwave field (MW) is generated by an antenna approached in the vicinity of the NV defect. (b)-PL raster scan of the AFM tip showing a bright PL spot at its apex. White dashed lines indicate the shadow of the tip. (c)- Second-order autocorrelation function $g^{(2)}(\tau)$ recorded from the bright emission spot using a Hanbury Brown and Twiss interferometer. A strong anticorrelation effect, $g^{(2)}(0) \approx 0.1$, is observed at zero delay. More than $1 \times 10^5$ photons per second can be detected from the single NV defect when excited at saturation, with a signal-to-background ratio greater than 10. (d)-Optically detected ESR spectra recorded for different magnetic field magnitudes. For these experiments, the ESR contrast is $C \approx 12\%$, the linewidth $\Delta_{ESR} \approx 9$ MHz, and the average rate of detected photons $\mathcal{R} \approx 6 \times 10^4$ cnt/s, with an optical pumping power $P_{opt} = 300$ µW. The zero-field splitting parameters are $D = 2.87$ GHz and $E = 5$ MHz.</figcaption></figure>

orientation of the magnetic sensor was determined by recording ESR frequencies as a function of the orientation and the magnitude of a calibrated magnetic field [15].

The shot-noise-limited sensitivity to d.c. magnetic field $\eta_B$ is linked to the minimum detectable magnetic field along the NV axis $B_z^{min}$ during an acquisition time $\Delta t$ through the relation [19]

$$ \eta_B(\text{T}/\sqrt{\text{Hz}}) = B_z^{\min} \sqrt{\Delta t} \approx \frac{1}{\gamma_e} \times \frac{2\pi\Delta_{\text{ESR}}}{C\sqrt{\mathcal{R}}}, \quad (2) $$

where $\mathcal{R}$ is the rate of detected photons, $C$ the ESR contrast and $\Delta_{ESR}$ the associated linewidth (FWHM). From the optically detected ESR spectra shown in Fig. 1(d), we infer $\eta_B \approx 10$ µT/√Hz. We note that this sensitivity could be significantly enhanced by using pulsed-ESR techniques [14, 19] or by engineering a single NV defect in an ultra-pure diamond nanostructure [20].

The performances of the NV scanning probe magnetometer were characterized by mapping the magnetic field distribution created by a commercial magnetic hard disk. The magnetic bit geometry of this simple test sample is depicted in Fig. 2(a). As a first experiment, the magnetic sensor was approached at roughly 250 nm from the sample surface. At such a distance, the random orientation of the magnetic bits provides non-trivial magnetic field patterns with a typical magnetic field magnitude in the mT range [15]. The simplest way to map such a magnetic field distribution is borrowed from magnetic resonance imaging [6]. A MW field was applied with a fixed frequency corresponding to the zero-field ESR frequency. Iso-magnetic field images were then recorded by monitoring the NV defect PL while scanning the hard disk [6]. Dark areas corresponding to zero magnetic field lines can be observed (Fig. 2(b)). However, the image exhibits a varying contrast related to inhomogeneous background luminescence from the sample. This limitation can be overcome by measuring the difference of PL for two fixed MW frequencies applied consecutively at each point of the scan (Fig. 2(c)). In this dual iso-magnetic field image, the contrast is significantly improved since background luminescence from the sample is suppressed.

Even with two iso-magnetic field lines recorded at once, the information remains incomplete. To determine the full magnetic field distribution, an ESR spectrum could be measured for each pixel of the scan. However, since a few seconds are required to record such a spectrum with a reasonable signal-to-noise ratio, this method would be extremely slow. To circumvent this limitation, a lock-in method was developed in order to track the shift of the ESR frequency while scanning the magnetic sample [21]. This technique allows us to measure the strength of the magnetic field along the NV axis over the full scanning area with a typical sampling time of 110 ms [15]. As shown in Fig. 2(d), the complete magnetic field map is in clear agreement with iso-magnetic field experiments. In addition, we note that the recorded pattern can be qualitatively reproduced by numerical simulations, both in shape, size, and magnetic field amplitude [15]. This confirms the reliability of NV-based scanning probe magnetometry for imaging non trivial magnetic field distributions at the nanoscale within a reasonable data acquisition time.

From the pixel-to-pixel noise in Fig. 2(d), an uncertainty $\delta B \approx 27$ µT is deduced, which corresponds to a sensitivity $\eta_B^{\exp} \approx 9$ µT/√Hz, given the 110 ms sampling time [15]. This value is in good agreement with the shot-noise-limited value calculated using Eq. (2). Regarding spatial resolution, the magnetic field is experienced by
<figure><img src="image_3.png" /></figure>

FIG. 2: Measurements of the magnetic field distribution created by a commercial magnetic hard disk for a probe-to-sample distance $d = 250$ nm. All images correspond to $150 \times 138$ pixels, with a 13-nm pixel size. (a)-Geometry of the magnetic bits. (b)-Single iso-magnetic field image. Dark areas correspond to a null $|B_z|$ component and the red arrow indicates the NV defect axis, along which the magnetic field projection is measured. (c)-Dual iso-magnetic field image recorded by measuring the PL difference for two fixed MW frequencies applied consecutively. Dark (resp. bright) areas correspond to $|B_z| = 0$ (resp. $|B_z| = 0.5$ mT). (d)-Complete magnetic field distribution of the same area recorded by using the lock-in method. The panel on the right shows a line-cut taken along the white dashed line. For images (b), (c) and (d), the acquisition time per pixel is 5 ms, 60 ms and 110 ms respectively.

the NV defect electron spin wavefunction, resulting in a subnanometric probe volume. Experimentally the spatial resolution is rather limited by the pixel size (13 nm) and the positioning accuracy. The B-map depicted in Fig. 2(d) is thus assumed to closely follow the actual field distribution – within the noise $\delta B$ – with an overall spatial resolution of a few tens of nm. The line-cut in Fig. 2(d) further illustrates the ability to follow abrupt variations, up to $0.4$ mT ($\gg \delta B$) between two adjacent pixels, corresponding to a field gradient of $3 \times 10^4$ T/m. We emphasize the fact that no other instrument is able to quantitatively map magnetic field distributions with such a resolution.

Yet, many material science studies are interested in the sample magnetization **M** rather than the stray field **B**. In this context, the spatial resolution is limited not only by the probe volume but also by its distance to the sample. Here for instance, simulations indicate that the magnetic bits could be resolved by using a probe-to-sample distance smaller than 40 nm (Fig. 3(a)) [15]. However, the magnetic field amplitude then reaches several tens of mT, including a component $B_\perp$ orthogonal to the NV defect axis [15]. In such a situation, the quantization axis becomes determined by the local magnetic field rather than the NV defect axis. The eigenstates of the spin Hamiltonian are therefore given by superpositions of the $m_s = 0$ and $m_s = \pm 1$ spin sublevels, both in the ground and excited states [22]. As a result, optically-induced spin polarization and spin-dependent PL of the NV defect become inefficient, and the contrast of optically detected ESR vanishes. Magnetic field sensing using the previous techniques is thus not accessible in this high off-axis magnetic field regime ($> 10$ mT). However, it was also shown that the NV defect PL drops by roughly 30% when the magnitude of $B_\perp$ increases from 0 to approximately 30 mT [22, 23]. This property can be

exploited to perform a direct, microwave-free, magnetic field imaging using the single NV defect sensor.

Figure 3(b) shows a PL image recorded while scanning the magnetic sample without applying any microwave field. In this experiment, an AFM feedback loop is ap-

<figure><img src="image_4.png" /></figure>

FIG. 3: (a)-Simulation of the off-axis magnetic field component $B_\perp$ for a random distribution of bit magnetizations and a probe-to-sample distance $d = 30$ nm. (b)-PL image recorded with the NV scanning probe magnetometer operating in tapping mode, without applying any microwave field. The image corresponds to $200 \times 200$ pixels, with a 8-nm pixel size and a 20-ms acquisition time per pixel. (c)-Line-cut corresponding to the white dashed line in (b). A possible configuration of the bit magnetization is schematically depicted in (d).
plied to maintain the mean probe-to-sample distance to a constant value. Comparison with simulations (Fig. 3(a)) suggests that this distance is around 30 nm, limited by the diamond size and its position on the tip as well as by the tip oscillation. The PL image exhibits dark areas with a contrast greater than 20% which reveal the tracks and the bits of the magnetic hard disk. We note that the contrast depends on the field strength, which itself depends on the number of bits that are consecutively parallel. For instance, from the known bit-to-bit spacing of 55 nm, we deduce that the line-cut in Fig. 3(b) corresponds to a sequence 001100, where 0 and 1 denote the two possible bit magnetizations (Fig. 3(b)-(c)). Each bit inversion gives rise to a stray field that appears dark on the PL image. We thus demonstrate a mode of NV-based magnetic field sensing that does not require the use of microwave and is sensitive to the off-axis magnetic field magnitude.

Summarizing, quantitative nanoscale magnetic field

mapping with a sensitivity below $10 \mu\text{T}/\sqrt{\text{Hz}}$ was demonstrated using NV-based scanning probe magnetometry. Moreover, we reported a microwave-free magnetic imaging technique that extends the range of application of NV-based magnetometry to large off-axis magnetic fields. Improvement of the sensitivity using pulsed-ESR techniques [19], together with a better control of the NV-to-sample distance, should enable imaging of few-spins systems, which would be of great interest for fundamental studies in nanomagnetism and spintronics.

The authors acknowledge L. Mayer, O. Klein, F. Mazaleyrat, M. Lo Bue, P. Bertet, A. Slablab, T. Gacoin, F. Treussart, S. Huant, O. Mollet and O. Arcizet for fruitful discussions. This work was supported by the Agence Nationale de la Recherche (ANR) through the project DIAMAG, by C'Nano Île-de-France and by RTRA-Triangle de la Physique (contract 2008-057T).

[1] J. R. Kirtley, Rep. Prog. Phys. **73**, 126501 (2010).

[2] D. Budker and M. Romalis, Nature Phys. **3**, 227 (2007).

[3] L. Bogani and W. Wernsdorfer, Nature Mater. **7**, 179-186 (2008).

[4] S. Heinze, M. Bode, A. Kubetzka, O. Pietzsch, X. Nie, S. Blgel, R. Wiesendanger, Science **288**, 1805 (2000).

[5] D. Rugar, R. Budakian, H. J. Mamin, and B. W. Chui, Nature **430**, 329-332 (2004).

[6] A. Finkler, Y. Segev, Y. Myasoedov, M. L. Rappaport, L. Neeman, D. Vasyukov, E. Zeldov, M. E. Huber, J. Martin and A. Yacoby Nano Lett. **10**, 1046-1049 (2010).

[7] W. Chao, J. Kim, S. Rekawa, P. Fischer, and E. H. Anderson, Opt. Exp. **17**, 17669 (2009).

[8] Y. Martin and H. K. Wickramasinghe, Appl. Phys. Lett. **50**, 1455 (1987).

[9] J. M. Garcia, A. Thiaville, J. Miltat, K. J. Kirk, J. N. Chapman, and F. Alouges, Appl. Phys. Lett. **79**, 656 (2001).

[10] B. M. Chernobrod and G. P. Berman, J. Appl. Phys. **97**, 014903 (2005).

[11] C. L. Degen, Appl. Phys. Lett. **92**, 243111 (2008).

[12] J. M. Taylor, P. Cappellaro, L. Childress, L. Jiang, D. Budker, P. R. Hemmer, A. Yacoby, R. Walsworth and M. D. Lukin, Nature Phys. **4**, 810-816 (2008).

[13] G. Balasubramanian, I. Y. Chan, R. Kolesov, M. Al-Hmoud, J. Tisler, C. Shin, C. Kim, A. Wojcik, P. R. Hemmer, A. Krueger, T. Hanke, A. Leitenstorfer, R. Bratschitsch, F. Jelezko and J. Wrachtrup, Nature **455**, 648-651 (2008).

[14] J. R. Maze, P. L. Stanwix, J. S. Hodges, S. Hong, J. M. Taylor, P. Cappellaro, L. Jiang, M. V. Gurudev Dutt, E.

Togan, A. S. Zibrov, A. Yacoby, R. L. Walsworth and M. D. Lukin, Nature **455**, 644-647 (2008).

[15] See supplementary material at [URL will be inserted by AIP] for experimental details and numerical simulations of the magnetic field distribution above the magnetic hard disk.

[16] A. Cuche, A. Drezet, Y. Sonnefraud, O. Faklaris, F. Treussart, J.-F. Roch, and S. Huant, Opt. Exp. **17**, 19969 (2009).

[17] L. Rondin, G. Dantelle, A. Slablab, F. Grosshans, F. Treussart, P. Bergonzo, S. Perruchas, T. Gacoin, M. Chaigneau, H.-C. Chang, V. Jacques and J.-F. Roch, Phys. Rev. B **82**, 115449 (2010).

[18] A. Grüber, A. Drabenstedt, C. Tietz, L. Fleury, J. Wrachtrup, and C. von Borczyskowski, Science **276**, 2012-2014 (1997).

[19] A. Dréau, M. Lesik, L. Rondin, P. Spinicelli, O. Arcizet, J.-F. Roch and V. Jacques, Phys. Rev. B, **84** 195204 (2011).

[20] P. Maletinsky, S. Hong, M.S. Grinolds, B. Hausmann, M.D.Lukin, R.-L. Walsworth, M. Loncar and A. Yacoby, Preprint arXiv:1108.4437.

[21] R. S. Schoenfeld and W. Harneit, Phys. Rev. Lett. **106**, 030802 (2011).

[22] R. J. Epstein, F. M. Mendoza, Y. K. Kato, and D. D. Awschalom, Nature Phys. **1**, 94-98 (2005).

[23] N. D. Lai, D. Zheng, F. Jelezko, F. Treussart, and J.-F. Roch, Appl. Phys. Lett. **95**, 133101 (2009).
# I. SUPPLEMENTARY METHODS

## A. Experimental setup

The experimental setup combines an atomic force microscope (AFM) and a confocal optical microscope (AFM/CFM, Attocube System) as shown in Fig. 4). Two sets of piezoelectric actuators and scanners are used for positioning the sample and the AFM tip. The AFM cantilever is an Akiyama-Probe (Nanosensors) corresponding to a quartz tuning fork equipped with a micromachined silicon cantilever. The cantilever ends with a sharp tip whose nominal curvature radius is ≈ 15 nm. A nanodiamond hosting a single nitrogen-vacancy (NV) defect is placed at the end of the tip as explained in the next section.

A continuous laser source operating at 532 nm wavelength (Spectra-Physics Excelsior) is tightly focused at the end of the AFM tip through a ×100 microscope objective with a 0.9-numerical aperture and a 1-mm working distance (Olympus, MPLFLN100X). The photoluminescence (PL) emitted by a single NV defect placed at the apex of the tip is collected by the same objective and spectrally filtered from the remaining pump light using a dichroic beam splitter and a band-pass filter (Semrock, 697/75 BP). Following standard confocal detection scheme, the collected light is then focused onto a 50-µm diameter pinhole and directed to silicon avalanche photodiodes (Perkin-Elmer, SPCM-AQR-14) operating in the single-photon counting regime. Independently of the AFM scanners, precise positioning of the NV defect at the focus of the confocal microscope is achieved by scanning the laser beam with a fast steering mirror (Newport, FSM-300-02) combined with a pair of telecentric lenses. The focal length is adjusted by using the piezoelectric positioner of the AFM tip.

The unicity of the emitter was checked by using a Hanbury Brown and Twiss (HBT) interferometer consisting of two avalanche photodiodes placed on the output ports of a 50/50 beamsplitter. The HBT detection system is associated with a fast multichannel analyser (Picoquant, TimeHarp 300) for recording the histogram of time delays between two consecutive single-photon detections. After normalization to a Poissonnian statistics, the recorded histogram is equivalent to a measurement of the second-order autocorrelation function $g^{(2)}(\tau)$ [1]. The observation of an anticorrelation effect at zero time delay, $g^{(2)}(0) < 0.5$, is the signature that a single NV defect is addressed (see Fig. 1(c) of the main text).

For the electron spin resonance (ESR) measurements, a microwave synthesizer (Rohde & Schwarz, SMR20) is

<figure><img src="image_5.png" /><figcaption>FIG. 4: Schematic of the experimental setup, showing both the confocal optical microscope (upper part) and the tuning-fork based AFM microscope (lower part). L stands for lens, F for filter, $\lambda/2$ for half-wave plate, P for polarizer, BS for beamsplitter, DBS for dichroic beamsplitter, M for mirror, FSM for fast steering mirror, PH for pinhole and APD for silicon avalanche photodiode. $F_1$ (resp. $F_2$) is a 10 nm (resp. 75nm) width interference filter centered at 532 nm (resp. 697 nm).</figcaption></figure>
followed by a power amplifier (Mini-Circuits, ZHL-42) and connected to a 20-µm-diameter copper wire directly spanned on the sample surface.

Scanning probe magnetometry is performed by monitoring the spin-dependent NV defect PL while scanning the magnetic sample. The tip-to-sample distance is adjusted using the piezoelectric scanner of the sample. For tapping mode operation, usual tuning-fork based AFM operation is used with a feedback loop adjusting the tip-to-sample distance.

## B. Grafting a single NV defect at the end of the AFM tip

We started from commercially available diamond nanocrystals (SYP 0.05, Van Moppes SA, Geneva). Such nanocrystals are produced by milling type-Ib high-pressure high-temperature diamond crystals with a high nitrogen content ([N] ≈ 200 ppm). The formation of NV defects was carried out using high energy (13.6 MeV) electron irradiation followed by annealing at 800°C under vacuum during two hours. The electron irradiation creates vacancies in the diamond matrix while the annealing procedure activates the migration of vacancies to intrinsic nitrogen impurities, leading to NV defect bonding. After annealing, the irradiated nanocrystals were oxidized in air at 550°C during two hours. This procedure reduces the size of the nanodiamonds [2] and leads to an efficient charge state conversion of the created NV defects into the negatively-charged state [3]. After sonication and washing with distilled water, aqueous colloidal solutions of dispersed nanodiamonds, with a mean size of 20 nm, were obtained and finally deposited by spin-coating onto a silica coverslip.

A nanodiamond (ND) hosting a single NV defect was grafted at the apex of the AFM tip following the method introduced by Cuche et al. [4, 5]. The tip was first dipped in a solution of poly-L-lysine (EMS, molecular weight 30000-70000 u) for a few minutes. The tip as well as the sample of dispersed nanodiamonds were then mounted in the experimental set-up, and the NDs were optically characterized. Once a ND hosting a single negatively-charged NV defect was found, the sample was scanned with the AFM tip in tapping mode in a small area around the preselected ND. Electrostatic interactions between the polymer and the ND allow reproducible and robust grafting of the nanodiamond at the apex of the AFM tip.

## C. Real-time tracking of the ESR frequency

The lock-in method allowing to track the shift of the ESR frequency $\nu_R$ while scanning the magnetic sample is described in Fig. 5. Two slightly different microwave frequencies $\nu_+$ and $\nu_-$, defined by $\nu_\pm = \bar{\nu} \pm \Delta\nu/2$, are applied consecutively and the PL difference $D(\bar{\nu}) = S(\nu_+) - S(\nu_-)$ is computed (Fig. 5(a) and (b)). This signal can be used as an error signal for tracking the ESR frequency [21]. Indeed, if $\bar{\nu} = \nu_R + \delta$ with $\delta$ smaller than the ESR linewidth (FWHM), the error signal is at first order proportional to the frequency detuning $\delta$, i.e. to the magnetic field variation (Fig. 5(b)). Monitoring $D(\bar{\nu})$ thus enables quantitative magnetic field mapping by continuously tracking the ESR frequency and measuring the frequency detuning from point to point, with a typical sampling time of 100 ms. Reliability of this method is demonstrated by monitoring in real-time the magnetic field created by an AC current passing through a coil with a frequency up to 1 Hz, as shown in Fig. 5(c).

## D. Estimation of the magnetic field sensitivity

Since the magnetic stray field of the investigated hard disk is a priori not known, the measured field map (Fig. 2(c) in the main text) cannot be directly compared to theory. However, the field is assumed to vary slowly with respect to the spatial sampling, i.e. the pixel size, so that high-frequency components are attributed to measurement noise. Therefore, we introduce a pixel-to-pixel noise to estimate the experimental error $\delta B$. If $\{B_{i,j}\}$ is the matrix corresponding to the magnetic field map, with $1 \le i \le p$ and $1 \le j \le q$, then $\delta B$ can be defined as the standard deviation

$$ \delta B^2 = \frac{\sum_{i=1}^{p-1} \sum_{j=1}^{q} \left( \frac{B_{i+1,j} - B_{i,j}}{2} \right)^2 + \sum_{i=1}^{p} \sum_{j=1}^{q-1} \left( \frac{B_{i,j+1} - B_{i,j}}{2} \right)^2}{(p-1) \times q + p \times (q-1)} \quad (3) $$

which takes into account the pixel-to-pixel noise along both axis. For Fig. 2(c) of the main text, for which $p = 138$ and $q = 150$, we find $\delta B = 27 \ \mu\text{T}$. Given the acquisition time per pixel $\Delta t = 110$ ms, an experimental field sensitivity $\eta_B^{exp} = \delta B \sqrt{\Delta t} = 9 \ \mu\text{T}/\sqrt{\text{Hz}}$ is obtained.
<figure><img src="image_6.png" /><figcaption>FIG. 5: Real-time tracking of the ESR frequency. (a)-Optically detected ESR spectrum $S(ν)$ and schematic of the field-frequency lock-in. (b)-Error signal $D(ν̄)$ used for the feedback loop. Provided that $δ < Δ_{ESR}$, $D(ν̄) = A × δ$ at first order, where A is experimentally determined and corresponds to the first derivative of $D(ν̄)$ evaluated at the resonance frequency $ν_R$. For each cycle of the tracking algorithm, $D(ν̄)$ around the former ESR frequency is measured and the local magnetic field $B_z$ is deduced. (c)-Real-time measurement of the magnetic field created by a 0.5 Hz AC current in a coil with a sampling rate of 150 ms. Parameters of the feedback loop are $Δν = 5$ MHz and $A = 5 × 10^3$ cnts.s⁻¹.MHz⁻¹.</figcaption></figure>

E. Determination of the NV defect axis

The NV defect axis, characterized by the unit vector $\hat{z}$, can be determined by measuring the ESR spectrum while applying a static magnetic field along several well-chosen directions. Denoting $θ$ and $φ$ the polar and azimuthal angles of the applied magnetic field in the reference frame $xyz$ of the NV defect, the diagonalization of the electron spin Hamiltonian (equation (1) of the main text) yields to the relation [6]

$$ \Delta = \frac{7D^3 + 2(\nu_1 + \nu_2)(2(\nu_1^2 + \nu_2^2) - 5\nu_1\nu_2 - 9E^2) - 3D(\nu_1^2 + \nu_2^2 - \nu_1\nu_2 + 9E^2)}{9(\nu_1^2 + \nu_2^2 - \nu_1\nu_2 - D^2 - 3E^2)}, \quad (4) $$

where $ν_1$ and $ν_2$ are the Zeeman-shifted ESR frequencies, $Δ = D \cos 2θ + 2E \cos 2φ \sin^2 θ$ while $D$ and $E$ are the zero-field splitting parameters of the NV ground-state electron spin. Since $E \ll D$, one can use the approximation $Δ ≈ D \cos 2θ$.

For a magnetic field applied along a given direction $\hat{K}$, Eq. (4) gives the angle $|θ_K|$ between $\hat{z}$ and $\hat{K}$. Repeating the measurement for two other directions of the magnetic field enables to completely determine $\hat{z}$. Since the magnetic images presented in the main manuscript are $XY$ maps of the magnetic field component $|B_z|$, it is important to know $\hat{z}$ with respect to the reference frame $XYZ$ of the laboratory. The orientation of the NV defect used in Fig. 2 and 3 of the main text was determined following the latter method. Fig. 6(b) shows the evolution of the measured resonance frequencies $ν_1$ and $ν_2$ as a function of a static magnetic field produced by two coils in an Helmholtz configuration. This field was first aligned along the $X$-axis (filled circles) and then along the $Y$-axis (open circles). From these
measurements and Eq. (4), the angles $|\theta_X| = 37 \pm 1^\circ$ and $|\theta_Y| = 53 \pm 1^\circ$ were obtained. As $|\theta_X| + |\theta_Y| = 90^\circ$, one deduces that $\hat{z}$ lies in the $XY$ plane. The actual orientation of the NV axis in the reference frame $XYZ$ is illustrated in Fig. 6(a). The other orientation compatible with the set ($|\theta_X|, |\theta_Y|$) was ruled out by a measurement along a third direction.

<figure><img src="image_7.png" /></figure>

FIG. 6: Measurement of the NV defect orientation using Helmholtz coils. (a)-Measuring the ESR spectrum while applying a static magnetic field along $X$ (resp. $Y$) gives access to the angle $|\theta_X|$ (resp. $|\theta_Y|$) between the NV axis (red arrow) and the $X$-axis (resp. $Y$-axis). (b)-ESR frequencies $\nu_1$ and $\nu_2$ as a function of the magnetic field magnitude. The filled (resp. open) black circles are the experimental data for a static magnetic field applied along $X$ (resp. $Y$). The angles $|\theta_X|$ and $|\theta_Y|$ were estimated using Eq. (4). The solid lines are the theoretical curves using the full diagonalization of the spin Hamiltonian and the calculated values of $|\theta_X|$ and $|\theta_Y|$, considering a field oriented along $X$ (green lines) and $Y$ (blue lines), respectively.

## II. MODELLING OF THE MAGNETIC FIELD DISTRIBUTION ABOVE THE HARD DISK

The magnetic sample used for the demonstration of magnetic field mapping is a piece of a commercial magnetic hard disk (Maxtor, 20 Gb). The geometry of the magnetic bits is depicted in Fig. 7. AFM topography of the sample allows to infer the geometrical orientation of the bits since grooves imprinted by the read/write head indicate the direction of the tracks (Fig. 7(a)). This information is used to determine the NV orientation with respect to the bits orientation.

The hard disk was modeled as an array of uniformly magnetized parallelepipeds (the ‘bits’). The dimensions of each ‘bit’ are $2a = 40$ nm, $2b = 400$ nm and $2c = 10$ nm, along $X$, $Y$ and $Z$, respectively, and their magnetization is $\mathbf{M} = \pm M_s \hat{X}$ depending whether the bit is at ‘0’ or ‘1’ (Fig. 7(b)-(c)). $M_s$ is the average magnetization of the ferromagnetic material. Typical value for the studied hard disk is $\mu_0 M_s = 0.5$ T where $\mu_0$ is the permeability of free space. The pitch of the array is $55$ nm along $X$ and $450$ nm along $Y$.

<figure><img src="image_8.png" /></figure>

FIG. 7: Modelling the magnetic hard disk. (a)-AFM Topography of a $2 \times 2$ µm area of the hard disk. (b)-Model used for the 20 Gb hard disk. Each bit is magnetized along $\pm \hat{X}$ and has dimensions 400 x 40 x 10 nm. The bits are spaced by 450 nm along $Y$ (track width) and $55$ nm along $X$. (c)- A parallelepiped uniformly magnetized along $X$ is equivalent to a magnetic “capacitor” with two charged surfaces located at $X = \pm a$.
The magnetic field distribution produced by a single bit (Fig. 7(c)) can be calculated using magnetostatics theory. Outside the parallelepiped, the three components of the magnetic field read as

$$B_X = -\frac{\mu_0 M_s}{4\pi} \sum_{i=\pm 1} \sum_{j=\pm 1} \sum_{k=\pm 1} ijk \tan^{-1} \frac{(Y+jb)(Z+kc)}{(X+ia)\sqrt{(X+ia)^2+(Y+jb)^2+(Z+kc)^2}} \quad (5)$$

$$B_Y = -\frac{\mu_0 M_s}{8\pi} \ln \left[ \prod_{i=\pm 1} \prod_{j=\pm 1} \prod_{k=\pm 1} \left( \frac{(Z+kc) - \sqrt{(X+ia)^2+(Y+jb)^2+(Z+kc)^2}}{(Z+kc) + \sqrt{(X+ia)^2+(Y+jb)^2+(Z+kc)^2}} \right)^{ijk} \right] \quad (6)$$

$$B_Z = -\frac{\mu_0 M_s}{8\pi} \ln \left[ \prod_{i=\pm 1} \prod_{j=\pm 1} \prod_{k=\pm 1} \left( \frac{(Y+jb) - \sqrt{(X+ia)^2+(Y+jb)^2+(Z+kc)^2}}{(Y+jb) + \sqrt{(X+ia)^2+(Y+jb)^2+(Z+kc)^2}} \right)^{ijk} \right] \quad (7)$$

The magnetic fields produced by each bit of the array were then summed up in order to compute the whole field distribution above the hard disk. Since the exact distribution of magnetic bit orientations is unknown, we compute the magnetic field distributions along X, Y and Z directions for a random distribution of magnetic bits (Figure 8(a)). Figure 8(b) indicates the magnetic field distribution at 250 nm from the hard disk, once projected along the axis of the NV defect used in the scanning-probe magnetometry experiments. The magnetic field follows rounded non trivial patterns with characteristics size and amplitude similar to the one observed experimentally (Fig. 2(c) of the main text). We note that the magnetic field distribution at another distance or along the Y axis follows a clearly different

<figure><img src="image_9.png" /><figcaption>FIG. 8: (a)-Calculated magnetic field distributions above a randomly written area of the hard disk. The three components $B_X$, $B_Y$ and $B_Z$ (columns 1, 2 and 3, respectively) are calculated at various distances $d$ from the surface, from 10 nm to 250 nm (from bottom to top). The plots are 1.8 x 1.8 µm in size, but the array used for the calculation is 9 times larger (5.4 x 5.4 µm) in order to avoid edge effects. (b)-Simulation of the magnetic field created by a random distribution of bit magnetizations for $d = 250$ nm, once projected along the NV defect axis used in the experiments described in the main text of the article. The magnetic bits are oriented as shown in the AFM topography (Fig. 4(a)).</figcaption></figure>
pattern.

[1] R. Brouri, A. Beveratos, J.-P. Poizat, and P. Grangier, Opt. Lett. **25**, 1294 (2000).

[2] T. Gaebel, C. Bradac, J. Chen, P. Hemmer, and J. R. Rabeau, preprint arXiv:1104.5075 (2011).

[3] L. Rondin et al., Phys. Rev. B **82**, 115449 (2010).

[4] A. Cuche et al., Opt. Exp. **17**, 19969 (2009).

[5] A. Cuche, A. Drezet, J.-F. Roch, F. Treussart, and S. Huant, J. Nanophoton. **4**, 043506 (2010).

[6] G. Balasubramanian et al., Nature **455**, 648-651 (2008).

[7] J. M. Garcia, A. Thiaville, J. Miltat, K. J. Kirk, J. N. Chapman, and F. Alouges, Appl. Phys. Lett. **79**, 656 (2001).