Giter VIP home page Giter VIP logo

Comments (11)

RChadwick7 avatar RChadwick7 commented on August 21, 2024 2

I'll assume you're more of a software person. Forgive me if I got your question wrong. GPIO14 will go low RELATIVE to ground. I'm not familiar with any magic that would allow knowing if a pin is low (0 Volts, connected to ground) or high (+5 Volts or +3.3 Volts) without access to a ground. Unlike a water hose, where water will go in one end and come out the other, Electricity needs to work in a loop. If you ever look at any battery, you will see two connections. At least one will be marked, and you can figure out what the other one is (Either + or -).
Hope this helps.

from lipopi.

NeonHorizon avatar NeonHorizon commented on August 21, 2024 1

Can you do a circuit diagram so I can see?

from lipopi.

slavapak avatar slavapak commented on August 21, 2024

RChadwick7 thanks!
That makes sense.

Do you mind if I ask you several more questions? :)

I'm thinking of implementing the basic lipopi but with a SPDT switch instead of a button.
Daniel suggested a nice solution here.

  1. Is it safe to have GPIO18 connected to Bat when Pi is off?
  2. Also does it drain any additional current?
  3. If yes, would adding a 100K resistor between Bat and switch less the drained current?
  4. In general, is it OK/safe to have Bat constantly connected to GPIO14 when Pi is on?
  5. Is it safe to have GPIO14, 18, Bat, En and Gnd connected momentarily? I assume that might happen during switch slider slide.

Thanks a lot!

Cheers,
Slava.

from lipopi.

RChadwick7 avatar RChadwick7 commented on August 21, 2024

I just want to back up for a second. The GPIO pins won't necessarily be connected directly to +V or Ground. If you program a GPIO pin to be high, it will switch on a switch between the pin and +V, and if you program it low, it will turn on a switch that connects it to Ground. So, what happens if you connect two GPIO pins together, and set one to be high, and one to be low? In some situations, you might get smoke! Since digital electronics is not about high power, but about information, you may often see a resistor between inputs and outputs. This ensures that no matter how the pins are set you won't get a direct short between +V and Ground. A resistor between 1K and 10K is usually good to let the voltage low/high information be passed, but not be a big deal if it's connected between +V and Gnd. I could be wrong, but I think the Pi has these resistors already internally. Regardless, it wouldn't hurt to put a 1K resistor on outputs.

In general, it's a bad idea to power random pins of a chip when it's powered down. However, if the Pi's power is the same as what you attach to GPIO18, that's fine. Again, if you want to be safe, put a 10K resistor between +V and GPIO18.

Since we're dealing with information instead of power here, very little current is required for an input to detect a high. If your code accidentally made GPIO18 and output, and set it low, you would have a higher current drain with a 1K resistor. Under normal operation, I doubt you could measure a difference. As for GPIO14, I would use a pull up resistor, 1K to 10K. Again, as long as it's configured as input, everything should be OK. In the Engineering world, it's common to permanently pull up a pin. If the pin could never be configured as an output, and a 1K resistor is not desirable for whatever reason (Cost, laziness, etc), the pin can usually be connected directly. Again, the warning about not powering pins on an unpowered chip. If you use the same power supply for everything, no worries.

As for connecting everything together momentarily? Sounds scary, but putting resistors on GPIO 14 and 18 should hopefully protect them. As for the +V from the battery and ground shorting, that's a really bad idea. Depending on what you want to do, I would either use an SPST (Or just one side of an SPDT) to switch the +Battery voltage (No need to switch Gnd), or leave the battery permanently connected, and use the SPST instead of the pushbutton switch. The PowerBoost will draw current this way, but it's SO small you likely will never notice it.

Hopefully some of this makes sense. I made some assumptions that might be wrong. If you have more questions, it might help to know more about your application.

from lipopi.

NeonHorizon avatar NeonHorizon commented on August 21, 2024

When the Pi is off or the pins are set as inputs the GPIO's should be very high impedance (IE little to no current will flow) but as mentioned having 1k resistors inline isn't a bad idea under most situations.

With reference to pulling up and down pins the Pi has software programmable pull up and down resistors which are about 50k so its usually unnecessary to have external ones. The only odd ones out are the I2C pins which I think have internal 1.8k pullups.

from lipopi.

slavapak avatar slavapak commented on August 21, 2024

Thanks for such a through explanation!

Basically, all I want to do is to add safe on/off to my RPi0. I like the idea to copy lipopi, but with a sliding switch instead of a button. And hence are all my questions :)
I.e. for button GPIO14 is connected to Bat only when button is pressed, but for sliding switch it will be connected all the time when RPi0 is on.
And in the solution suggested by Daniel in that other thread GPIO18 remains constantly connected to Bat when RPi0 is off.
Now, if I understand you correctly, all of it is safe and does not cost much current.

Thank you!

Cheers,
Slava.

from lipopi.

slavapak avatar slavapak commented on August 21, 2024

Reviving this thread.

I just realized that when using sliding switch instead of a button, and put it between Bat and 100 KOhm resistor, connection to Bat might be redundant.

Here how I assume it would work:

  • When switch is closed, En is shorted to Gnd, and Powerboost is turned off.
  • Now, when you open switch, En is not connected to Gnd anymore and Pi boots up.
  • If you close switch after that, Pi will continue working, because GPIO14 is connected to En and is high.
  • After graceful Pi shutdown, GPIO14 will turn low, and power supply will shut off.

Unfortunately I do not know a lot about electric circuits, and I'm afraid to burn my RPi0.
Can you please confirm that it is safe to remove link to Bat?

Thank you!

Cheers,
Slava.

from lipopi.

slavapak avatar slavapak commented on August 21, 2024

Sure!

Here it is:
sliding-switch

from lipopi.

NeonHorizon avatar NeonHorizon commented on August 21, 2024

Hey that's really clever!
You are taking advantage of the tri-state output on the GPIO (hi, low, high impedance).
I think it should work but I don't know for sure give it a go and let us know :)

from lipopi.

NeonHorizon avatar NeonHorizon commented on August 21, 2024

By the way now I understand a bit better I think I can answer your original question.
You were asking why the ground wire is needed, I'm guessing you mean the wire with the 100k resistor rather than the actual ground? The reason that is needed is because when the Pi is powered off GPIO14 is high impedance (almost open circuit) so the 100k is used as a pulldown resistor.

from lipopi.

slavapak avatar slavapak commented on August 21, 2024

I see.
Thank you!

from lipopi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.