Structural DNA nanotechnology seeks to build synthetic molecular machinery from DNA. DNA nanomachines are artificially designed assemblies that switch between defined conformations in response to an external cue. Though it has proved possible to create DNA machines and rudimentary walkers, the function of such autonomous DNA-based molecular devices has not yet been achieved inside living organisms. Here we demonstrate the operation of a pH-triggered DNA nanomachine inside the nematode Caenorhabditis elegans. The nanomachine uses fluorescence resonance energy transfer to effectively map spatiotemporal pH changes associated with endocytosis in wild type as well as mutant worms, demonstrating autonomous function within the organismal milieu in a variety of genetic backgrounds. From this first demonstration of the independent functionality of a DNA nanomachine in vivo, we observe that rationally designed DNA-based molecular devices retain their in vitro functionality with quantitative precision. This positions DNA nanodevices as exciting and powerful tools to interrogate complex biological phenomena. Many synthetic DNA nanomachines have been developed and demonstratedin vitro, but their use in living organisms has not been reported. Now, a DNA nanomachine, the I-switch, is used to map spatiotemporal pH changes associated with endosomal maturation within coelomocytes of Caenorhabditis elegans.