Control of pH in bioelectronics and applications