Although implanted medical devices (IMDs) offer many benefits, they are susceptible to bacterial colonization and infections. Such infections are difficult to treat because bacteria could form biofilms on the implant surface, which reduce antibiotics penetration and generate local dormant regions with low pH and low oxygen. In addition, these infections are hard to detect early because biofilms are often localized on the surface. Herein, an optical sensor film is developed to detect local acidosis on an implanted surface. The film contains both upconverting particles (UCPs) that serve as a light source and a pH indicator that alters the luminescence spectrum. When irradiated with 980 nm light, the UCPs produce deeply penetrating red light emission, while generating negligible autofluorescence in the tissue. The basic form of the pH indicator absorbs more of upconversion luminescence at 661 nm than at 671 nm and consequently the spectral ratio indicates pH. Implanting this pH sensor film beneath 6–7 mm of porcine tissue does not substantially affect the calibration curve because the peaks are closely spaced. Furthermore, growth of Staphylococcus epidermidis on the sensor surface causes a local pH decrease that can be detected non-invasively through the tissue.