DNA nanomachines are synthetic assemblies that switch between defined molecular conformations upon stimulation by external triggers. Previously, the performance of DNA devices has been limited to in vitro applications. Here we report the construction of a DNA nanomachine called the I-switch, which is triggered by protons and functions as a pH sensor based on fluorescence resonance energy transfer (FRET) inside living cells. It is an efficient reporter of pH from pH 5.5 to 6.8, with a high dynamic range between pH 5.8 and 7. To demonstrate its ability to function inside living cells we use the I-switch to map spatial and temporal pH changes associated with endosome maturation. The performance of our DNA nanodevices inside living systems illustrates the potential of DNA scaffolds responsive to more complex triggers in sensing, diagnostics and targeted therapies in living systems.