A sensor for the in vivo detection of glucose comprises:components of an assay for glucose, a readout of which is a detectable optical signal which can be interrogated transcutaneously by external optical means when the sensor is implanted in vivo anda shell of biodegradable material encapsulating the assay components while allowing analyte to contact the assay components, wherein the biodegradable material comprises a co-polymer having hydrophobic and hydrophilic units.A method of preparing such a sensor preferably comprises coacervation, solvent evaporation and/or extraction, spray drying, spray coating, spray chilling, rotary disk atomisation, fluid bed coating, coextrusion and/or pan coating.A method of detecting glucose using such a sensor suitably comprises implantation of the sensor into the skin of a mammal, transdermal detection or measurement of glucose using external optical means and degradation of the biodegradable material.