A one-compartment photofuel cell with two photoelectrodes was combined with a capacitor to develop a portable self-powered sensor for sulfadimethoxine (SDM) detection. The developed sensor was applied to the assay of SDM in veterinary drug samples with desirable accuracy and precision.