
A potentiometer is a variable resistor that allows you to adjust resistance manually. A trimmer potentiometer (or trimpot) is a small, adjustable version usually used on PCBs for fine-tuning voltage, brightness, contrast, or calibration in circuits.
When we connect a trimmer potentiometer with the ESP8266, we can use it as an analog input device. For example, we can read the resistance value and use it to:
Since the ESP8266 has only one ADC pin (A0), we will connect the potentiometer to it and read values ranging from 0 to 1023.
⚠️ Note: ESP8266 ADC works on 0–3.3V only, so don’t supply 5V to the potentiometer.

// Trimmer Potentiometer with ESP8266
int potPin = A0; // Potentiometer connected to analog pin A0
int potValue = 0; // Variable to store potentiometer value
void setup() {
Serial.begin(115200); // Start Serial Monitor
}
void loop() {
// Read potentiometer value (0 to 1023)
potValue = analogRead(potPin);
// Print value to Serial Monitor
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
delay(500); // Wait 0.5 seconds
}
Pin Declaration
int potPin = A0;
Setup Function
Serial.begin(115200);
Loop Function
potValue = analogRead(potPin);
Serial.println(potValue);
analogRead(A0) reads values between 0 and 1023 depending on the position of the potentiometer.
The value is printed on the Serial Monitor.
Yes, ESP8266 can read potentiometer values through its A0 analog pin, which reads voltages from 0–3.3V.
analogRead(A0) returns values between 0 and 1023, representing 0–3.3V input.
Yes, both work the same. A trimmer is small and used for calibration, while a normal potentiometer is larger and suitable for user control.
Yes, but only if you ensure the output going to A0 pin never exceeds 3.3V. Otherwise, you may damage the ESP8266.
You can map potentiometer values to control LED brightness, fan speed, or send them to an IoT dashboard for real-time monitoring.






