Envirophat analog inputs


#1

Hi,

What’s the best way of wiring a potentiometer into an envirophat’s analog ports to get a reading please? I’m looking to add a couple to control timeout values in a script. I know @sandyjmacdonald did something with a pot in the ARRR600 but there is no detail in his blog posts about the wiring.

Thanks
Marc


#2

The exact requirements depend upon your potentiometer, but I’m guessing it’s got 3 pins- one should be power, one should be ground (although these are generally reversible) and the third is the output which can be connected directly to an analog input on Enviro pHAT. You can power it from the 5V pin supplied.

Think of the potentiometer as one long resistor- you connect it to power and ground and then use the slider or dial to move a physical wiper along the length of the resistor. At any given point it forms a regular voltage divider between the 5V input, Ground and the output.

Ideally a potentiometer connected to 5v should output 2.5v when it’s in the middle since the resistance on either side of the output matches.

IE: If you have a 10k pot turned to half way- you basically have this circuit:

So running that through Vout = Vin * R2 / (R1+R2)
or 5 * 5000 / (5000 + 5000)

gives you: 2.5v

Refer to the datasheet for your particular pot to see where the relevant connections are :D


#3

It’s usually the two outer pins that are the power and ground and the centre pin is the output pin.