Recently, urban mobility has become one of the most pressing issues in today's cities, and it must be addressed with caution. The exponential increase in the number of cars has a negative influence on the transportation system that most communities rely on. One of the most important aspects of transportation system is traffic control, which is reliant on a series of coordinated traffic lights. Smart traffic lights not only can receive and analyses the real time traffic data but also can help to alleviate traffic congestion by accurately predicting the waiting time for each traffic lane at the intersections. This can help to enhance traffic flow and, as a result, the overall performance of the transportation system. The proposed Smart Traffic System (STS) not only an automated IoT based traffic measuring system but it also calculates the ideal waiting time for each traffic lane. Calculating the optimal waiting time of each lane of the intersections can reduce the average waiting time. The objective is to provide accurately real-time traffic updates on traffic congestion according to the size of vehicles and their location relative to the traffic lights. Urgent cases for emergency vehicles also has been taken into consideration. Ultrasonic sensors and a lateral scanning approach are employed in the proposed STS which is suitable for using on real traffic roads in various roadway environments. STS adjusted to accurately measure traffic volumes according to the size of vehicles and their locations relative to the traffic light in real time. A prototype is implemented to evaluate the feasibility of the model. Simulation results show good accuracy in vehicles detection, low relative error in road occupancy estimation, the least delay, and highest throughput compared to other works.