The ends, and when it is wrong · 09 of 9

When the reading is wrong

A wrong reading is nearly always one of three wires. Stuck at 0 is VCC, stuck at the top is GND, and a number that wanders with nobody touching the wheel is SIGNAL. The rest is a setting in the sketch.

Five symptoms

What the reading is doing
The reading
A reading stuck at 0 means SIGNAL is at 0 V whatever the wheel does. The usual reason is VCC: with nothing on it the track has no top, and the wiper reaches GND through it. Then check the sketch reads the pin SIGNAL is really on.

Pick what the reading is doing. The ringed part of the board is where to look first, and the list beside it is the order to check in.

Stuck at 0

SIGNAL is at 0 V wherever the wheel is. The usual reason is VCC: with nothing on it the track has no top, and the wiper reaches GND through it. If VCC is connected, check that POT_PIN names the pin SIGNAL is really on, and that the cable is not one pin over. Shifted one position, SIGNAL lands on NC, which is connected to nothing.

Stuck at full scale

SIGNAL is at VCC wherever the wheel is. The usual reason is GND: without it the track has no bottom, and the wiper sees VCC through it.

In MicroPython on an ESP32, a missing atten() line gives a reading that hits the top under a third of the way round, because the ADC's default range there is about 1 V. In Arduino, an ADC_MAX of 1023 on an ESP32 makes a percentage or a duty hit the top a quarter of the way round.

Wanders on its own

A reading that drifts over hundreds of counts with nobody touching the wheel means the pin is measuring nothing. SIGNAL is not reaching it, and an unconnected analog input reads whatever charge happens to be on it. Check the SIGNAL wire, then the pin number.

A few counts of jitter with everything connected is normal, more on an ESP32 than on an Uno. Smoothing a jittery reading is the fix.

Goes the wrong way

Which direction raises the reading is set by the part, and nothing is wrong. Use ADC_MAX - reading instead of reading, and the wheel works the other way round.

Stops short of the ends

On an ESP32 the last few percent at each end read flat, and on any board a stop may be a few counts short of 0 or full scale. Why the ends are not exact has the sketch that takes your own stops.

When it does not work

How can I test the block without any code?

With a multimeter on volts: black probe on GND, red on SIGNAL, block powered from your board. Turn the wheel and the voltage should run from 0 to whatever VCC is. If it does, the block is fine and the problem is the pin or the sketch.

Is it safe to swap VCC and GND to reverse the direction?

Electrically yes: the block is only a resistor, and it does not mind which end is which. But a TinkerBlock cable fixes the order, so the cleaner fix is in code: subtract the reading from ADC_MAX, or from 65535 in MicroPython.

It worked, then started reading nonsense after I added Wi-Fi.

On a classic ESP32 that is the sign of an ADC2 pin: they stop reading while Wi-Fi is on. GPIO 34, the pin this book uses, is on ADC1 and is not affected. Check that SIGNAL is still on it.

Which ESP32 pins should I avoid for SIGNAL?

Anything that is not an ADC1 pin. On a classic ESP32 the ADC1 pins are the high-numbered ones, 32 and up, and most of them are input-only, which suits a pot perfectly. Never use the pins wired to the flash chip, which stop the board booting. On an ESP32-S3, ADC1 is the low-numbered GPIOs, and GPIO 4 is one of them.

Where this goes next

Forty-odd blocks, and the disc potentiometer is the simplest way to give any of them a setting you can turn.

Back to the blocks

Edit this page — content/books/disc-potentiometer/when-the-reading-is-wrong.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Disc Potentiometer

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum