Skip to content

charlo016/calibration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Calibration — Solenoid Valve PWM Control

ESP32-S3 firmware to control the opening level of a 12V NC solenoid valve using PWM, for the alambic project.

Objective

Drive a 12V normally-closed solenoid valve at partial opening levels instead of simple on/off. The ESP32 generates a 12-bit PWM signal (0–4095) that switches a MOSFET on the 12V power line of the valve. Adjusting the duty cycle changes the average current in the coil, which holds the plunger at intermediate positions.

Approach change: web interface instead of serial monitor

The first version used the on-board BOOT button to step the duty cycle (+100 per press) and the serial monitor to read the current value. Finding the right frequency/duty combination this way was slow: every frequency change required editing the code and reflashing.

The current version hosts a web server directly on the ESP32. The board creates its own WiFi access point, and a web page with two sliders allows live tuning of both parameters without reflashing:

  • Frequency slider: 50 Hz to 15 kHz
  • Duty slider: 0 to 4095 (12-bit), with live percentage display

Changes are applied in real time while dragging the sliders.

Hardware

Component Role
ESP32-S3 DevKit PWM generation + WiFi AP + web server
IRLZ44N logic-level MOSFET Switches the 12V valve line from a 3.3V gate signal
1N5819 Schottky diode Flyback protection across the valve coil
220 Ω resistor Gate series resistor
10 kΩ resistor Gate pull-down
12V NC solenoid valve Controlled load (water)
12V external supply Valve power (common ground with ESP32)

Wiring details: see circuit_description.md.

Usage

  1. Flash valve_pwm_control/valve_pwm_control.ino on the ESP32-S3 (Arduino IDE or arduino-cli, board esp32:esp32:esp32s3).
  2. Connect to the WiFi network ValveControl (password: valve1234).
  3. Open http://192.168.4.1 in a browser.
  4. Adjust frequency and duty with the sliders; the serial monitor (115200 baud) logs every change.

Notes

A standard on/off solenoid valve is not a proportional valve: the usable duty-cycle range for partial opening is narrow (typically somewhere between ~60% and ~85%), with hysteresis between opening and closing. This is expected physical behavior, not a firmware issue.

About

ESP32-S3 PWM control of a 12V solenoid valve with a web slider interface (WiFi AP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages