This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thingy91 usb power state change

Hi,

I am working on the Thingy91 and trying to set up an event when the USB power state changes (USB cable w/power is plugged or unplugged). For now I will just blink an LED or something simple. I have a few references but nothing that solves the problem on the Thingy91 just yet.

I've been pointed to this app

https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/applications/nrf_desktop/src/events/usb_event.c

however it inst supported on the thingy91

also

I found this performing the same task on the nrf52832.

https://devzone.nordicsemi.com/f/nordic-q-a/31289/charging-indication-by-led-glow

it looks to be doing exactly what I want to do successfully. It does so via "P0.17 connected to USB supply using voltage divider". Is there a pin on the thingy91 connected to the USB power supply that I can set up a similar process. I looked at the pin layouts on the thingy91 manual but didn't see anything that looked correct. Is this something I would have to wire up myself or does it already exist and I just missed it?

Any help would be appreciated.

Parents Reply Children
  • I've been looking into this and trying to figure out how to implement. It seems I would have to get this running on the 52 side of the board and have the 52 send any usb events detect over the 9160 side to trigger an event where the 9160 can perform an action. Is there anyway to get the 9160 to directly listen for a USB power event and respond to that without the middle man 52 chip?

  • The nRF91 does not know USB, so you would have to implement the state recognition yourself.

    I am not familiar enough with USB to be able to tell how viable that would be. Also, while I have not studied the schematics for the Thingy:91, I do not believe the nRF91 is connected to the USB bus.

    It might be possible to detect a connected USB cable by reading the battery voltage, but that is just speculation on my part.

  • I believe you are correct about the USB bus. At least for the thingy91 which I can confirm the HCI to USB is done through the 52. I think the 9160DK is a little different as there is a Jlink chip in between the chips and the USB. I do know however that the 9160 connects to the PMIC which is where I would think I would read the charge state. Looking for an event to trigger when the power via usb is provided or stopped I'm not concerned with any data connection. Here is the diagram showing the connections

    https://infocenter.nordicsemi.com/pdf/Thingy91_UG_v1.0.pdf page 14

    I can confirm you can tell if there is power via USB by checking the bat voltage but I don't how to use that to trigger an event without constantly checking the voltage. Seems like it would be rather power hungry compared to having a pin with a pull down/up on it. I appreciate your feedback!

  • Yes, on the Thingy:91, the USB bus is connected to the nRF52. And I believe that would be the easiest way to detect the USB status changes.

    As you also mention, it is also possible to read the status registers of the PMIC. However, looking at our driver, it looks like you would have to poll here as well.

    The PMIC also has an interrupt line connected to the nRF9160. You might be able to use that one to provide an interrupt when the USB cable is connected (I have not studied the PMIC datasheet, nor the battery management code on the Thingy).

    Another possibility could be to get access to one of the GPIO pins connected to the NMOS header via a test pad and use that to generate an interrupt, assuming that the voltages from the battery/USB-connection is within the parameters of the GPIO PIN.

Related