Skip to content

About

ESP8266 firmware examples for driving 24 VAC sprinkler solenoids using USB-C Power Delivery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

USB-C Solenoid Driver

ESP8266 firmware examples for driving 24 VAC sprinkler solenoids with USB-C Power Delivery. The repository is one PlatformIO project containing four independently buildable drive methods that share a local CH224 driver in lib/CH224/src.

See the companion article for the circuit and an explanation of each drive method.

Hardware

Prototype circuit board used for the experiments:

USB-C solenoid-driver prototype board

Circuit schematic:

USB-C solenoid-driver schematic

Prerequisites

Install PlatformIO Core, then run commands from this repository's top-level directory.

Firmware environments

Environment Program
method1_pwm Full-voltage activation followed by P2 low-side holding PWM
method2_dualvoltage Dual-voltage drive using P2 low-side as the switch
method3_acsynthesis Timer1 sine synthesis without debug output
method4_squarewave Bipolar square-wave drive

Compile and upload

Compile one program:

pio run -e method4_squarewave

Compile every program:

pio run

Upload one program to the automatically detected serial port:

pio run -e method4_squarewave -t upload

If automatic port detection fails, specify it explicitly:

pio run -e method4_squarewave -t upload --upload-port /dev/ttyUSB0

PlatformIO stores generated firmware under .pio/build/<environment>/. For example, the Method 4 binary is .pio/build/method4_squarewave/firmware.bin. The .pio directory is ignored by Git. Before creating a source-only ZIP, omit that directory or remove generated builds with pio run -t clean.

Configuration and safety

Each program keeps its user-adjustable voltage, current, timing, and frequency constants near the top of its main.cpp. PlatformIO builds the AC-synthesis program at 160 MHz and the simpler programs at 80 MHz as required by their source code.

Before connecting a solenoid, verify all four bridge-control signals and the polarity-reversal dead time with an isolated oscilloscope. Disconnect external VBUS while flashing unless the programming and power paths are known to be isolated.

License

This project is licensed under the MIT License.

About

ESP8266 firmware examples for driving 24 VAC sprinkler solenoids using USB-C Power Delivery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages