PWM Duty Cycle Adapter

Last updated March 22, 2026


The PWM Duty Cycle Adapter converts a continuous 0–1 control signal (from a PID controller) into a timed on/off pulse pattern suitable for relay-controlled actuators. This gives you proportional-like control over binary devices that can only be fully on or fully off.


When to Use

Use the PWM Duty Cycle Adapter when all three of these conditions are true:

  1. Your controller outputs a continuous signal — A PID controller produces a value between 0.0 and 1.0 (0% to 100%).
  2. Your actuator is binary — A relay, smart plug, or solenoid that is either on or off.
  3. The controlled process has enough thermal mass to smooth out the pulsing — heating elements, slow-response cooling systems, or large water volumes.

Do not use this adapter for:

  • Actuators with native analog/PWM input (variable-speed fans, servo valves) — wire the PID output directly.
  • Compressor-based systems (AC units, refrigerators) — use the HVAC Hysteresis Controller instead. Compressors cannot tolerate rapid on/off cycling.
  • Fast-response processes where pulsing would cause visible oscillation (e.g., lighting).

How It Works

The adapter operates on a fixed cycle period (default 60 seconds). Within each cycle, the relay is on for a fraction of the period proportional to the PID output, and off for the remainder.

PID Output

Relay On Time

Relay Off Time

Behavior

0%

0s

60s

Always off

25%

15s

45s

Quarter duty

50%

30s

30s

Half duty

75%

45s

15s

Three-quarter duty

100%

60s

0s

Always on

This is the same principle as pulse-width modulation in electronics, but at a much slower rate suitable for relays and thermal processes.


Configuration

Cycle Period — The total duration of one on/off cycle in seconds. Default is 60 seconds.

  • Shorter periods (10–30 s) give smoother control but increase relay switching frequency.
  • Longer periods (60–120 s) reduce relay wear but may produce noticeable temperature swings.
  • Match the cycle period to your process response time. A fermentation heat wrap with 5-minute thermal lag can use a 120-second cycle. A small aquarium heater might need 30 seconds.

Minimum On Time — The shortest time the relay will stay on. Default is 0 seconds. Set this to prevent very short pulses that some relays or smart plugs cannot handle reliably. A 2-second minimum is typical for mechanical relays.

Minimum Off Time — The shortest time the relay will stay off between pulses. Default is 0 seconds. Important for actuators that need a brief rest between activations.


Wiring in the Configurator

  1. Add a PID Controller (temperature, humidity, or CO₂) to your room.
  2. Add a PWM Duty Cycle Adapter to the same room.
  3. Add a relay actuator (GPIO relay, smart plug, or Sequent HAT channel).
  4. Wire: Sensor → PID Controller → PWM Duty Cycle Adapter → Relay Actuator.
  5. Configure the PID setpoint and tuning parameters.
  6. Set the PWM cycle period.
  7. Deploy.

The PID controller outputs a continuous value. The PWM adapter converts it to timed relay pulses. The thermal mass of the process smooths the pulsing into an effectively proportional response.


Use Cases

Fermentation Heat Wrap

A homebrew fermenter uses a 40W silicone heat wrap controlled by a relay. The process is too slow for bang-bang control to maintain tight temperature, but the heat wrap has no analog input.

Parts: DS18B20 sensor → PID Temperature Controller → PWM Duty Cycle Adapter (60s cycle) → GPIO Relay.

Result: At 50% PID output, the relay turns the heat wrap on for 30 seconds, off for 30 seconds. The fermenter's thermal mass smooths this into a steady temperature within ±0.2 °C of setpoint.

Sous Vide Water Bath

An immersion heater in a water bath controlled by a relay. Water has excellent thermal mass, making it ideal for duty-cycle control.

Parts: PT100 RTD → PID Temperature Controller → PWM Duty Cycle Adapter (30s cycle) → Relay.


Troubleshooting

The actuator stays fully on or fully off

Check the PID controller output. If the PID is outputting 0.0 or 1.0 constantly, the problem is PID tuning, not the PWM adapter. Reduce the proportional band or check that the sensor is reading correctly.

Visible temperature oscillation

If the temperature swings noticeably with each on/off cycle, reduce the cycle period. A 120-second cycle on a small heater will produce larger swings than a 30-second cycle.

Relay clicks rapidly

If the PID output fluctuates rapidly between values, the relay may switch multiple times per cycle. Add a Rate Limiter upstream of the PWM adapter to smooth the PID output, or increase the PID sample time.


Known Issues and Limitations

Not suitable for compressors — Never use duty-cycle PWM on compressor-based systems. Use the HVAC Hysteresis Controller with minimum run time protection instead.

Relay wear — Mechanical relays have a finite switching life (typically 100,000 cycles). A 60-second cycle period produces ~1,440 switches per day. For high-duty applications, consider a solid-state relay (SSR) which has no mechanical wear.

Pi-side timing — The duty cycle runs in Node-RED on the Pi. If the Pi CPU is heavily loaded, timer accuracy may degrade slightly. This is rarely noticeable in practice.


For PID controller setup and tuning, see PID Controllers.

For binary on/off control without proportional behavior, see Hysteresis Controllers.

For relay and actuator wiring, see Actuators.

pwmduty cyclepidrelayproportional controlcontroller