Owner: Kaveesha Abeysundara (SID: 201578163)
Project: Automated Tracking of Assembly Line-Side Flow Rack Parts
School of Mechanical Engineering
University of Leeds
LS2 9JT
Arduino firmware for individual sensor modules in an automated flow rack tracking system, leveraging VL53L1X ToF measurements and ESP-NOW communication.
- About
- Hardware Setup
- Prerequisites
- Installation
- Usage
- Data Structures & Communication
- Repository Structure
- License
- Contact
This repository hosts the Arduino sketch (SensorModule.ino) and supporting headers for each sensor node. Sensor modules measure distances to part boxes using a STMicroelectronics VL53L1X time-of-flight sensor, compute part counts in real time with rolling averages and Six Sigma filtering, and transmit results to a rack-level transmitter via ESP-NOW.
| Connection | ESP32 Pin | Description |
|---|---|---|
| VIN | 5V | Sensor power (5V rail) |
| GND | GND | Common ground |
| SDA | 21 | I2C data line |
| SCL | 22 | I2C clock line |
| XSHUT | 19 | Optional sensor reset control |
Ensure all power and ground rails are shared between sensor and ESP32.
- Arduino IDE v1.8.10+ with ESP32 board support
- Adafruit_VL53L1X or Pololu VL53L1X Arduino library
- ESP32 Arduino libraries for ESP-NOW
- USB cable and ESP32 development board
git clone https://github.com/kav12ab/sensormodulecode.git
cd sensormodulecode- Open
SensorModule.inoin the Arduino IDE. - Install required libraries via Sketch → Include Library → Manage Libraries.
- Configure
SensorIDand peer MAC addresses inconfig.h.
- Select ESP32 Dev Module and correct COM port.
- Upload
SensorModule.inoto each ESP32 sensor node. - Monitor serial output at 115200 baud for status and debug messages.
- Verify LED indicators: solid green for normal operation; other colours for sensor errors.
Sensor modules build a data packet containing:
scanID(unique sensor identifier)boxCount(calculated number of boxes)autoMode(bool flag for automatic box size detection)autoBoxSize(measured box size in mm)
These packets are sent via ESP-NOW to the rack transmitter. Retries and callbacks are managed in comms.h.
sensormodulecode/
├── .vscode/ # JSON files for VSCODE Arduino Configuration
├── build/ # Build logs, libraries and other files
├── ESP32_VL53L1X_Wiring_Diagram.png # Wiring Diagram
├── sensor.ino # Main programme
├── .h and .cpp files # Custom libraries to support main program functionality
└── README.md # This file
Given below is a table with the core code components and their functionalities
| File | Purpose |
|---|---|
Sensor.ino |
Main programme that schedules, coordinates and calls functions in other header files and handles error logic. Contains an editable global variable section for easy deployment. |
Espnowsetup.h |
Manages wireless communication including initialization, peer addition, data transmission, and handling send status via ESP-NOW. |
VL53L1XHandler.h / VL53L1XHandler.cpp |
Initializes and manages the VL53L1X sensor, processes distance measurements with rolling averages and stability thresholds, and computes the number of boxes in the rack. Also auto-calculates box sizes. |
WifiSetup.h |
Configures the device as a Wi-Fi station to support ESP-NOW transmissions. |
LEDControl.h / LEDControl.cpp |
Provides visual feedback by controlling an RGB LED, indicating success or failure of operations. |
All rights reserved.
This firmware and documentation are proprietary. No part may be copied, modified, or distributed without permission.
Author: Kaveesha Abeysundara (SID: 201578163)
Open an issue at sensormodulecode issues.
