In one embodiment, a stylus receives a first signal from a first electrode of the stylus, the stylus being operable to communicate wirelessly with a device through a touch sensor of the device; receives a second signal from a second electrode of the stylus, the second signal being a reference signal and the second electrode being a reference electrode; and compares the first signal with the second signal.