

The OLED-Rotary-Encoder by SAMIROB (Part ID: Rotary Encoder) is a versatile device that combines an OLED display with a rotary encoder. This integration allows for both visual feedback and user input through rotation and pressing. The component is ideal for applications requiring compact user interfaces, such as menu navigation, parameter adjustment, and real-time data display.








| Parameter | Value |
|---|---|
| Manufacturer | SAMIROB |
| Part ID | Rotary Encoder |
| OLED Display Type | 128x64 pixels, monochrome |
| OLED Interface | I2C (Inter-Integrated Circuit) |
| Rotary Encoder Type | Incremental |
| Encoder Resolution | 20 steps per revolution |
| Push Button | Integrated (momentary switch) |
| Operating Voltage | 3.3V - 5V |
| Current Consumption | ~20mA (OLED active) |
| Dimensions | 30mm x 30mm x 15mm |
| Pin Name | Description | Notes |
|---|---|---|
| VCC | Power supply (3.3V - 5V) | Connect to the power source |
| GND | Ground | Common ground for the circuit |
| SCL | I2C Clock Line | Connect to microcontroller SCL |
| SDA | I2C Data Line | Connect to microcontroller SDA |
| Pin Name | Description | Notes |
|---|---|---|
| CLK | Clock signal output | Connect to microcontroller pin |
| DT | Data signal output | Connect to microcontroller pin |
| SW | Push button signal output | Connect to microcontroller pin |
| GND | Ground | Common ground for the circuit |
| VCC | Power supply (3.3V - 5V) | Connect to the power source |
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Encoder.h>
// OLED display dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// I2C address for the OLED display
#define OLED_ADDR 0x3C
// Initialize OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Rotary encoder pins
#define ENCODER_CLK 2
#define ENCODER_DT 3
#define ENCODER_SW 4
// Initialize rotary encoder
Encoder myEnc(ENCODER_CLK, ENCODER_DT);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize OLED display
if (!display.begin(SSD1306_I2C_ADDRESS, OLED_ADDR)) {
Serial.println(F("OLED initialization failed!"));
while (true); // Halt execution if OLED fails
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println(F("OLED-Rotary-Encoder"));
display.display();
// Configure rotary encoder button pin
pinMode(ENCODER_SW, INPUT_PULLUP);
}
void loop() {
// Read rotary encoder position
static long oldPosition = -999;
long newPosition = myEnc.read() / 4; // Adjust for encoder resolution
if (newPosition != oldPosition) {
oldPosition = newPosition;
display.clearDisplay();
display.setCursor(0, 0);
display.print(F("Position: "));
display.println(newPosition);
display.display();
}
// Check if the button is pressed
if (digitalRead(ENCODER_SW) == LOW) {
display.setCursor(0, 20);
display.println(F("Button Pressed!"));
display.display();
delay(200); // Debounce delay
}
}
OLED Display Not Turning On:
Rotary Encoder Not Responding:
Push Button Not Working:
Flickering or Unstable Display:
Q: Can I use this component with a 3.3V microcontroller like ESP32?
A: Yes, the OLED-Rotary-Encoder supports both 3.3V and 5V logic levels.
Q: What is the default I2C address of the OLED display?
A: The default I2C address is 0x3C. Check the datasheet or use an I2C scanner if unsure.
Q: How do I handle noisy signals from the rotary encoder?
A: Use software debouncing techniques or external capacitors (e.g., 10nF) on the CLK and DT lines.
Q: Can I change the OLED display's text size?
A: Yes, use the setTextSize() function in the Adafruit SSD1306 library to adjust the text size.