Cameras, millimeter-wave radars, and lidars are widely deployed on smart roads to obtain personalized vehicle trajectories for advanced traffic control and risk avoidance. However, these asynchronous roadside sensors need to be spatiotemporally calibrated accurately before they are put into service. Traditional manual manipulation methods are inefficient and will affect traffic operation and safety. A rapid and convenient method has become essential under the trend that large amounts of roadside sensors need to be tested and calibrated frequently. As more and more connected and automated vehicles (CAVs) flood the smart roads, this paper proposes a novel spatiotemporal calibration framework using the positioning and perception data of CAVs. First, a trajectory matching algorithm is designed using motion feature and point feature histogram sequences as the descriptors, which can determine the approximate spatiotemporal correspondence for the CAV from the roadside trajectory dataset. An optimization method is then formulated to tune transformation parameters through the Gaussian Process trajectory representation and Gauss-Newton algorithms, considering the sampling frequency deviation and measurement noise. Based on numerical analysis via the NGSIM and HighD datasets, it is shown that the proposed calibration method can significantly reduce transformation errors and perform robustly in different scenarios. The feasibility and practicability of the calibration method are further validated through real-world experiments at Tongji University and on the Donghai Bridge in Shanghai, China. This study provides an economical and practical way for spatiotemporal calibration of roadside sensors in an era of CAVs.