The dynamic management of traffic light cycles is a really interesting research issue considering modern technologies, which can be used in order to optimise road junctions and then improve living conditions of the roads. Wireless sensor networks represent the most suitable technology, as they are easy to deploy and manage. The data relating to road traffic flows can be detected by the sensor network and then processed through the innovative approach, proposed in this work, in order to determine the right green times at traffic lights. Although wireless sensor networks are characterized by very low consumption devices, the continuous information transmission reduces the life cycle of the whole network. To this end, the proposed architecture provides a technique to power the sensor nodes based on piezoelectric materials, which allow producing potential energy taking advantage of the vibration produced by the passage of vehicles on the road.