An efficient scheme for detecting charge numbers of nearby charged body is presented in the cavity optoelectromechanical system. This is realized by means of the sensitive relationship between the charge number and the measured photon number. The proposed scheme is feasible with experimentally accessible values and is applicable to precision measurement of electrical charge.