SAN FRANCISCO  The secret to finding the perfect parking spot in congested cities is usually just a matter of luck. But drivers here will get some help from an innocuous tab of plastic that will soon be glued to the streets.

This fall, San Francisco will test 6,000 of its 24,000 metered parking spaces in the nation’s most ambitious trial of a wireless sensor network that will announce which of the spaces are free at any moment.

Drivers will be alerted to empty parking places either by displays on street signs, or by looking at maps on screens of their smartphones. They may even be able to pay for parking by cellphone, and add to the parking meter from their phones without returning to the car.

Solving the parking mess takes on special significance in San Francisco because two years ago a 19-year-old, Boris Albinder, was stabbed to death during a fight over a parking space.