The basic principle involves placing a sample in a strong magnetic field, causing nuclei with a magnetic moment, such as hydrogen or carbon-13, to align with the field. When these aligned nuclei are exposed to a pulse of radiofrequency radiation, they absorb energy and resonate. As they return to their lower energy states, they emit radiofrequency signals, which are recorded and transformed into an NMR spectrum. This spectrum provides information about the chemical environment of the nuclei.