You can still use Bruce's method of sensing whether the bus is active... The presence of a USB bus could allow your PIC to switch some FETs that activate a charging circuit, etc.

Or, like Bruce mentioned, you can run in non-USB datalogging mode until a voltage is sensed on that pin. Then, enumerate and dump your data.

Officially, your device is supposed to draw less than 100 mA of current during enumeration until it negotiates and is approved to receive higher power. If you're running on a laptop through a bus-powered hub, there's a chance that the computer might just say, "Sorry, no can do." There just isn't enough power available.

And if the bus is idle (which means > 3 mS of inactivity), you're not supposed to draw more than I think 500 uA. Yes, microamps.

Surf on over to usb.org, click on developers and then on discussion forums. You'll find a wealth of information and helpful engineers.

They aren't too patient with people who haven't done some basic homework before asking questions, but the forums can be searched. Many of the most popular questions have been discussed ad absurdum already...

John