.cargo | ||
docs | ||
scripts | ||
src | ||
.gitignore | ||
build.rs | ||
Cargo.toml | ||
LICENSE | ||
README.md | ||
run.sh | ||
rust-toolchain.toml | ||
sdkconfig.defaults |
DIY Fencing Target
A Rust based ESP32 project for a DIY fencing target. The final goal is to build a replacement of the Favero EFT-1 fencing target, but for a much lower cost (the EFT-1 is around 645€).
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
Current README
is the initial phase of this project, for now simulating a fencing target with visual feedback using LEDs and button input.
What It Does
This firmware creates a simple fencing target simulator that:
- Monitors a button connected to GPIO27 (simulating a hit sensor)
- Controls two LEDs:
- Red LED (GPIO25): ON when target is ready/idle
- Green LED (GPIO26): ON when target is "hit" (button pressed)
- Provides logging output via serial monitor showing hit events
- Runs continuously checking for hits every 50ms
Hardware Behavior
- Normal state: Red LED on, Green LED off
- Hit detected (button pressed): Red LED off, Green LED on
- Button released: Returns to normal state
Built With
Project Structure
The project is organized as follows:
diy_fencing_target/
├── src/
│ └── main.rs # Main application code
├── .cargo/
│ └── config.toml # ESP32 build configuration
├── docs/
│ └── favero/ # Reference materials for Favero EFT-1 target
├── Cargo.toml # Project dependencies
├── run.sh # Quick start build/flash script
└── README.md # This file
Getting Started
Follow these instructions to set up a local instance of the DIY Fencing Target firmware.
Prerequisites
System Requirements (Arch Linux)
# Install required system libraries
sudo pacman -S libxml2
Rust ESP32 Toolchain Setup
- Install espup:
cargo install espup
- Install Xtensa ESP32 toolchain:
espup install
- Install ldproxy linker:
cargo install ldproxy
- Fix libxml2 compatibility (if needed):
mkdir -p ~/.esplib
ln -sf /usr/lib/libxml2.so.16 ~/.esplib/libxml2.so.2
- Install espflash (for flashing to device):
cargo install espflash
Quick Start
For a quick start, simply use the provided script:
./run.sh
This script will:
- Set up the ESP environment variables
- Build the firmware
- Flash it to your ESP32
- Open the serial monitor
Device Permissions
Before flashing, check your USB device permissions:
ls -l /dev/ttyUSB0
Permanent solution (recommended):
sudo usermod -aG uucp <YOUR_USER>
# Log out and log in again for changes to take effect
Temporary execution:
sudo chmod 666 /dev/ttyUSB0
Hardware Requirements
- ESP32 development board
- 2x LEDs (red and green)
- 2x 220Ω resistors (for LEDs)
- 1x Push button/switch
- Breadboard and jumper wires
Wiring Diagram
ESP32 GPIO25 → [220Ω Resistor] → Red LED (+) → GND
ESP32 GPIO26 → [220Ω Resistor] → Green LED (+) → GND
ESP32 GPIO27 → Button → GND (internal pull-up enabled)
Configuration
Pin Configuration
Edit src/main.rs
to change GPIO pins:
let mut red_led = PinDriver::output(peripherals.pins.gpio25)?; // Red LED
let mut green_led = PinDriver::output(peripherals.pins.gpio26)?; // Green LED
let mut button = PinDriver::input(peripherals.pins.gpio27)?; // Button
Polling Interval
Change the delay in the main loop (currently 50ms):
FreeRtos::delay_ms(50); // Check every 50 milliseconds
Troubleshooting
Build fails with "can't find crate for core"
Make sure you've sourced the ESP environment and set RUSTUP_TOOLCHAIN:
source ~/export-esp.sh
export RUSTUP_TOOLCHAIN=esp
Linker error with ldproxy
Ensure ldproxy is installed and the config.toml has the correct linker settings.
libxml2.so.2 not found
Create the symlink:
mkdir -p ~/.esplib
ln -sf /usr/lib/libxml2.so.16 ~/.esplib/libxml2.so.2
export LD_LIBRARY_PATH=~/.esplib:$LD_LIBRARY_PATH
Device not detected
Check USB connection and permissions:
ls -l /dev/ttyUSB0
sudo usermod -aG uucp <YOUR_USER>
# Log out and back in for changes to take effect
Future Enhancements
- Multiple target support
- Hit timing and scoring
- Sound feedback
Contributing
Contributions are welcome! Please fork the repository, make your changes, and open a pull request.
- Fork the Project on Forgejo
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the European Union Public License v1.2. See LICENSE
for more information.
Contact
Aitor Astorga Saez de Vicuña - a.astorga.sdv@protonmail.com
Project Link: https://git.prisma.moe/aichan/diy_fencing_target
Acknowledgments
Thanks to these amazing projects and technologies!