An electronic device, comprising: a housing including an inner space; a hole formed through the housing to the inner space, wherein the hole and the inner space are configured to receive an insertable stylus pen, 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 the at least one memory stores instructions that, 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 to the wireless charging receiver circuit, using the wireless charging transmitter circuit after detecting that the stylus pen is inserted into the inner space, scan for a wireless signal from the first wireless communication circuit, using the second wireless communication circuit after the starting to provide charging, receive the wireless signal from the first wireless communication circuit, using the second wireless communication circuit, stop providing charging for the first duration to the wireless charging receiver circuit, after receiving the wireless signal, and transmit a connection request using the second wireless communication circuit to the first wireless communication circuit. a housing including an inner space; a hole formed through the housing to the inner space, wherein the hole and the inner space are configured to receive an insertable stylus pen, 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 the at least one memory stores instructions that, 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 to the wireless charging receiver circuit, using the wireless charging transmitter circuit after detecting that the stylus pen is inserted into the inner space, scan for a wireless signal from the first wireless communication circuit, using the second wireless communication circuit after the starting to provide charging, receive the wireless signal from the first wireless communication circuit, using the second wireless communication circuit, stop providing charging for the first duration to the wireless charging receiver circuit, after receiving the wireless signal, and transmit a connection request using the second wireless communication circuit to the first wireless communication circuit. detect whether the stylus pen is inserted into the inner space, start to provide charging for a first duration to the wireless charging receiver circuit, using the wireless charging transmitter circuit after detecting that the stylus pen is inserted into the inner space, scan for a wireless signal from the first wireless communication circuit, using the second wireless communication circuit after the starting to provide charging, receive the wireless signal from the first wireless communication circuit, using the second wireless communication circuit, stop providing charging for the first duration to the wireless charging receiver circuit, after receiving the wireless signal, and transmit a connection request using the second wireless communication circuit to the first wireless communication circuit.