Skip to content

Repository files navigation

ReworkTC - PID Temperature Controller

A versatile PID temperature controller designed for soldering rework stations, reflow ovens, and other precision temperature control applications. Supports ESP32 (with display and Bluetooth) and Arduino Nano (minimal configuration). Features thermocouple temperature sensing, optional OLED display, and Bluetooth/Serial control interface.

Features

  • PID Temperature Control: Precise temperature regulation with tunable PID parameters (Kp, Ki, Kd)
  • Auto-Tune: Automatic PID parameter optimization using relay-feedback method
  • Power Control: Configurable maximum power limit and manual power override for safety and testing
  • Temperature Bridge Mode: Host-driven temperature input for bridged/multi-device setups (thermocouple ignored)
  • MAX6675 Thermocouple Interface: Accurate temperature readings up to 1024°C
  • Multiple Board Support: ESP32 (full features), Arduino Uno, or Arduino Nano
  • OLED Display: Real-time temperature, power percentage, and status display (ESP32)
  • Dual Control Interface: Bluetooth and Serial command support
  • Time-Proportional SSR Control: Smooth 2-second cycle PWM for solid-state relays
  • Persistent Settings: PID parameters and setpoint stored in flash/EEPROM
  • Improved PID Algorithm: Fast 250ms updates with derivative filtering and smart anti-windup
  • Open Source: MIT licensed for easy modification and integration

Hardware Requirements

Supported Boards

ESP32 (Full Features)

  • Board: Heltec WiFi Kit 32 or compatible ESP32
  • Features: Display, Bluetooth, persistent settings, all commands
  • Environment: heltec_wifi_kit_32

Arduino Uno (Recommended for Production)

  • Board: Arduino Uno (ATmega328P)
  • Features: Serial control, persistent EEPROM settings, reliable USB (ATmega16U2/FTDI)
  • Environment: uno
  • Note: More reliable serial communication than Nano clones with CH340

Arduino Nano (Budget Option)

  • Board: Arduino Nano (AT, Arduino Uno, or Arduino Nano
  • MAX6675 Thermocouple Interface Module
  • K-Type Thermocouple
  • Solid State Relay (SSR) for heater control
  • SSD1306 OLED Display (128x64, I2C) - ESP32 only
  • Optional: External FT232 USB-Serial module for reliable Nano serial communication

Core Components

  • ESP32 Development Board or Arduino Nano
  • MAX6675 Thermocouple Interface Module
  • K-Type Thermocouple
  • Solid State Relay (SSR) for heater control
  • SSD1306 OLED Display (128x64, I2C) - ESP32 only

Connections

ESP32 Configuration

MAX6675 Thermocouple Module
  • CLK → GPIO 18
  • CS → GPIO 5
  • DO → GPIO 19
  • VCC → 3.3V
  • GND → GND
SSR Control
  • SSR Signal → GPIO 25
  • Status LED → GPIO 22
OLED Displa/Uno Configuration
MAX6675 Thermocouple Module
  • CLK → Digital Pin 7
  • CS → Digital Pin 8
  • DO → Digital Pin 6
  • VCC → 5V
  • GND → GND
SSR Control
  • SSR Signal → Digital Pin 3 (PWM)
  • Status LED → Digital Pin 13 (Built-in LED)

Note: For Nano with CH340 USB chip issues, connect external FT232 module to TX/RX pins for reliable serial communication.

  • DO → Digital Pin 6
  • VCC → 5V
  • GND → GND
SSR Control
  • SSR Signal → Digital Pin 3 (PWM)
  • Status LED → Digital Pin 13 (Built-in LED)

Software Requirements

  • PlatformIO (recommended) or Arduino IDE
  • Required Libraries (ESP32 only):
    • Adafruit GFX Library
    • Adafruit SSD1306

Building the Project

Using PlatformIO (Recommended)

  1. Clone or download the repository

    git clone <repository-url>
    cd ReworkTc
  2. Build for ESP32

    pio run -e heltec_wiUno**
    ```bash
    pio run -e uno
  3. Build for Arduino Nano

    pio run -e nanoatmega328

5 pio run -e nESP32**

pio run -e heltec_wifi_kit_32 --target upload --upload-port COMX
  1. Upload to Arduino Uno

    pio run -e uno --target upload --upload-port COMX
  2. Upload to Arduino Nano

    pio run -e nanoatmega328 --target upload --upload-port COMX

    Replace COMX with your board's serial port (e.g., COM7 on Windows, /dev/ttyUSB0 on Linux)

8 ```

  1. Upload to Arduino Nano

    pio run -e nanoatmega328 --target upload --upload-port COMX

    Replace COMX with your board's serial port (e.g., COM7 on Windows, /dev/ttyUSB0 on Linux)

  2. Monitor Serial Output

    pio device monitor

Using Arduino IDE

  1. Install ESP32 board support
  2. Install required libraries via Library Manager
  3. Open src/main.cpp and compile
  4. Upload to your ESP32 board

Configuration

Build Flags

Edit platformio.ini to customize pin assignments and features:

build_flags = 
    -DBT_ENABLED=1              ; Enable (1) or disable (0) Bluetooth
    -DDISABLE_DISPLAY=0         ; Disable display if not used
    -DPID_OUTPUT_PIN=25         ; SSR control pin
    -DHEATER_LED_PIN=22         ; Status LED pin
    -DSSR_PERIOD_MS=2000        ; SSR PWM cycle time (ms)
    -DMAX6675_CLK=18            ; MAX6675 clock pin(ESP32) and Serial. 

Serial Settings:

  • ESP32: 115200 baud
  • Arduino Uno/Nano: 9600 baud
  • Format: 8-N-1 (8 data bits, no parity, 1 stop bit)

Commands are case-sensitive and end with newline (\n).

Available Commands

Command Description Example
SET:<temp> Set target temperature (0-400°C) SET:250
ON Enable PID controller ON
OFF Disable PID controller OFF
STATUS Get current status STATUS
KP:<value> Set proportional gain KP:10.0
KI:<value> Set integral gain KI:0.5
KD:<value> Set derivative gain KD:50.0
TUNE Start PID auto-tune TUNE
POWER:<value> Manual power override (0-100%) POWER:50
RELEASE Release manual power control RELEASE
MAXPOWER:<value> Set maximum power limit (saved) MAXPOWER:80
TBRDG:ON Enable temperature bridge mode TBRDG:ON
TBRDG:OFF Disable temperature bridge mode TBRDG:OFF
BRT:<temp> Host-reported temperature in bridge mode BRT:75
HELP Show command list HELP

OK Setpoint=120 (saved)

MAXPOWER:80 OK Max power limit set to 80% (saved)

POWER:50 OK Power set to 50% (manual override)

RELEASE OK Power control released to PID

TUNE OK Auto-tune started. Wait 5-10 minutes... WARNING: Monitor temperature! Stop if unstable.

[Wait for auto-tune to complete...]

Auto-tune complete! Kp=12.34 Ki=0.67 Kd=45.21

ON OK PID=ON

STATUS SETPOINT:120 ENABLED:1 TEMP:119.8 POWER:28 MAX_POWER:80 HOLD:0 KP:12.34 KI:0.67 KD:45.21 MAX_POWER:100 VERSION:1.4 BRIDGE:0 AT:0

Power Control Features

Maximum Power Limit (MAXPOWER:<value>)

Set a maximum power limit to restrict PID output. Useful for safety or when working with delicate components.

  • Range: 0-100% (default: 100%)
  • Automatically saved to non-volatile memory
  • Enforced in both normal PID mode and auto-tune mode
  • Example: MAXPOWER:75 limits heater to 75% maximum power

Manual Power Override (POWER:<value> and RELEASE)

Temporarily override PID control with manual power setting for testing or manual temperature control.

  • POWER:<value> - Set manual power level (0-100%) and hold
  • RELEASE - Release manual control back to PID
  • While in manual mode, display shows "HOLD" indicator
  • STATUS command shows HOLD:1 when active
  • Example use case: Test heater operation without PID

Example:

POWER:50
OK Power set to 50% (manual override)

[Test heater at 50% power...]

RELEASE
OK Power control released to PID

Temperature Bridge Mode

Temperature bridge mode lets the host machine supply the temperature instead of the onboard thermocouple. This is used when two controllers are bridged together, so one unit's measured temperature drives the other.

  • TBRDG:ON - Enable temperature bridge. The device stops reading the thermocouple (whether connected or not) and uses the temperature reported by the host.
  • TBRDG:OFF - Disable temperature bridge. The device resumes reading the thermocouple and operates normally.
  • BRT:<temp> - Host-reported temperature (0-400°C). The host should send this every second while bridged.

While bridged, the STATUS response includes BRIDGE:1; otherwise it includes BRIDGE:0.

Example:

TBRDG:ON
OK Temperature bridge ON

BRT:75
OK Bridge temperature=75

STATUS
SETPOINT:120 ENABLED:1 TEMP:75.0 POWER:28 BRIDGE:1 ...

TBRDG:OFF
OK Temperature bridge OFF

Automatic Tuning (Recommended)

The controller includes an auto-tune feature that uses relay-feedback method with Ziegler-Nichols tuning:

  1. Set target temperature: SET:120
  2. Start auto-tune: TUNE
  3. Wait 5-10 minutes while the system oscillates
  4. Parameters automatically calculated and saved

The auto-tune will:

  • Heat to setpoint then cycle on/off
  • Measure oscillation amplitude and period
  • Calculate optimal PID values
  • Save to EEPROM/flash automatically

** Monitor temperature during auto-tune!** Stop if unstable.

Manual Tuning

Default PID values work well for most systems:

  • Smart anti-windup protection for integral term
  • Power output clamped to 0-100%
  • Time-proportional control for SSR longevity
  • Thermocouple open-circuit detection
  • Derivative filtering reduces noise-induced instability
  • Auto-tune monitors oscillations to prevent runaway To manually adjust:
  1. Start with defaults: KP:10.0, KI:0.5, KD:50.0
  2. If overshoots: Reduce Kp or increase Kd
  3. If slow response: Increase Kp
  4. If doesn't reach setpoint: Increase Ki
  5. If oscillates: Reduce Kp and Ki, increase Kd

Values are automatically saved to persistent storage.

PID Algorithm Details

  • Update rate: 250ms (4 Hz) for responsive control
  • Derivative filtering: Low-pass filter reduces thermocouple noise
  • Smart anti-windup: Integral only accumulates when output is 5-95%
  • Direct percentage output: 0-100% power to heater

License

Copyright (c) 2025 Black Horse Repairs LLC

Licensed under the MIT License. See project files for full license text.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Support

For support and questions, please open an issue on the repository.

About

External PID controller for Rework Pro

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages