The primary, reliable and most common traffic light sensors are induction loops. Induction loops are coils of wire that have been embedded in the surface of the road to detect changes in inductance, then conveying them to the sensor circuitry in order to produce signals.
Traffic lights commonly detect vehicles using digital sensors mounted on the lights themselves, or through an inductive loop embedded in the surface of the road. Both methods allow the traffic system to keep tabs on stopped vehicles occupying the intersection and help traffic to flow smoothly.
Perhaps the most well-known branding for these types of devices is called Opticom. Essentially, the tech works by detecting a specific pattern of infrared light emitted by the Mobile Infrared Transmitter (MIRT) installed in a police car, fire truck, or ambulance when the MIRT is switched on.
Your car interrupts the flow of electricity and sends a signal to the light system to change. This is why motorcycles and bicycles sometimes won't change the light - not because of weight but rather because of their size that is not sufficient to interrupt the electrical loop.