The invention discloses a new energy vehicle charging pile capable of automatically detecting a cable and having a warning function, which comprises a charging pile body, charging holes are formed in the centers of the two sides of the charging pile body, charging heads are inserted into the inner cavities of the charging holes, and the sides, away from the charging pile body, of the charging heads communicate with the cable; and a current sensor is embedded in the surface of the cable. Through cooperation of a motor, a gear, a rack plate and a moving seat, a user can conveniently drive the moving seat to move left and right, so that an alarm is driven to move left and right through a swing rod, the warning range of the alarm is greatly enlarged, and the user can conveniently overhaul a fault in time; and through cooperation of a supporting plate, a first movable seat, an air cylinder, a second movable seat, a third movable seat and a swing rod, a user can conveniently utilize the air cylinder to drive the swing rod to swing, so that the alarm is driven to swing, and the visual range of the alarm is expanded.