B4R Question Technical question ADC pin/ Potentiometer

Beja

Expert
Licensed User
Longtime User
To interface a pot to an Arduino analog pins, you need to connect all 3 pins (Vcc, Gnd and the center pin..
Why is that necessary? Isn't Vcc and the center pin enough to send a variable voltage to the analog pin"
In the image below, why A and not B?

quiz8.png
 

advansis

Active Member
Licensed User
Longtime 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
 

Attachments

  • Arduino.png
    Arduino.png
    9.5 KB · Views: 177
Upvote 0

Beja

Expert
Licensed User
Longtime 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

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)
 
Upvote 0

advansis

Active Member
Licensed User
Longtime 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)

You can use your 2wires sensor: my schema uses a 3wires and transforms it in 2wires
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
You can use your 2wires sensor: my schema uses a 3wires and transforms it in 2wires

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.
 
Upvote 0

Beja

Expert
Licensed User
Longtime 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.
 
Upvote 0

advansis

Active Member
Licensed User
Longtime 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
 

Attachments

  • Arduino.png
    Arduino.png
    8.5 KB · Views: 171
Last edited:
Upvote 0

Beja

Expert
Licensed User
Longtime 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

Did you cancel the internal pullup and replace it with external one?
 
Upvote 0

Chris Tyrie

Member
Licensed User
Longtime 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)
 
Upvote 0
Top