5

I have my Pi Zero connected to my laptop in OTG mode and it is scheduled to take temperature readings every 5 minutes, then send the data to the laptop on the hour.

I was wondering if I was able to connect the PWR port to the mains as a backup supply so that the Pi continues to take readings when unplugged from my laptop. Or would this just blow up the Pi? Would the Pi know when to switch between master/slave mode?

  • 1
    No. Do not do this. There is no onboard switching, so what you will have is two competing supplies and I believe that can end badly for one of them -- which may damage the Pi and/or your laptop. I think it would be okay if both jacks are connected to the same ultimate source (i.e., the laptop) but there doesn't seem to be much point in that. I'll leave it up to someone more electrically astute and with more knowledge of the schematics to provide a definitive answer. – goldilocks Dec 3 '16 at 14:57
  • I don't know a lot about electricity, but I know diodes can be used to block the flow of current in 1 direction depending on which way you point them. In theory 4 diodes 1 for each wire of each power source should block backing feeding. However, you probably want to wait for someone with more knowledge to confirm this theory. – cybernard Feb 4 '17 at 4:47
  • @cybernard Using diodes to OR supplies of the same nominal voltage is totally legitimate – crasic Aug 1 '17 at 22:30
1

I agree with goldilock that you should not connect two separate power sources. If losing power when connecting to the laptop is a big enough concern to warrant some risk I do have a suggestion.

NOTE: This is a possible solution to the problem based on past experience, but it is not without some risk as you will be modifying a cable connected to the laptop. Consider this a warning!

You could modify a USB cable to carry data, but not power. This can be done by stripping the insulation on a USB cable and cutting the 5v wire (usually red). Confirm using a volt meter. If any of the other wires are damaged in the process, cut all off them and re-attach with solder / heat-shrink (all but the 5v line). DO NOT DISCONNECT THE GROUND. If this has any chance of working, you will need a shared ground.

I've done something similar when working with older models of the Pi; there was concern of back-feeding power coming from the USB ports when using cheap powered hubs. By disconnecting the 5v line from the hub to the Pi's USB port it allowed devices connected to the hub to be powered from the hub's supply, but not bypass the internal protection on the Pi. (see: What's the problem with backfeeding?)

Use the modified cable to connect the pi to your laptop: this will prevent your laptop from powering the pi so you will need keep the power cable connected for the Pi to stay on. You will, however be able to disconnect the laptop without the Pi losing power. Make sure to only use the modified cable when connecting to another source of power. Mark it or even glue it into the Pi (after testing it) to make sure you don't forget.

It's a trade-off, but it should work if the sensor is stationary, has it's own battery or otherwise has a more consistent power supply.

If a battery backup is a better option, make sure to handle charging correctly. I don't have as much experience on that side of things, so check out https://hackaday.io/project/9461-lifepo4weredpi and other battery charging projects first.

  • Wouldn't adding a few diodes to block the power from flowing backwards solve this? – cybernard Feb 4 '17 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.