Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Motors & Motion
  4. ›25mm and 37mm DC Gear Motors with Hall Encoder

Component guide · Intermediate · 3 min read

25mm and 37mm DC Gear Motors with Hall Encoder

Wiring and PID Code

By Geekobot Learning Team · Updated 29 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the 25mm encoder gear motor is25mm encoder gear motor pinoutWiring the 25mm encoder gear motorExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Short answer

The 25 mm (JGA25-370 style) and 37 mm metal gear motors with a Hall encoder are the standard wheel motors for robots that need speed or distance control. They run from 6 or 12 V at 12 to 1000 RPM, and the two-channel magnetic encoder on the back gives 11 pulses per motor turn per channel, multiplied by the gear ratio at the output shaft.

Key specs at a glance

Diameter
25 mm or 37 mm gearbox, 4 mm or 6 mm D-shaft
Voltage
6 V or 12 V versions
Speed
About 12 to 1000 RPM depending on ratio
Stall current
About 1 to 2 A (25 mm), 3 to 5 A (37 mm) at 12 V
Encoder
Hall, 2 channels (A/B), 11 pulses per motor turn per channel, 3.3 to 5 V
Wires
6: motor + and -, encoder VCC, GND, A, B

Models in this guide

These are alternatives. Pick the one that fits your project; you only need one.

  • Option 1Metal Gear DC Motor with Hall Encoder (25mm / 37mm)₹480
  • Option 225mm DC Metal Encoder Gearmotor (by Voltage and RPM)₹1,180
01

What the 25mm encoder gear motor is

With the encoder you can drive both wheels at exactly the same speed, turn by a set angle and measure distance. A PID loop compares the measured speed with the target and corrects the PWM many times a second.

Output pulses per revolution = 11 x gear ratio (x4 if you count every edge of both channels). A 30:1 motor gives 330 pulses per channel per wheel turn.

02

25mm encoder gear motor pinout

The pins on the 25mm encoder gear motor and what each one does.

PinFunction
Red / white (M+ / M-)Motor terminals
Blue (or black) VCCEncoder power, 3.3 to 5 V
Green / black GNDEncoder ground
Yellow (A)Encoder channel A
White / green (B)Encoder channel B
PinFunction
Red / white (M+ / M-)
Motor terminals
Blue (or black) VCC
Encoder power, 3.3 to 5 V
Green / black GND
Encoder ground
Yellow (A)
Encoder channel A
White / green (B)
Encoder channel B
03

Wiring the 25mm encoder gear motor

Wire colours vary between makers, so check the label on the encoder board. Use a driver rated above the stall current: a TB6612FNG for 25 mm motors at 6 V, an L298N or MDD3A for 12 V, and a larger driver for 37 mm motors.

25mm encoder gear motor pinArduino UnoESP32
M+ / M-Driver OUT1 / OUT2Driver OUT1 / OUT2
Encoder VCC / GND5V / GND3V3 / GND
Encoder AD2GPIO 34
Encoder BD3GPIO 35
M+ / M-
Arduino Uno:
Driver OUT1 / OUT2
ESP32:
Driver OUT1 / OUT2
Encoder VCC / GND
Arduino Uno:
5V / GND
ESP32:
3V3 / GND
Encoder A
Arduino Uno:
D2
ESP32:
GPIO 34
Encoder B
Arduino Uno:
D3
ESP32:
GPIO 35
04

Example code

Tune the 1.2 (P) and 4.0 (I) gains for your motor and load. Set PPR to 11 times your gear ratio.

Hold a target RPM with a simple PI loop (Arduino) · Arduino C++Verify & upload in Electrolark
const int ENC_A = 2, ENC_B = 3, PWM = 5, IN1 = 7, IN2 = 8;
const float PPR = 11 * 30.0;          // 11 pulses x 30:1 gearbox
volatile long ticks = 0;
void onA() { ticks += digitalRead(ENC_B) ? -1 : 1; }

float target = 120, integ = 0;        // RPM

void setup() {
  Serial.begin(115200);
  pinMode(ENC_A, INPUT_PULLUP); pinMode(ENC_B, INPUT_PULLUP);
  pinMode(PWM, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  attachInterrupt(digitalPinToInterrupt(ENC_A), onA, RISING);
}

void loop() {
  noInterrupts(); long t = ticks; ticks = 0; interrupts();
  float rpm = t / PPR * 1200.0;        // per 50 ms
  float err = target - rpm;
  integ = constrain(integ + err * 0.05, -255, 255);
  int out = constrain(1.2 * err + 4.0 * integ, 0, 255);
  analogWrite(PWM, out);
  Serial.println(rpm);
  delay(50);
}
05

Setup and tuning

Find the ratio

run at a known speed, count encoder pulses for one wheel turn, divide by 11.

Direction

if the count goes negative when driving forward, swap A and B.

Mounting

use the matching 25 mm or 37 mm bracket and a 4 or 6 mm coupling hub for wheels.

Noise

twist the encoder wires and keep them away from the motor wires.

06

What you need

Shop this list6 of 7 found in our store · ₹2,680

  • Metal Gear DC Motor with Hall Encoder (25mm / 37mm): the part this guide coversMetal Gear DC Motor with Hall Encoder (25mm / 37mm)₹480
  • 25mm DC Metal Encoder Gearmotor (by Voltage and RPM): another version this guide covers25mm DC Metal Encoder Gearmotor (by Voltage and RPM)₹1,180
  • Uno R3 development board: the controller used in the wiring tableFind this part
  • ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
  • L298N motor driver module: a simple driver for two motorsL298N Dual H-Bridge Motor Driver Module₹128Closest match, check the specs
  • TB6612FNG motor driver module: an efficient driver for two small motorsTB6612FNG Dual Motor Driver Module₹130Closest match, check the specs
  • 7.4V 2S Li-Po battery: to power the motors7.4V 3800mAh 2S Li-Po Battery (114253)₹373
07

Alternatives and when to choose them

  • ✓N20 gear motor: the smaller encoder motor.
  • ✓Motor encoders: quadrature counting explained.
  • ✓Cytron MDD10A: a driver for larger 37 mm motors.
08

Common mistakes to avoid

  • !Guessing the wire colours instead of checking the label.
  • !Using an L298N on a 37 mm motor with a 5 A stall current.
  • !Forgetting to multiply 11 by the gear ratio.
  • !Polling encoder pins in loop() instead of using interrupts.
09

Frequently asked questions

How many pulses per revolution?

11 per motor turn per channel, times the gear ratio at the output shaft; four times that if you count all edges.

6 V or 12 V?

Match your battery: 12 V motors on 3S Li-ion or 12 V packs, 6 V motors on 2S.

Can I use the encoder at 3.3 V?

Yes, power it from 3.3 V for an ESP32 or Pi.

Why is my speed reading jumpy?

The sample time is short; average over 100 ms or count both edges.

What wheels fit?

Wheels with a 4 mm (25 mm motor) or 6 mm (37 mm motor) hub, or a coupling hub.

Parts for this guide

  • Metal Gear DC Motor with Hall Encoder (25mm / 37mm)
    ₹480View
  • 25mm DC Metal Encoder Gearmotor (by Voltage and RPM)
    ₹1,180View
  • Uno R3 Development Board (No Cable)
    ₹359View
  • ESP32-WROOM-32 38-Pin Development Board
    ₹389View
  • L298N Dual H-Bridge Motor Driver Module
    ₹128View
  • TB6612FNG Dual Motor Driver Module
    ₹130View
  • 7.4V 3800mAh 2S Li-Po Battery (114253)
    ₹373View
Shop DC & Geared Motors

Keep learning

Concept explainerIntermediateMotor Encoders and Speed FeedbackA motor encoder reports how far and how fast a shaft has turned.3 min read · Motors & MotionComponent guideBeginnerDC Motors ExplainedA brushed DC motor spins when current flows through it: voltage sets the speed and the load sets the current it draws.4 min read · Motors & MotionComponent guideBeginnerL298N motor driverThe L298N module drives two DC motors (or one bipolar stepper) in both directions with speed control.5 min read · Motors & MotionHow-toBeginnerRotary EncodersA rotary encoder is a knob that turns endlessly and outputs two square-wave signals, A and B, a quarter step apart.3 min read · Switches, Relays & Input

Sources

  • JGA25-370 encoder gear motor specifications
  • 37mm DC gear motor with Hall encoder specifications

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the 25mm encoder gear motor is25mm encoder gear motor pinoutWiring the 25mm encoder gear motorExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide (Arduino Uno)4 items · ₹2,237

Metal Gear DC Motor with Hall Encoder (25mm / 37mm) · 25mm DC Metal Encoder Gearmotor (by Voltage and RPM) · 7.4V 3800mAh 2S Li-Po Battery (114253) · Uno R3 CH340G ATmega328p Compatible Development Board

Run itChange the inputs and watch the output

The PI loop holds 120 rpm. Add load and watch the PWM rise to keep the speed.

Motor fwd 60%
PWM out96 / 255
Serial monitor115200 baud
118.65

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question