Piezoelectric sensors collect data by converting mechanical energy into electrical energy. The sensor is mounted in a groove cut into road's surface.
When a car drives over the piezoelectric sensor, it squeezes it and causes an electric potential - a voltage signal. The size of the signal is proportional to the degree of deformation. When the car moves off, the voltage reverses.
This change in voltage can be used to detect and count vehicles.
The counting device which is connected to the sensors is housed in an enclosure by the side of the road. Data may be collected locally via an Ethernet or RS232 connection to a laptop, or may be transmitted by modem.
Piezoelectric traffic counter by the side of the road
Photo by Louis van Senden [CC BY-SA 4.0]