Semiconductor p–n junctions provide rectification behaviour and act as building blocks in many electronic devices. However, the typical junction configuration restricts the potential functionalities of devices. Here we report a light-detection electrochemical cell that is based on vertically aligned p-AlGaN/n-GaN p–n heterojunction nanowires in an electrolyte environment. After decorating the nanowires with platinum nanoparticles, the cell exhibits a photoresponse in which the photocurrent polarity is reversed depending on the wavelength of light. In particular, illumination of the device at two different wavelengths (254 nm and 365 nm) triggers different redox reactions at the nanowire/electrolyte interface, inducing polarity reversal of the photocurrent. The device offers a responsivity of up to −175 mA W−1 at 254 nm and 31 mA W−1 at 365 nm, both at 0 V. A light-detection electrochemical cell that is based on vertically aligned p–n heterojunction nanowires in an electrolyte environment can exhibit a photoresponse in which the polarity is reversed depending on the wavelength of light.