The invention discloses a road roller with a road surface flatness detection function. The road roller comprises a road roller frame, a connecting frame is installed at the bottom end of the road roller frame, a mud scraping work box is fixedly installed at the end, away from the road roller frame, of the connecting frame, and a first pneumatic push rod is connected to the inner wall of the mud scraping work box in a screwed mode; and a first connecting rod is installed at the output end of the first pneumatic push rod, a moving block is connected to the end, away from the first pneumatic pushrod, of the first connecting rod in a screwed mode, and a fixing plate penetrates through the portion, located on the inner wall of the mud scraping work box, of the inner wall of the moving block. According to the road roller with the road surface flatness detection function, the moving block is arranged; the first pneumatic push rod works to drive the first connecting rod to rotate through a second connecting rod, the rotating angle of the first connecting rod is 45 degrees, the first connecting rod and the second connecting rod are equal in length, and the first connecting rod drives a mudscraping rod to move along a moving groove in a fixed plate through the moving block; the mud scraping rod drives a mud scraping plate to move; and the operation of adjusting the gap between the mudscraping plate and a roller is realized.