No description
Find a file
2025-10-04 10:18:18 +02:00
.cargo Initial commit 2025-10-04 10:18:18 +02:00
docs Initial commit 2025-10-04 10:18:18 +02:00
scripts Initial commit 2025-10-04 10:18:18 +02:00
src Initial commit 2025-10-04 10:18:18 +02:00
.gitignore Initial commit 2025-10-04 10:18:18 +02:00
build.rs Initial commit 2025-10-04 10:18:18 +02:00
Cargo.toml Initial commit 2025-10-04 10:18:18 +02:00
LICENSE Initial commit 2025-10-04 10:18:18 +02:00
README.md Initial commit 2025-10-04 10:18:18 +02:00
run.sh Initial commit 2025-10-04 10:18:18 +02:00
rust-toolchain.toml Initial commit 2025-10-04 10:18:18 +02:00
sdkconfig.defaults Initial commit 2025-10-04 10:18:18 +02:00


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
  1. About The Project
  2. Project Structure
  3. Getting Started
  4. Hardware Requirements
  5. Configuration
  6. Troubleshooting
  7. Future Enhancements
  8. Contributing
  9. License
  10. Contact
  11. Acknowledgments

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

(back to top)

Built With

Rust

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

(back to top)

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

  1. Install espup:
cargo install espup
  1. Install Xtensa ESP32 toolchain:
espup install
  1. Install ldproxy linker:
cargo install ldproxy
  1. Fix libxml2 compatibility (if needed):
mkdir -p ~/.esplib
ln -sf /usr/lib/libxml2.so.16 ~/.esplib/libxml2.so.2
  1. 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

(back to top)

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)

(back to top)

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

(back to top)

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

(back to top)

Future Enhancements

  • Multiple target support
  • Hit timing and scoring
  • Sound feedback

(back to top)

Contributing

Contributions are welcome! Please fork the repository, make your changes, and open a pull request.

  1. Fork the Project on Forgejo
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the European Union Public License v1.2. See LICENSE for more information.

(back to top)

Contact

Aitor Astorga Saez de Vicuña - a.astorga.sdv@protonmail.com

Project Link: https://git.prisma.moe/aichan/diy_fencing_target

(back to top)

Acknowledgments

Thanks to these amazing projects and technologies!

  • esp-rs - Rust on ESP community and tooling
  • ESP-IDF - Espressif IoT Development Framework

(back to top)