HW-517 MOSFET module: motor speed in one direction

The HW-517 is a small blue board that switches a large load from one ESP32 pin. It has two AOD4184 MOSFETs in parallel, a gate resistor, a pull-down resistor and an indicator LED. Connect a motor, a pump, a fan or an LED strip to its output, and send PWM to its TRIG/PWM input to set the speed or the brightness.

It is a low-side switch: it connects the negative side of the load to ground. So it can turn a motor in one direction only. To reverse a motor or to brake it, use an H-bridge such as the L298N. The board does not have a flyback diode. You must add one.

Blue HW-517 board with the J1 signal pads on the left, resistors R1 to R3 and an LED, two black MOSFETs in the middle, and two blue two-way screw terminals on the right
HW-517 module. The signal (TRIG/PWM and GND) connects at J1 on the left. The two screw terminals on the right are for the supply (VIN) and the load (OUT). Examine the labels on your board.

Specifications

ItemValueNotes
Load supply5–36 V DCThe MOSFETs are rated to 40 V.
Load current15 A (seller rating)Optimistic With a 3.3 V signal, plan for a few amps. Refer to the notes below.
Signal3.3–20 VHIGH = on. LOW or not connected = off.
PWM frequency0–20 kHzStart at 1 kHz with an ESP32.
DirectionOne directionFor two directions, use an H-bridge.
Flyback diodeNoneAdd one Necessary for motors, pumps, solenoids and relays.

Wiring

ESP32 GPIO 4 GND HW-517 TRIG/PWM GND VIN+ VIN− OUT+ OUT− Motor supply 5–36 V + − M diode: stripe to OUT+ signal GND = VIN− on the board
HW-517 wiring for one motor. Add the flyback diode across the motor, with the stripe (cathode) to OUT+. The module does not have a diode.

Wiring table

HW-517 terminalConnect toPurpose
VIN+ / VIN−Motor supply + / −Motor power (5–36 V)
OUT+ / OUT−Motor terminalsOUT+ is connected directly to VIN+. OUT− is switched to ground.
TRIG/PWMGPIO 4 (any output pin)HIGH = on. PWM = speed.
GNDESP32 GNDCommon ground (connected to VIN− on the board)

Parts to add

  • Flyback diode across the motor: a Schottky diode such as the SS34 or 1N5822 (3 A), or the SR560 (5 A) for larger motors. Stripe to OUT+.
  • 0.1 µF ceramic capacitor across the motor terminals for brush noise.
  • 100–470 µF electrolytic capacitor across VIN+ and VIN− near the board.
  • A fuse in the VIN+ wire for projects that use a battery.

Limits you must know

The 15 A rating is optimistic

Sellers list 15 A (30 A with extra cooling). But the AOD4184 MOSFETs are specified with a gate voltage of 4.5–10 V. An ESP32 gives only 3.3 V, so the MOSFETs do not switch fully on and they become warmer. With a 3.3 V signal, plan for a few amps.

Test with a stalled motor for a few seconds. Then touch the MOSFETs carefully. If they are too hot to touch, use a larger driver or a logic-level MOSFET with a lower resistance.

PWM frequency

The board accepts up to ~20 kHz. The gate resistor and the two large MOSFETs make the switching edges slow. At each edge, the MOSFETs lose some energy as heat, so a higher frequency gives more heat. Start at 1 kHz. You will hear a quiet whine. Increase the frequency only if the whine is a problem and the MOSFETs stay cool.

Grounds and boot

The signal is not isolated: the signal GND and VIN− are the same connection on the board. Connect the ESP32 GND to it. The on-board pull-down resistor keeps the motor off while the ESP32 boots, so you do not need an external resistor.

Code

Increase and decrease the speed

hw517_ramp.ino


              const int MOTOR_PIN = 4;     // to TRIG/PWM on the HW-517
              const int FREQ = 1000;       // 1 kHz: the MOSFETs stay cool
              const int BITS = 8;          // speed 0..255

              void setup() {
                ledcAttach(MOTOR_PIN, FREQ, BITS);
              }

              void loop() {
                // increase the speed gradually
                for (int s = 0; s <= 255; s += 5) {
                  ledcWrite(MOTOR_PIN, s);
                  delay(30);
                }
                delay(2000);
                // decrease the speed gradually
                for (int s = 255; s >= 0; s -= 5) {
                  ledcWrite(MOTOR_PIN, s);
                  delay(30);
                }
                delay(2000);               // off (coast)
              }
            

Set the speed with a potentiometer

hw517_pot.ino


              const int MOTOR_PIN = 4;     // to TRIG/PWM on the HW-517
              const int POT_PIN = 34;      // potentiometer wiper (ADC1 pin)
              const int FREQ = 1000, BITS = 8;
              const int MIN_DUTY = 60;     // below this, most motors do not turn

              int duty = 0;                // the duty that is sent now

              void setup() {
                ledcAttach(MOTOR_PIN, FREQ, BITS);
                analogReadResolution(12);  // 0..4095
              }

              void loop() {
                int raw = analogRead(POT_PIN);
                int target = map(raw, 0, 4095, 0, 255);
                if (target < MIN_DUTY) target = 0;     // dead zone at the bottom: motor off

                // Soft start: change the duty a small step at a time
                if (duty < target) duty = min(duty + 4, target);
                if (duty > target) duty = max(duty - 8, target);
                ledcWrite(MOTOR_PIN, duty);
                delay(10);
              }
            

Connect the potentiometer ends to 3V3 and GND, and the wiper to GPIO 34. Refer to Potentiometers & joysticks.

Troubleshooting

The motor always turns at full speed

The MOSFETs are damaged (they fail short-circuited), frequently because there was no flyback diode. Disconnect TRIG/PWM. If the motor still turns, replace the board and add the diode.

The motor does not turn

Make sure that the LED comes on when the pin is HIGH. If it does not, examine the signal and ground wires. If the LED comes on, examine the VIN and OUT wires and the motor supply. Very low duty values do not overcome friction.

The MOSFETs are hot

The current is too high for a 3.3 V gate signal, or the PWM frequency is too high. Decrease the frequency to 1 kHz. For larger motors, use a driver with a gate driver chip, or a logic-level MOSFET.

The ESP32 resets when the motor starts

The start current causes a brownout. Use a separate motor supply and connect only the grounds. Add the bulk capacitor at VIN. Increase the speed gradually. Refer to Power supplies.

I need to reverse the motor

The HW-517 cannot reverse a motor. Use an H-bridge: the L298N, or the TB6612FNG or DRV8833 on the DC motors page.

Safety

Stalled motors and overloaded MOSFETs become hot quickly. Keep fingers away from gears and wheels. Install a fuse in projects that use a battery.

Resources