Using micro USB-B connector to detect phone connection

I am working on a project where the arduino needs to detect if the smartphone is plugged in the micro usb-b.

I noticed that the micro usb has 5 pins, and I am wondering if I could use the sensor/ID pin to send an electric signal to the arduino using a series of NPN transistor. is that possible?

if not, any recommendations?

Thanks,
C

Pinout here

Weedpharma

I noticed that the micro usb has 5 pins, and I am wondering if I could use the sensor/ID pin to send an electric signal to the arduino using a series of NPN transistor. is that possible?

Sensor/I/O pin ? What is that, Newbie for " analog input " ?

Need to know which arduino.

"Sensor/ID pin" is referring to the 4th pin in the USB.

Weedpharma

The full spec here

excerpt (also I'm not quite sure what miniA and miniB refer to after a very quick glance):

The ID pin on a Mini-A plug shall be connected to the GND pin. The ID pin on a Mini-B plug is not connected or is connected to ground by a resistance of greater than RB_PLUG_ID. A dual-role device is required to be able to detect whether a Mini-A or Mini-B plug is inserted by determining if the ID pin resistance to ground is less than RA_PLUG_ID or if the resistance to ground is greater than RB_PLUG_ID.
Any ID resistance less than RA_PLUG_ID shall be treated as ID = FALSE and any resistance greater than RB_PLUG_ID shall be treated as ID = TRUE.

Sounds like shorting the pin in the cable should work.

my apologies and thanks for replying.

yes the sensor/ID pin in the micro USB-b.

I am using an arduino nano.

so the plan is to make the nano receive an electric signal(like a buttonPin) from the micro usb to tell the nano that the phone is plugged.

I am currently using the DATA + pin of the micro usb but the electric current fluctuates a lot if I use the DATA +. So, I was hoping if I could use the Sensor/ID pin in the micro usb.