The disclosure relates to an electronic device. The electronic device includes: a shell, a display panel, the display panel or the shell including a light-transmitting area, an ambient light sensor, an infrared transmitter and a light guiding piece. The light guiding piece includes a light incident end and a light emitting end, the light incident end being configured to face the light-transmitting area, and the light emitting end being configured to face the ambient light sensor and the infrared transmitter.