0

I have an idea that involves detecting and possibly measuring a 12v feed from a car but my electrics skills are a little limited and I'm using this idea to learn. My understanding is that the 12v feed could range from 11-18v so I'll need some sort of step down electronics. So this is my understanding

Option 1

If I use a regulator LM1117 to 3.3v this will provide a basic high/low feed. If this is correct this could then be connected directly to a GPIO input.

Option 2

Use some other form of step down electronics (I need ideas or documents) that steps down the max 18v down to 3.3v. As the input voltage drops lower so does the output voltage. Then I can use an MCP3008 device to the read the actual voltage.


So is my thinking about both options correct and which would be the best approach? Technically is the regulator that I've referenced in option 1 the best option? If Option 2 is viable can anyone suggest any reference documents that I could read that provides the required stepdown.

This is as much a learning excercise as a real project, so the solution has to be reasonably simple and relatively cheap. Even though I've only mentioned one 12v feed eventually there will be 8 feeds two of which will be pulsating on and off. I'm using a PI and have RasPIO Zero on order:

https://thepihut.com/products/raspio-analog-zero?utm_medium=cpc&utm_source=googlepla&variant=21364880964&gclid=CJu4gobums8CFSco0wod5eELxg

Thanks for any help

UPDATE:

Thanks for your help, I'll be doing a little testing over the weekend, as a result of your suggestions I've found a couple of useful site (very basic but what I need):

www.bowdenshobbycircuits.info/r2.htm

www.wikihow.com/Make-a-Voltage-Divider-Circuit

  • What are you asking, exactly? I dont understand. Sounds like you need to take a course first.. Does any of this make specific question to a Raspberry Pi??? – WillyWonka Nov 9 '16 at 8:07
2

Sounds like you are trying to measure the source voltage (rather than try to get a stable 5v to power your Raspberry Pi).

As you know the Raspberry Pi does not have any analog input so you'll need an external device to do this - as you have already identified a MCP3008 is a good candidate.

Now the question is how to you get convert the 12-18v down to something that can be used by the MCP3008. For that you can use a voltage divider (and some Ohms Law):

+18v-------------------------
      |
      |
      \
      /
      \ R1
      /
      \
      |
      |
      -------------->   Vout (connect to ADC input)
      |
      |
      \
      / 
      \ R2
      /
      \
      |
      |
Gnd----------------------

The voltage dropped across each is a ratio of their resistances:

                R1
Vr1 = Vin * ---------
            (R1 + R2)

                R2
Vr2 = Vin * ---------
            (R1 + R2)

So, to get down to (max 3.3v) on Vout you need around a ratio of 5:1 I'd look at around 100K for R1 and 20K for R2.

Meaning that if the input was 18v you'd get:

18 * (20k / (20k + 100k) = 3v.

... and if it drops to say 12v, you'd get:

12 * (20k / (20k + 100k) = 2v.

Some testing of the ADC values for known source voltages will be required (i.e. calibration) to account for resistor tolerances (and I'm not sure if the performance of the MCP3008 is completely linear).

  • +1. This is absolutely sufficient and safe for 18V input, however, one may want a capacitator to GND at the ADC input to smooth out spikes from the generator and ignition. 1µF should be sufficient. Uh, and no ASCII art needed. There's a circuit editor built into the editor window. See the circuit icon. – Janka Nov 8 '16 at 21:39
  • For 24 Volt input I use 1M and 200K - nice high-impedence input and good separation between Vcc and GND. No need for a cap since I am measuring battery voltages which do not change rapidly. Since it is a solar panel input I find it tops out at 1023 at about 29 Volts, which is fine. One caveat: Calibrating it on USB power is not the same as the actual installed Vcc. – SDsolar Jan 8 '17 at 9:17
0

Use a UBEC which will drop any voltage between 5.5V and 26V to a Pi safe 5V.

You can buy a UBEC for 1GBP or so, e.g. http://www.ebay.co.uk/itm/281924450613

EDITED TO ADD

I misread your question. I thought you wanted to power the Pi.

As it happens you could still use a UBEC. Let the UBEC drop the voltage to 5V and then use a pair of resistors as a voltage divider to drop the 5V to a Pi GPIO safe 3V3.

  • I donnut blame you for misreading question. What is he talking about?? – WillyWonka Nov 9 '16 at 8:08
  • 1
    I think the OP wants to measure the voltage, so stabilizing it to 5V will be counter-productive. – Dmitry Grigoryev Nov 9 '16 at 9: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.