B4R Question Technical question ADC pin/ Potentiometer

Discussion in 'B4R Questions' started by Beja, May 14, 2019.

  1. advansis

    advansis Member Licensed User

    The value of the internal pullup resistor (Rup) is around 20k.
    In A0 you will find (voltage divider Rx/Rup):

    Vx=Vcc*Rx/(Rx+20k)

    So you will never obtain the full-range voltage (0-5 Volts), but less than 5V, depending on the maximum value of the resistance of the potentiometer.
    For example, considering the formula, with Rx at its maximum,
    - if you have a 1k potentiometer, the range will be 0-0.2V
    - if you have a 20k potentiometer, the range will be 0-2.5V
    - if you have a 100k potentiometer, the range will be 0-4.16V

    When the knob is versus the ground, you will always find a value close to 0V (it depends on wiring resistance)
    Usually the free wire of the potentiometer is connected to the central one: this reduces noise for large resistors and reduces glitches dued to mechanical defects.
    Without external power supply, you will never burn your pin, for sure...

    Hope this helps
     

    Attached Files:

    Beja likes this.
  2. Beja

    Beja Expert Licensed User

    Thanks advansis for the detailed description. indeed it helps and it's more clear now. But it seems my application may not work on this setting because my
    sensor only has 2 wires, and I think the only solution is to use Peter Simpson's example of water sensor because it's similar in this case. In other words, to use a brake-out module.

    https://www.b4x.com/android/forum/threads/reading-a-fc-37-water-sensor-2-pin-black.96335/ (thanks Pete)
     
  3. advansis

    advansis Member Licensed User

    You can use your 2wires sensor: my schema uses a 3wires and transforms it in 2wires
     
    Beja likes this.
  4. Beja

    Beja Expert Licensed User

    I don't get it.. Say I have that same water sensor with two wires.. How am I going to use your solution? The sch in image above can't do the job. I would appreciate it if you kindly sent another image.
     
  5. Beja

    Beja Expert Licensed User

    Finally
    I thank all who tried to help
    And in the process I learned a lot from you guys.
    The secret recipe was the breakout board that took care of the voltage divider. I just tested and replaced the water sensor with a 100k potentiometer.. It worked like a charm.
     
  6. Beja

    Beja Expert Licensed User

    20190517_184657~2.jpg
     
    kolbe likes this.
  7. advansis

    advansis Member Licensed User

    Well done. Forgive me for not responding before... Your module seems an amplifier.
    You can also use the attached schema. The value of Rup should be 1k or more (not less otherwise the circuit will waste a lot of energy).
    Put a ceramic capacitor in series with your probe, to reduce noise. Disable the internal pullup resistor.
    The formula for calculating your resistance is the same Vx=Vcc*Rx/(Rx+RUp) where Rx is your resistance and Vx is the value read on A0
     

    Attached Files:

    Last edited: May 21, 2019
    Beja likes this.
  8. Beja

    Beja Expert Licensed User

    Did you cancel the internal pullup and replace it with external one?
     
  9. advansis

    advansis Member Licensed User

    Yes, RUp Is the external pullup
     
  10. Chris Tyrie

    Chris Tyrie Member Licensed User

    But what if i have 3 metal pots, a microwave oven, and non-dairy creamer? What happens then?

    (Chris stumps the band yet again)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice