An electronic device is provided. The electronic device includes a housing including an inner space, a hole formed through the housing to the internal space, a
stylus pen insertable into the internal space through the hole, wherein the
stylus pen includes a first
wireless communication circuit and a
wireless charging
receiver circuit, a
wireless charging
transmitter circuit positioned inside the housing and configured to provide charging to the wireless charging
receiver circuit when the
stylus pen is inserted into the inner space, a second wireless communication circuit positioned inside the housing, at least one processor operatively connected to the wireless charging
transmitter circuit and the second wireless communication circuit, and at least one memory operatively connected to the at least one processor, wherein when executed, cause the at least one processor to detect whether the stylus pen is inserted into the inner space, start to provide charging for a first duration.