Two-stage microbial fuel cell (MFC) and membrane bioreactor (MBR) system for enhancing wastewater treatment and resource recovery based on MFC as a biosensor.