Skin pain resulting from mechanical compression is one of the most common pains in daily life and the indispensable information for electronic skin to perceive external signals. The external mechanical stimuli are transduced into impulses and transmitted via nerve fiber, and finally, the sensation is perceived via the procession of the nerve system. However, the mathematical mechanism for pain sensation due to mechanical stimuli remains unclear. In this paper, a mathematical model for skin pain sensation under compression is established, in which the Flament solution, the revised Hodgkin-Huxley model, and the mathematical model gate control theory are considered simultaneously. The proposed model includes three parts: a mechanical model of skin compression, a model of transduction, and a model of modulation and perception. It is demonstrated that the pain sensation degree increases with the compression amplitude and decreases with deeper nociceptor location in the skin. With the help of the proposed model, the quantitative relationship between compression pain sensation and external mechanical stimuli is revealed, which has a significant benefit in promoting the design and mechanism research of electronic skin with pain perception function.