This study proposes a power source that operates between acidic and basic reservoirs under sunlight to treat acidic wastewater sustainably. We present a strategy that harvests energy from an ionic gradient associated with acidic solution neutralization and water photo-oxidation under UV light. In contrast to neutralization batteries, these photo-assisted acid-base machines operate with an interconnected battery ensemble comprising (A) a photo-assisted acid battery composed of photo-anode (TiO2) for water photo-oxidation and a selective self-assembled cathode consisting of poly(3,4-ethylenedioxythiophene) and phosphomolybdic acid for proton insertion; (B) a proton-alkali ion battery composed of the self-assembled electrode for proton deinsertion and a cathode made of copper hexacyanoferrate for potassium ion electro-insertion, which can be used as portable or stationary power source; (C) an alkali ion-air battery composed of the polycyanometalate for potassium ion deinsertion and a platinum cathode for the oxygen reduction reaction (ORR). This ensemble avoids reverse water splitting reactions and dismisses the need for external electrical power sources, which increases machine efficiency. Experiments demonstrate that acidic solution neutralization from pH = 1.3 to pH = 6.0 can harvest 102.6 kJ per mol of electro-inserted proton: this process converts energy from sunlight and from ionic gradient into electrical work. Therefore, the strategy presented here may contribute to environmental preservation and sustainable growth.