Skip to content

MohmedhKA/E-Voting-V2-Hardware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blockchain-Based Voting System

πŸ—³οΈ Blockchain E-Voting Terminal - Firmware

Hardware voting terminal firmware for secure blockchain-based electronic voting system
Built with STM32L432KC microcontroller and ESP32 WiFi bridge over 11 months of solo development.

Terminal WiFi Biometric


Project Overview

This project implements a blockchain-based voting system designed to ensure secure, transparent, and tamper-proof elections. The system leverages the STM32 microcontroller and ESP32 for hardware integration, along with custom-built libraries to manage the voting process and blockchain operations.

πŸ—οΈ Hardware Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    STM32L432KC (Main MCU)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚   Keypad     β”‚  β”‚   LCD I2C    β”‚  β”‚   R307 FP    β”‚      β”‚
β”‚  β”‚   Input      β”‚  β”‚   Display    β”‚  β”‚   Sensor     β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚         β”‚                  β”‚                  β”‚              β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β”‚                            β”‚                                 β”‚
β”‚                            β”‚ UART (115200 baud)              β”‚
β”‚                            ↓                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                ESP32-WROOM-32 (WiFi Bridge)                 β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚  β”‚  HTTP Client   β”‚ ←────→  β”‚   TLS/SSL      β”‚             β”‚
β”‚  β”‚  JSON Parser   β”‚         β”‚   Encryption   β”‚             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β”‚                            β”‚                                 β”‚
β”‚                            β”‚ WiFi/HTTPS                      β”‚
β”‚                            ↓                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             ↓
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Backend API   β”‚
                    β”‚  (Node.js)     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             ↓
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Hyperledger   β”‚
                    β”‚  Fabric        β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

Biometric Authentication

  • R307 Fingerprint Sensor integration via UART
  • Template enrollment with 512-byte capacity
  • Real-time matching with adjustable confidence scores
  • Support for 1:1 verification mode

Secure Communication

  • ESP32 WiFi Bridge handles all network operations
  • HTTPS support with TLS 1.2+
  • Certificate validation (configurable)
  • Command-response protocol via UART
  • Automatic retry logic with exponential backoff

User Interface

  • 16x2 LCD Display with I2C interface (PCF8574)
  • 4x4 Matrix Keypad for Aadhaar/VoterID entry
  • Scrolling candidate list navigation
  • Real-time status updates and error messages
  • Loading animations during network operations

Blockchain Integration

  • Direct API calls to Hyperledger Fabric backend
  • Vote submission with cryptographic proofs
  • Receipt polling with transaction IDs
  • Automatic session management
  • Email receipt delivery

Security Features

  • SHA256 hashing for voter identity
  • Fingerprint-based authentication proof
  • OTP verification via email
  • Auth token-based session management
  • No local vote storage (direct blockchain submission)

πŸ› οΈ Hardware Requirements

Component Model/Spec Quantity Purpose
Microcontroller STM32L432KC (NUCLEO-32) 1 Main voting logic controller
WiFi Module ESP32-WROOM-32 DevKit 1 Network communication bridge
Fingerprint Sensor R307 Optical Sensor 1 Biometric authentication
LCD Display 16x2 with I2C (PCF8574) 1 User interface display
Keypad 4x4 Matrix Membrane 1 Data entry (Aadhaar/VoterID)
Power Supply 5V 2A adapter 1 System power
Jumper Wires Male-to-Female 20+ Connections

Optional Components

  • Breadboard or custom PCB
  • Enclosure for terminal housing
  • Buzzer for audio feedback
  • Status LEDs

πŸ”Œ Pin Connections

STM32L432KC Pinout

UART1 - R307 Fingerprint Sensor

PA9  (TX) β†’ R307 RX (Yellow)
PA10 (RX) β†’ R307 TX (White)
         β†’ R307 VCC (Red) β†’ 5V
         β†’ R307 GND (Black) β†’ GND

UART2 - ESP32 Communication Bridge

PA2 (TX) β†’ ESP32 RX (GPIO16)
PA3 (RX) β†’ ESP32 TX (GPIO17)

I2C1 - LCD Display (PCF8574)

PB6 (SCL) β†’ LCD SCL
PB7 (SDA) β†’ LCD SDA
          β†’ LCD VCC β†’ 5V
          β†’ LCD GND β†’ GND

GPIO - 4x4 Keypad Matrix

Rows:
PB0 β†’ Row 1
PB1 β†’ Row 2
PA8 β†’ Row 3
PA11 β†’ Row 4

Columns:
PA0 β†’ Col 1
PA1 β†’ Col 2
PA4 β†’ Col 3
PA5 β†’ Col 4

ESP32-WROOM-32 Pinout

GPIO16 (RX2) β†’ STM32 UART2 TX (PA2)
GPIO17 (TX2) β†’ STM32 UART2 RX (PA3)
GND          β†’ STM32 GND (common ground)

⚠️ Note: ESP32 and STM32 must share common ground. ESP32 runs on 3.3V logic, STM32 UART pins are 5V tolerant.


Folder Structure

Hardware/
β”œβ”€β”€ BlockchainVotingMX_STM32/
β”‚   β”œβ”€β”€ Core/
β”‚   β”‚   β”œβ”€β”€ Inc/                # Header files for STM32
β”‚   β”‚   β”œβ”€β”€ Src/                # Source files for STM32
β”‚   β”‚   └── Startup/            # Startup assembly files
β”‚   β”œβ”€β”€ Drivers/                # STM32 HAL drivers
β”‚   β”œβ”€β”€ Debug/                  # Debugging files
β”‚   └── BlockchainVotingMX.ioc  # STM32CubeMX configuration file
β”œβ”€β”€ Evoting_ESP32/
β”‚   └── Evoting.ino             # Arduino sketch for ESP32
β”œβ”€β”€ LICENSE                     # License file
└── README.md                   # Project documentation

πŸ“± Usage

First-Time Setup

  1. Power on the terminal
  2. Enroll fingerprints (admin mode - if implemented)
  3. Connect to WiFi - ESP32 auto-connects on boot
  4. Verify backend connection - Check LCD for status messages

Voting Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  1. SELECT ELECTION β”‚ ← Navigate with keypad (↑/↓/Enter)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  2. ENTER AADHAAR   β”‚ ← 12-digit Aadhaar number
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  3. ENTER VOTER ID  β”‚ ← Alphanumeric Voter ID
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  4. SCAN FINGERPRINTβ”‚ ← Place finger on R307
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  5. VERIFY IDENTITY β”‚ ← Backend validates with stored template
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  6. SEND OTP        β”‚ ← OTP sent to registered email
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  7. ENTER OTP       β”‚ ← 6-digit OTP code
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  8. VERIFY OTP      β”‚ ← Backend validates OTP
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  9. SELECT CANDIDATEβ”‚ ← Scroll through candidate list
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  10. CONFIRM VOTE   β”‚ ← Press # to confirm, * to cancel
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  11. CAST VOTE      β”‚ ← Vote submitted to blockchain
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  12. WAIT RECEIPT   β”‚ ← Polling blockchain for confirmation
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  13. SHOW RECEIPT   β”‚ ← Display TX ID and success message
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Keypad Controls

β”Œβ”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”
β”‚ 1 β”‚ 2 β”‚ 3 β”‚ A β”‚  A = Up/Previous
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€
β”‚ 4 β”‚ 5 β”‚ 6 β”‚ B β”‚  B = Down/Next
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€
β”‚ 7 β”‚ 8 β”‚ 9 β”‚ C β”‚  C = Clear/Cancel
β”œβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€
β”‚ * β”‚ 0 β”‚ # β”‚ D β”‚  # = Enter/Confirm
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”˜  * = Back/Cancel
                    D = Menu (reserved)

Software Components

  • Custom Libraries:
    • esp32_bridge: Manages communication between STM32 and ESP32.
    • keypad: Handles keypad input.
    • sha256: Provides cryptographic hashing.
    • r307: Interfaces with the biometric sensor.
  • Blockchain Implementation: Ensures secure and immutable vote storage.

Setup Instructions

  1. STM32 Setup:

    • Open the BlockchainVotingMX.ioc file in STM32CubeMX.
    • Generate the code and compile it using STM32CubeIDE.
    • Flash the firmware onto the STM32 microcontroller.
  2. ESP32 Setup:

    • Open the Evoting.ino file in the Arduino IDE.
    • Install the required libraries for ESP32.
    • Upload the sketch to the ESP32 board.
  3. Hardware Connections:

    • Connect the STM32 and ESP32 using UART.
    • Attach the keypad and biometric sensor to the STM32.
  4. Run the System:

    • Power on the hardware.
    • Follow the on-screen instructions to cast votes.

⭐ Star History

If this project helped you or inspired your work, please give it a ⭐!


πŸ“Š Project Stats

  • Lines of Code: ~3000+ (STM32) + ~800+ (ESP32)
  • Development Time: 11 months
  • Languages: C, C++
  • Hardware Platforms: STM32L4, ESP32
  • Communication Protocols: UART, I2C, HTTP/HTTPS
  • Security: SHA256, TLS, Fingerprint biometrics

Built with ❀️ and countless cups of coffee β˜•

"From concept to completion, every line of code tells a story of persistence."

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the terms of the LICENSE file.

Acknowledgments

  • Special thanks to the open-source community for providing tools and libraries that made this project possible.

About

This is the Hardware setup for my E-voting system

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages