Smart Factory Projects using Acebott Education Solution Series QE031 Smart Factory Education Kit – Level 1

01 Overview
This set of projects demonstrates how to build several smart factory automation systems using the Acebott Education Solution Series QE031 Smart Factory Education Kit – Level 1, powered by the ESP32 microcontroller. The kit allows users — especially engineering students, STEM educators, and makers — to explore real-world industrial automation and IoT monitoring concepts through hands-on learning.
We created five projects to showcase different aspects of smart factory automation, each focusing on a specific industrial application. Two of these projects feature MQTT-based cloud dashboards using HiveMQ and Node-RED for real-time IoT monitoring.
Project 1 — Smart Robotic Arm
A four-degree-of-freedom robotic arm controlled manually using two I2C joystick modules. The left joystick controls the shoulder and chassis (base rotation), while the right joystick controls the elbow and claw, allowing full manual pick-and-place operation.
Project 2 — Automated Sorting System
An automated conveyor-based sorting system that uses a color sensor to identify the color of objects on the belt and a servo-driven sorting gate to route them. An infrared sensor detects when an object arrives at the sensing area.
Project 3 — Smart Warehouse + MQTT Dashboard
A smart warehouse management system that tracks incoming and outgoing goods using RFID, an LCD display for local inventory, a keypad for manual retrieval, and an MQTT-based cloud dashboard using HiveMQ and Node-RED for real-time remote monitoring.
Project 4 — Smart Trash Bin Sorter
A custom-built automated trash sorting system that uses RFID tags to classify waste into three categories — biodegradable, non-biodegradable, and recyclable — and routes each item to its corresponding bin using the robotic arm.
Project 5 — Smart Inspection & Sorting Line + MQTT Dashboard
A custom-built smart inspection and sorting line that automatically identifies items via RFID and routes them to the correct output lane. Items with unknown or missing RFID tags are classified as defective and moved to a reject lane. All data is published to an MQTT dashboard via HiveMQ and Node-RED.
02 Hardware and Software Components
Gather everything below before you start. The Acebott QE031 kit includes most of these components.
Hardware Components
| Component | Description |
|---|---|
| Acebott ESP32 QA018 Max V3.0 Board | Main microcontroller with built-in Wi-Fi and Bluetooth |
| ESP32 Expansion Board | Provides labeled I/O ports for clean and reliable module connections |
| Robotic Arm Kit (4 Servos) | Four-servo arm with chassis, shoulder, elbow, and claw joints |
| Dual Joystick Modules (I2C) | Two I2C joysticks for manual control of the robotic arm (Project 1) |
| Color Sensor Module (I2C) | Detects the color of objects on the conveyor belt (Project 2) |
| DC Motor + Motor Driver | Powers the conveyor belt; driver controls speed and direction via PWM |
| Sorting Gate Servo | Single servo that diverts objects into the correct lane (Project 2) |
| RFID Module (I2C) | Reads RFID tag UIDs to identify objects (Projects 3, 4, 5) |
| RFID Tags / IC Cards (3 pcs) | Color-coded tags (Red, Green, Blue) attached to objects for identification |
| Infrared Obstacle Avoidance Sensor | Detects object presence at the sensing or sorting area |
| LCD1602 (I2C) | 16x2 character display for real-time inventory counts and status |
| 4-Button Keypad Module | Analog keypad for manual goods retrieval (Project 3) |
| Conveyor Belt Assembly | Motorized belt for transporting objects from input to sorting area |
| Colored Wooden Boxes (3 pcs) | Blue, Red, and Green bins used in the Trash Bin Sorter project |
Software Tools
| Software | Version / Details |
|---|---|
| Arduino IDE | Version 2.x (recommended) |
| ESP32 Board Package | Version 2.0.12 (install via Arduino Board Manager) |
| ACB_JoyStick_I2C Library | Acebott joystick library — for Project 1 |
| ACB_ColorSensor Library | Acebott color sensor library — for Project 2 |
| ESP32Servo Library | Servo control for ESP32 — for Projects 1 and 2 |
| ACB_ARM Library | Acebott robotic arm control library — for Projects 3, 4, 5 |
| MFRC522_I2C Library | RFID module control via I2C — for Projects 3, 4, 5 |
| hd44780 Library | LCD1602 I2C display control — for Projects 3, 4, 5 |
| PubSubClient Library | MQTT client by Nick O'Leary — for Projects 3 and 5 |
| HiveMQ Cloud | Free cloud MQTT broker — for Projects 3 and 5 |
| Node-RED | Flow-based dashboard tool — for Projects 3 and 5 |
| @flowfuse/node-red-dashboard | Node-RED dashboard UI nodes — for Projects 3 and 5 |
03 Application Discussion
Here is what each key component does and why it is part of these projects.
ESP32 (Acebott QA018 Max V3.0)
The ESP32 is a low-power, highly integrated Wi-Fi and Bluetooth dual-mode microcontroller developed by Espressif Systems. It serves as the main controller for all five projects — processing sensor data, controlling servos and motors, and in Projects 3 and 5, managing Wi-Fi connectivity and MQTT communication with the cloud broker.
ESP32 Expansion Board
The expansion board sits on top of the ESP32 and provides clearly labeled 3-pin and 4-pin ports for sensors and modules. It simplifies wiring connections, reduces the risk of short circuits, and makes assembly much cleaner for multi-component projects like these.
Robotic Arm (4 Servos)
The robotic arm consists of four servo motors controlling the chassis (base rotation), shoulder, elbow, and claw joints. In Project 1 it is controlled manually with joysticks; in Projects 3, 4, and 5 it is controlled programmatically using the ACB_ARM library to perform automated pick-and-place operations.
Dual Joystick Modules (I2C)
Two I2C joystick modules provide manual control of the robotic arm in Project 1. Each joystick reports X, Y, and switch (SW) values over the I2C bus. The left joystick controls the shoulder and chassis joints, and the right joystick controls the elbow and claw, giving the operator full manual control over all four degrees of freedom.
Color Sensor Module (I2C)
The color sensor reads the red, green, and blue light values reflected from an object on the conveyor belt. In Project 2, these values are compared to determine the object's color, which then triggers the sorting gate servo to route the object to the correct position.
DC Motor
The DC motor is the actuator that physically drives the conveyor belt, transporting objects from the input area to the sensing or sorting area. It converts electrical energy into the rotational motion that moves the belt, and is started and stopped at key moments during the sorting process.
Motor Driver
The motor driver acts as the bridge between the ESP32 and the DC motor. Because the ESP32's GPIO pins cannot supply enough current to power a motor directly, the driver takes the low-power PWM signals from the ESP32 and uses them to control the higher-power output to the motor, regulating its speed and direction safely.
RFID Module and IC Cards
The RFID module reads the unique ID (UID) stored on each IC card attached to an object. Since each tag has a unique UID, the system identifies which object is on the belt without needing a color sensor or camera. Three tags are used — one each for Red, Green, and Blue categories — in Projects 3, 4, and 5.
Infrared Obstacle Avoidance Sensor
The IR sensor detects when a physical object has arrived at the sensing or sorting area of the conveyor belt. The program waits for the IR sensor to confirm arrival before stopping the belt and triggering the next action. In Project 5, the IR sensor also serves as a defect detector — if an object triggers the IR sensor without a valid RFID scan, it is classified as defective.
LCD1602 (I2C)
The 16x2 LCD display provides local real-time feedback, showing inventory counts, sorting results, and system status messages. It communicates with the ESP32 via the I2C bus (address 0x27), sharing the same SDA/SCL lines as the RFID module.
4-Button Keypad Module
The keypad is an analog input module with four color-coded buttons. Each button produces a different analog voltage level when pressed, which the ESP32 reads on a single analog pin (GPIO 36). In Project 3, the Blue, Green, and Red buttons trigger goods retrieval from the corresponding warehouse shelf.
HiveMQ Cloud + Node-RED (Projects 3 and 5)
HiveMQ Cloud is a free cloud-based MQTT broker that acts as the message relay between the ESP32 and the Node-RED dashboard. The ESP32 publishes inventory and event data to specific MQTT topics on HiveMQ, and Node-RED subscribes to those topics to display live data on a web-based dashboard. This stack enables real-time remote monitoring without requiring a local server.
04 Getting Started: Arduino IDE Installation
All five projects are programmed using the Arduino IDE. Follow these steps once to set up your environment before starting any project.
Step 1 — Download and Install Arduino IDE
- Go to the official Arduino website at arduino.cc and open the Software / Downloads page.
- Download the Arduino IDE 2.x version for your operating system (Windows, macOS, or Linux).
- Run the installer and follow the on-screen instructions to complete the installation.
- Open the Arduino IDE once installation is finished.
Step 2 — Add the ESP32 Board Package
- Open the Arduino IDE and go to File → Preferences.
- In the Additional Boards Manager URLs field, paste the ESP32 board package URL, then click OK.
- Go to Tools → Board → Boards Manager.
- Search for ESP32, select version 2.0.12, and click Install.
Step 3 — Select the Board and Port
- Connect the ESP32 to your computer with a USB cable.
- Go to Tools → Board and select ESP32 Dev Module.
- Go to Tools → Port and select the COM port that appears for your ESP32.
Step 4 — Install Project Libraries
Each project lists the specific libraries it needs in its own Software Setup section. To install a library, go to Sketch → Include Library → Manage Libraries, search for the library name, and click Install. Acebott-specific libraries (ACB_JoyStick_I2C, ACB_ColorSensor, ACB_ARM) are included in the kit resources if they are not found in the Library Manager.
05 MQTT Dashboard Setup (HiveMQ + Node-RED)
Projects 3 and 5 send live data to a cloud dashboard for real-time remote monitoring. This shared setup uses HiveMQ Cloud as the MQTT broker and Node-RED as the dashboard. Complete this setup once, then reuse it for both projects. Each project simply publishes to its own set of MQTT topics.
Part A — Set Up the HiveMQ Cloud Broker
- Go to hivemq.com and create a free account, then log in to the HiveMQ Cloud console.
- Create a new Serverless cluster (free tier).
- Once the cluster is created, HiveMQ automatically generates a unique connection gateway for you — this includes your own Broker URL (host), the secure TLS Port (8883), and a WebSocket port (8884). Copy your Broker URL; it is unique to your cluster.
- Open the cluster, go to Access Management, and create your own credentials — set your username and password, with Publish and Subscribe permission.
Part B — Install Node.js and Node-RED
- Download and install Node.js (LTS version) from nodejs.org.
- Open Command Prompt (or Terminal) and install Node-RED globally with the command below.
- After installation, start Node-RED by typing node-red and pressing Enter.
- Open a web browser and go to the Node-RED editor at the local address shown in the terminal.
Install Node-RED
npm install -g --unsafe-perm node-red
Start Node-RED
node-red
Then open the editor in your browser:
127.0.0.1:1880
Part C — Install the Dashboard Package
- In the Node-RED editor, click the menu (top right) and choose Manage Palette.
- Go to the Install tab and search for @flowfuse/node-red-dashboard.
- Click Install. The dashboard UI nodes (gauges, text, etc.) will be added to your palette.
Part D — Connect Node-RED to HiveMQ
Each project uses mqtt in nodes to receive data. When you configure the first mqtt in node, you will create a broker (server) configuration that all the other nodes can reuse:
- Drag an mqtt in node onto the flow and double-click it.
- Beside the Server field, click the pencil icon to add a new broker.
- Enter your HiveMQ Broker URL in the Server field and set the Port to 8883.
- Go to the Security tab and enter your HiveMQ username and password.
- Go to the Connection tab, enable Use TLS, and add a blank TLS configuration entry (click the pencil beside TLS, add nothing, and Save).
- Click Add / Update to save the broker, then set the node's Topic to the project topic you want to monitor.
Part E — Build the Dashboard Flow
This is how we built our dashboard flow in Node-RED. The structure is the same for both Project 3 and Project 5 — only the topics and the number of values differ. The general pattern is: mqtt in node → function node → display/gauge node.
- Add one mqtt in node for each topic the project publishes (for example, the inventory topic, the sorted topic, the defect topic, and the status topic).
- For simple text values (such as status messages), connect the mqtt in node directly to a text display node so the latest message is shown on the dashboard.
- For the combined inventory string (for example, "R:2 G:1 B:3 DEF:1"), connect the inventory mqtt in node to a function node that splits the string into separate values. We named this node "Split Inventory."
- The Split Inventory function stores each number in a flow variable, and a small "Get" function node for each color reads its value back out.
- Connect each "Get" function node to its own gauge node — for example Get Red to a Red Gauge, Get Green to a Green Gauge, Get Blue to a Blue Gauge, and Get Defect to a Defect Gauge.
- Click Deploy to save and activate the flow.
The screenshot above shows our finished flow: the Inventory topic feeds the Split Inventory function, which fans out to Get Red, Get Green, Get Blue, and Get Defect function nodes, each driving its own gauge. The Sorted, Defect, and Status topics feed text display nodes directly.
Part F — View the Live Dashboard
After deploying, open the dashboard in your browser to see the live data update in real time as the ESP32 publishes events:
127.0.0.1:1880/dashboard
This is the final product — a live dashboard showing the gauges and status messages updating automatically whenever the system sorts or stores an item.
Project 1
Smart Robotic Arm
Acebott QE031 Smart Factory Education Kit – Level 1
06 Hardware Setup
Assemble the robotic arm following the kit manual, then connect the four servos and the two I2C joystick modules.
Servo Pin Connections
| Servo Joint | ESP32 Pin |
|---|---|
| Chassis (Base Rotation) | GPIO 5 |
| Shoulder | GPIO 12 |
| Elbow | GPIO 18 |
| Claw | GPIO 19 |
Joystick Connections
Both joystick modules connect to the I2C bus on the expansion board. In the code they are initialized as separate objects — the left joystick uses channels (0, 1, 2) and the right joystick uses channels (3, 4, 5).
Control Mapping
| Joystick Movement | Arm Action |
|---|---|
| Left joystick X | Shoulder up / down |
| Left joystick Y | Chassis left / right |
| Right joystick X | Elbow up / down |
| Right joystick Y | Claw open / close |
07 Software Setup
Step 1 — Install Libraries
Install via the Arduino Library Manager (or from kit resources):
- ACB_JoyStick_I2C — Acebott joystick library
- ESP32Servo — servo control for ESP32
Step 2 — Upload the Code
- Open the P1 sketch in Arduino IDE.
- Select ESP32 Dev Module and the correct COM port under Tools.
- Click Upload and wait for "Done uploading."
08 Code
P1_SmartRoboticArm.ino
#include <ACB_JoyStick_I2C.h> // import joystick control library
#include <ESP32Servo.h> // import servo library
// declare pins of servos:
#define chassisPin 5
#define shoulderPin 12
#define elbowPin 18
#define clawPin 19
// create joystick objects:
ACB_JoyStick_I2C LeftJoyStick;
ACB_JoyStick_I2C RightJoyStick;
// create servo objects:
Servo chassis_servo;
Servo shoulder_servo;
Servo elbow_servo;
Servo claw_servo;
// initial values of angles
int chassis_angle = 90;
int shoulder_angle = 90;
int elbow_angle = 90;
int claw_angle = 90;
void setup() {
// initial servos
chassis_servo.attach(chassisPin);
delay(200);
shoulder_servo.attach(shoulderPin);
delay(200);
elbow_servo.attach(elbowPin);
delay(200);
claw_servo.attach(clawPin);
delay(200);
chassis_servo.write(chassis_angle);
delay(10);
shoulder_servo.write(shoulder_angle);
delay(10);
elbow_servo.write(elbow_angle);
delay(10);
claw_servo.write(claw_angle);
delay(10);
Serial.begin(115200);
// initial joystick modules
LeftJoyStick.init(0, 1, 2);
RightJoyStick.init(3, 4, 5);
}
void loop() {
LeftJoyStick.Get_JoyStick(); // get left joystick values
RightJoyStick.Get_JoyStick(); // get left joystick values
// print values of joystick
Serial.println("----------------------------");
Serial.println(" ");
Serial.print("LeftX: ");
Serial.print(LeftJoyStick.X);
Serial.print(" ,LeftY: ");
Serial.print(LeftJoyStick.Y);
Serial.print(" ,LeftSW: ");
Serial.print(LeftJoyStick.SW);
Serial.println(" ");
Serial.print("RightX: ");
Serial.print(RightJoyStick.X);
Serial.print(" ,RightY: ");
Serial.print(RightJoyStick.Y);
Serial.print(" ,RightSW: ");
Serial.print(RightJoyStick.SW);
Serial.println(" ");
Serial.println("----------------------------");
if (LeftJoyStick.X > 3500) { // if left joystick moved down
shoulder_angle--; // decrease angle of shoulder servo
if (shoulder_angle < 0) { // set limitation of servo
shoulder_angle = 0;
}
// shoulder joint moves up:
shoulder_servo.write(shoulder_angle);
delay(10);
}
if (LeftJoyStick.X < 200) { // if left joystick moved up
shoulder_angle++; // increase angle of shoulder servo
if (shoulder_angle > 180) { // set limitation of servo
shoulder_angle = 180;
}
// shoulder joint moves down:
shoulder_servo.write(shoulder_angle);
delay(10);
}
if (LeftJoyStick.Y < 200) { // if left joystick moved to the left
chassis_angle++; // increase angle of chassis servo
if (chassis_angle > 180) {
chassis_angle = 180;
}
// chassis joint moves to the left:
chassis_servo.write(chassis_angle);
delay(10);
}
if (LeftJoyStick.Y > 3500) { // if left joystick moved to the right
chassis_angle--; // decrease angle of chassis servo
if (chassis_angle < 0) {
chassis_angle = 0;
}
// chassis joint moves to the right:
chassis_servo.write(chassis_angle);
delay(10);
}
if (RightJoyStick.X > 3500) { // if right joystick moved up
elbow_angle--; // decrease angle of elbow servo
if (elbow_angle < 0) {
elbow_angle = 0;
}
// elbow joint moves down:
elbow_servo.write(elbow_angle);
delay(10);
}
if (RightJoyStick.X < 200) { // if right joystick moved down
elbow_angle++; // increase angle of elbow servo
if (elbow_angle > 180) {
elbow_angle = 180;
}
// elbow joint moves up:
elbow_servo.write(elbow_angle);
delay(10);
}
if (RightJoyStick.Y > 3500) { // if right joystick moved to the left
claw_angle++; // increase angle of elbow servo
if (claw_angle > 180) {
claw_angle = 180;
}
// open the gripper:
claw_servo.write(claw_angle);
delay(10);
}
if (RightJoyStick.Y < 200) { // if right joystick moved to the right
claw_angle--; // decrease angle of elbow servo
if (claw_angle < 90) {
claw_angle = 90;
}
// close the gripper:
claw_servo.write(claw_angle);
delay(10);
}
}
09 Code Breakdown
Libraries
| Library | Purpose |
|---|---|
| ACB_JoyStick_I2C.h | Reads X, Y, and switch values from the I2C joystick modules |
| ESP32Servo.h | Controls servo motors on the ESP32 |
Key Functions
setup()
Attaches all four servos to their pins, moves them to the initial 90-degree position, starts serial communication at 115200 baud, and initializes the two joystick modules on their I2C channels.
Get_JoyStick()
Reads the current X, Y, and switch (SW) values from a joystick module. Called for both joysticks at the start of every loop.
loop() — control logic
Compares each joystick axis against threshold values (above 3500 or below 200) to detect direction. When a threshold is crossed, the matching joint angle is increased or decreased by one step, clamped within its allowed range, and written to the servo.
General Program Workflow
- On startup, all servos move to their neutral 90-degree position.
- Each loop reads both joysticks and prints their values to the Serial Monitor.
- If a joystick axis is pushed past its threshold, the corresponding joint angle changes by one step.
- Each angle is limited to a safe range before being sent to the servo.
- The result is smooth, continuous manual control of all four arm joints.
10 Testing and Calibration
Joystick Response Test
Open the Serial Monitor at 115200 baud and move each joystick. Confirm the printed X and Y values change as expected. Then verify each arm joint moves in the correct direction when you push the matching joystick.
Project 2
Automated Sorting System
Acebott QE031 Smart Factory Education Kit – Level 1
06 Hardware Setup
This project uses the conveyor belt, a color sensor, an IR sensor, and a single sorting gate servo.
Pin Connections
| Component | ESP32 Pin |
|---|---|
| DC Motor Driver IN1 (IN-) | GPIO 16 |
| DC Motor Driver IN2 (IN+) | GPIO 17 |
| IR Obstacle Sensor | GPIO 32 |
| Sorting Gate Servo | GPIO 4 |
| Color Sensor (I2C) | I2C bus (SDA / SCL) |
Sorting Positions
The sorting gate servo moves to a different angle depending on the detected color. The initial (resting) position is 175 degrees.
| Detected Color | Servo Angle |
|---|---|
| Red | 115° |
| Green | 40° |
| Initial position | 175° |
07 Software Setup
Step 1 — Install Libraries
Install via the Arduino Library Manager (or from kit resources):
- ACB_ColorSensor — Acebott color sensor library
- ESP32Servo — servo control for ESP32
Step 2 — Upload the Code
- Open the P2 sketch in Arduino IDE.
- Select ESP32 Dev Module and the correct COM port.
- Click Upload.
08 Code
P2_AutomatedSortingSystem.ino
#include <ACB_ColorSensor.h> // import library of color sensor
#include <ESP32Servo.h> // import library of servo
// declare names of strings:
#define R "red"
#define G "green"
#define B "blue"
#define IR 32 // declare the pin of infrared obstacle avoidance sensor
#define IN1 16 // declare the IN- pin of driver module
#define IN2 17 // declare the IN+ pin of driver module
#define SERVO_PIN 4 // declare the pin of servo
ACB_ColorSensor colorSensor; // creat a color sensor object
Servo servo; // creat a servo object
void setup() {
pinMode(IR, INPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
servo.attach(SERVO_PIN); // initial servo
delay(200);
servo.write(175); // servo move to initial position
delay(10);
Serial.begin(115200); // set baud rate
}
int red_value; // value of red light from color sensor
int green_value; // value of green light from color sensor
int blue_value; // value of blue light from color sensor
int IR_value; // value of infrared obstacle avoidance sensor
void loop() {
conveyorRun(255); // run conveyor
IR_value = digitalRead(IR); // read value of infrared obstacle avoidance sensor
if (!IR_value) { // if object is detected
conveyorRun(0); // stop conveyor
for (int i = 0; i < 5; i++) { // read light values from color sensor
red_value = colorSensor.read(R);
green_value = colorSensor.read(G);
blue_value = colorSensor.read(B);
delay(200);
}
if (red_value > green_value && red_value > blue_value) {
// if the object is red
servo.write(115); // servo rotate to 115°
delay(10);
}
if (green_value > red_value && blue_value < green_value) {
// if the object is green
servo.write(40); // servo rotate to 40°
delay(40);
}
conveyorRun(255); // run conveyor
delay(3000); // delay 2s
servo.write(175); // servo rotate to 175°
delay(10);
}
Serial.print("IR:"); // print values of all sensors
Serial.println(IR_value);
Serial.print("R:");
Serial.println(red_value);
Serial.print("G:");
Serial.println(green_value);
Serial.print("B:");
Serial.println(blue_value);
}
void conveyorRun(int speed) { // define function of controlling conveyor
analogWrite(IN1, speed);
digitalWrite(IN2, 0);
delay(10);
}
09 Code Breakdown
Libraries
| Library | Purpose |
|---|---|
| ACB_ColorSensor.h | Reads red, green, and blue light values from the color sensor |
| ESP32Servo.h | Controls the sorting gate servo |
Key Functions
conveyorRun(speed)
Controls the conveyor belt motor via PWM. Passing 255 runs the belt at full speed; passing 0 stops it.
colorSensor.read()
Reads the light intensity value for a given color channel (red, green, or blue). The code reads each channel five times to get a stable reading before deciding the object's color.
loop() — sorting logic
Runs the conveyor until the IR sensor detects an object, then stops the belt and reads the color. If red is the highest value, the servo moves to 115°; if green is highest, it moves to 40°. The belt then resumes and the servo returns to its 175° initial position.
General Program Workflow
- The conveyor belt runs continuously.
- When the IR sensor detects an object, the belt stops.
- The color sensor reads the red, green, and blue values five times.
- The values are compared to determine the object's color.
- The sorting gate servo rotates to the matching angle to divert the object.
- The belt resumes, the servo returns to its initial position, and all sensor values are printed to the Serial Monitor.
10 Testing and Calibration
Color Detection Test
Open the Serial Monitor at 115200 baud and place objects of different colors under the sensor. Confirm the R, G, and B values change and that the highest value matches the object's actual color.
Sorting Gate Test
Place a red object on the belt and confirm the servo moves to 115°; place a green object and confirm it moves to 40°. If the gate does not divert the object correctly, adjust the servo angles in the code to match your physical setup.
Project 3
Smart Warehouse + MQTT Dashboard
Acebott QE031 Smart Factory Education Kit – Level 1
06 Hardware Setup
Pin Connections
| Component | ESP32 Pin |
|---|---|
| DC Motor Driver IN1 | GPIO 16 |
| DC Motor Driver IN2 | GPIO 17 |
| IR Obstacle Sensor | GPIO 32 |
| Chassis Servo | GPIO 5 |
| Shoulder Servo | GPIO 12 |
| Elbow Servo | GPIO 18 |
| Claw Servo | GPIO 19 |
| Keypad (Analog) | GPIO 36 |
| RFID Module (I2C) | SDA: GPIO 21 / SCL: GPIO 22 |
| LCD1602 (I2C) | SDA: GPIO 21 / SCL: GPIO 22 (shared bus) |
07 Software Setup
Step 1 — Install Libraries
Install via Arduino Library Manager:
- ACB_ARM — Acebott robotic arm library
- MFRC522_I2C — RFID module via I2C
- hd44780 — LCD1602 I2C display
- PubSubClient — MQTT client by Nick O'Leary
Step 2 — Configure Wi-Fi and MQTT
Before uploading, replace the placeholders in the code with your own values:
- YOUR_WIFI_NAME and YOUR_WIFI_PASSWORD — your Wi-Fi credentials
- YOUR_BROKER_URL — your HiveMQ Broker URL (from Section 05)
- YOUR_USERNAME and YOUR_PASSWORD — the HiveMQ credentials you created
Step 3 — Node-RED Topics
In your Node-RED dashboard (see Section 05), add mqtt in nodes for these topics:
| Node Name | MQTT Topic |
|---|---|
| Inventory | warehouse/inventory |
| Goods In | warehouse/goodsin |
| Goods Out | warehouse/goodsout |
| Status | warehouse/status |
Step 4 — Upload the Code
- Select ESP32 Dev Module and the correct COM port.
- Click Upload.
- Open Serial Monitor at 115200 baud to verify Wi-Fi and HiveMQ connection messages.
08 Code
P3_SmartWarehouse_MQTT.ino
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#include "MFRC522_I2C.h"
#include <ACB_ARM.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqtt_broker = "YOUR_BROKER_URL";
const int mqtt_port = 8883;
const char* mqtt_username = "YOUR_USERNAME";
const char* mqtt_password = "YOUR_PASSWORD";
const char* topic_inventory = "warehouse/inventory";
const char* topic_goodsin = "warehouse/goodsin";
const char* topic_goodsout = "warehouse/goodsout";
const char* topic_status = "warehouse/status";
#define IN1 16
#define IN2 17
#define IR 32
#define CHASSIS_PIN 5
#define SHOULDER_PIN 12
#define ELBOW_PIN 18
#define CLAW_PIN 19
#define BUTTON_PIN 36
#define R "444fb4eba2a81"
#define G "493f54eba2a81"
#define B "434144fba2a81"
const int i2cAddress = 0x27;
const int numRows = 2;
const int numCols = 16;
hd44780_I2Cexp lcd(i2cAddress, numRows, numCols);
MFRC522_I2C mfrc522(0x28, -1);
ACB_ARM myArm;
WiFiClientSecure espClient;
PubSubClient mqttClient(espClient);
String rfid_str = "";
int rNum = 0;
int gNum = 0;
int bNum = 0;
void connectWiFi() {
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println("
WiFi connected!");
}
void connectMQTT() {
espClient.setInsecure();
mqttClient.setServer(mqtt_broker, mqtt_port);
while (!mqttClient.connected()) {
String clientId = "ESP32Client-" + String(random(0xffff), HEX);
if (mqttClient.connect(clientId.c_str(), mqtt_username, mqtt_password)) {
Serial.println("Connected to HiveMQ!");
} else { delay(2000); }
}
}
void publishInventory() {
String payload = "R:" + String(rNum) + " G:" + String(gNum) + " B:" + String(bNum);
mqttClient.publish(topic_inventory, payload.c_str());
Serial.println("Published inventory: " + payload);
}
void setup() {
Serial.begin(115200);
Wire.begin();
mfrc522.PCD_Init();
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IR, INPUT);
lcd.begin(numCols, numRows); lcd.backlight(); delay(500); lcd.clear();
myArm.ARM_init(CHASSIS_PIN, SHOULDER_PIN, ELBOW_PIN, CLAW_PIN);
myArm.Speed(40);
connectWiFi(); connectMQTT();
}
void loop() {
if (!mqttClient.connected()) connectMQTT();
mqttClient.loop();
lcd.setCursor(0, 0); lcd.print("GOODS LIST:");
lcd.setCursor(0, 1); lcd.print("R:"); lcd.print(rNum);
lcd.setCursor(6, 1); lcd.print("G:"); lcd.print(gNum);
lcd.setCursor(12, 1); lcd.print("B:"); lcd.print(bNum);
publishInventory();
GoodsOut();
GoodsIn();
}
void conveyorRun(int speed) { analogWrite(IN1, speed); digitalWrite(IN2, 0); delay(10); }
void MoveToStart() {
myArm.ChassisCmd(0); myArm.ClawsCmd(120); myArm.ShoulderCmd(110);
myArm.ElbowCmd(70); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90);
}
void MoveToR1() { myArm.ChassisCmd(75); myArm.ElbowCmd(120); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToG1() { myArm.ChassisCmd(95); myArm.ElbowCmd(115); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToB1() { myArm.ChassisCmd(82); myArm.ElbowCmd(75); myArm.ShoulderCmd(116); delay(500); myArm.ClawsCmd(110); }
void MoveToR2() { myArm.ClawsCmd(115); myArm.ChassisCmd(65); myArm.ElbowCmd(120); myArm.ShoulderCmd(130); myArm.ClawsCmd(90); myArm.ShoulderCmd(90); }
void MoveToG2() { myArm.ClawsCmd(113); myArm.ChassisCmd(90); myArm.ElbowCmd(120); myArm.ShoulderCmd(130); myArm.ClawsCmd(90); myArm.ShoulderCmd(90); }
void MoveToB2() { myArm.ClawsCmd(120); myArm.ChassisCmd(73); myArm.ElbowCmd(75); myArm.ShoulderCmd(118); myArm.ClawsCmd(90); myArm.ShoulderCmd(90); myArm.ElbowCmd(90); }
void MoveToEnd() { myArm.ChassisCmd(145); myArm.ShoulderCmd(130); myArm.ElbowCmd(70); myArm.ClawsCmd(120); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90); myArm.ChassisCmd(90); }
void GoodsIn() {
conveyorRun(255);
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) { delay(50); return; }
rfid_str = "";
Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++) rfid_str += String(mfrc522.uid.uidByte[i], HEX);
Serial.println(rfid_str);
while (digitalRead(IR)); conveyorRun(0); MoveToStart();
if (rfid_str == R) { MoveToR1(); rNum++; mqttClient.publish(topic_goodsin, "Red object stored"); }
if (rfid_str == G) { MoveToG1(); gNum++; mqttClient.publish(topic_goodsin, "Green object stored"); }
if (rfid_str == B) { MoveToB1(); bNum++; mqttClient.publish(topic_goodsin, "Blue object stored"); }
publishInventory();
myArm.ShoulderCmd(90); myArm.ElbowCmd(90); myArm.ChassisCmd(90); myArm.ClawsCmd(90);
}
void GoodsOut() {
if (analogRead(BUTTON_PIN) == 0) { delay(200); if (analogRead(BUTTON_PIN) == 0) {
if (bNum > 0) { conveyorRun(0); MoveToB2(); MoveToEnd(); bNum--; mqttClient.publish(topic_goodsout, "Blue object retrieved"); publishInventory(); }
else { mqttClient.publish(topic_status, "Blue - No Stock!"); lcd.clear(); lcd.setCursor(0,0); lcd.print("In No Stock!"); delay(2000); lcd.clear(); }
}}
if (analogRead(BUTTON_PIN) < 1000 && analogRead(BUTTON_PIN) > 0) { delay(200); if (analogRead(BUTTON_PIN) < 1000 && analogRead(BUTTON_PIN) > 0) {
if (gNum > 0) { conveyorRun(0); MoveToG2(); MoveToEnd(); gNum--; mqttClient.publish(topic_goodsout, "Green object retrieved"); publishInventory(); }
else { mqttClient.publish(topic_status, "Green - No Stock!"); lcd.clear(); lcd.setCursor(0,0); lcd.print("In No Stock!"); delay(2000); lcd.clear(); }
}}
if (analogRead(BUTTON_PIN) > 1000 && analogRead(BUTTON_PIN) < 2000) { delay(200); if (analogRead(BUTTON_PIN) > 1000 && analogRead(BUTTON_PIN) < 2000) {
if (rNum > 0) { conveyorRun(0); MoveToR2(); MoveToEnd(); rNum--; mqttClient.publish(topic_goodsout, "Red object retrieved"); publishInventory(); }
else { mqttClient.publish(topic_status, "Red - No Stock!"); lcd.clear(); lcd.setCursor(0,0); lcd.print("In No Stock!"); delay(2000); lcd.clear(); }
}}
}
09 Code Breakdown
Libraries
| Library | Purpose |
|---|---|
| Wire.h | I2C communication for RFID and LCD modules |
| hd44780.h / hd44780_I2Cexp.h | Controls the LCD1602 display via I2C |
| MFRC522_I2C.h | Reads RFID tag UIDs via I2C |
| ACB_ARM.h | Controls the four-joint robotic arm |
| WiFi.h | Manages Wi-Fi connection on the ESP32 |
| WiFiClientSecure.h | Enables TLS connections for MQTT over port 8883 |
| PubSubClient.h | MQTT client for publishing to HiveMQ topics |
Key Functions
connectWiFi()
Connects the ESP32 to the specified Wi-Fi network and waits until a connection is established.
connectMQTT()
Connects the ESP32 to the HiveMQ Cloud broker using TLS. setInsecure() skips certificate verification for the free tier. A random client ID is generated on each connection to avoid conflicts.
publishInventory()
Publishes current inventory counts as a formatted string (e.g., "R:2 G:1 B:3") to the warehouse/inventory topic. Called after every Goods In and Goods Out event.
GoodsIn()
Runs the conveyor, polls the RFID reader, waits for IR confirmation, then picks up the object and places it on the matching shelf. Increments the inventory count and publishes the event to MQTT.
GoodsOut()
Reads the analog keypad. Each button (Blue = 0, Green = 1–999, Red = 1000–1999) triggers retrieval from the corresponding shelf if stock is available. If no stock remains, an alert appears on the LCD and is published to MQTT.
General Program Workflow
- The ESP32 connects to Wi-Fi and then to HiveMQ on startup.
- Every loop displays the current inventory on the LCD and publishes it to MQTT.
- GoodsOut() checks for a keypad button press and handles retrieval if stock is available.
- GoodsIn() runs the conveyor, waits for RFID scan and IR confirmation, then sorts the item to the correct shelf and updates inventory.
- All events are published to MQTT and appear live on the Node-RED dashboard.
10 Testing and Calibration
Wi-Fi and MQTT Connection Test
Open Serial Monitor at 115200 baud. You should see "WiFi connected!" followed by "Connected to HiveMQ!" and repeated "Published inventory" messages confirming the MQTT connection is active.
Dashboard Test
Open your Node-RED dashboard. The Inventory, Goods In, Goods Out, and Status fields should update in real time as the ESP32 publishes events.
Project 4
Smart Trash Bin Sorter
Custom Project — Acebott QE031 Smart Factory Education Kit – Level 1
06 Hardware Setup
Pin Connections
| Component | ESP32 Pin |
|---|---|
| DC Motor Driver IN1 | GPIO 16 |
| DC Motor Driver IN2 | GPIO 17 |
| IR Obstacle Sensor | GPIO 32 |
| Chassis Servo | GPIO 5 |
| Shoulder Servo | GPIO 12 |
| Elbow Servo | GPIO 18 |
| Claw Servo | GPIO 19 |
| RFID Module (I2C) | SDA: GPIO 21 / SCL: GPIO 22 |
| LCD1602 (I2C) | SDA: GPIO 21 / SCL: GPIO 22 (shared bus) |
Bin Layout
Place the three wooden bins within reach of the robotic arm. The servo angle values in the code are calibration placeholders — adjust them during hardware testing to match the exact position of each bin.
| Bin Color | Waste Category |
|---|---|
| Red bin | Non-biodegradable |
| Green bin | Biodegradable |
| Blue bin | Recyclable |
07 Software Setup
Step 1 — Install Libraries
Install via Arduino Library Manager:
- ACB_ARM — Acebott robotic arm library
- MFRC522_I2C — RFID module via I2C
- hd44780 — LCD1602 I2C display
Step 2 — Upload and Calibrate
- Upload the code to the ESP32.
- Place a tagged object on the belt and observe where the arm drops it.
- Adjust ChassisCmd, ElbowCmd, and ShoulderCmd values in MoveToRedBox(), MoveToGreenBox(), and MoveToBlueBox() until the arm accurately places items in each bin.
- Re-upload after each adjustment.
08 Code
P4_SmartTrashBinSorter.ino
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#include "MFRC522_I2C.h"
#include <ACB_ARM.h>
#define IN1 16
#define IN2 17
#define IR 32
#define CHASSIS_PIN 5
#define SHOULDER_PIN 12
#define ELBOW_PIN 18
#define CLAW_PIN 19
#define R "444fb4eba2a81" // Non-biodegradable
#define G "493f54eba2a81" // Biodegradable
#define B "434144fba2a81" // Recyclable
const int i2cAddress = 0x27;
const int numRows = 2;
const int numCols = 16;
hd44780_I2Cexp lcd(i2cAddress, numRows, numCols);
MFRC522_I2C mfrc522(0x28, -1);
ACB_ARM myArm;
String rfid_str = "";
int nonBioNum = 0;
int bioNum = 0;
int recNum = 0;
void setup() {
Serial.begin(115200);
Wire.begin();
mfrc522.PCD_Init();
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IR, INPUT);
lcd.begin(numCols, numRows); lcd.backlight(); delay(500); lcd.clear();
myArm.ARM_init(CHASSIS_PIN, SHOULDER_PIN, ELBOW_PIN, CLAW_PIN);
myArm.Speed(40);
lcd.setCursor(0, 0); lcd.print("Smart Trash");
lcd.setCursor(0, 1); lcd.print("Bin Sorter");
delay(2000); lcd.clear();
}
void loop() {
lcd.setCursor(0, 0); lcd.print("NB:"); lcd.print(nonBioNum);
lcd.setCursor(8, 0); lcd.print("BI:"); lcd.print(bioNum);
lcd.setCursor(0, 1); lcd.print("RC:"); lcd.print(recNum);
SortTrash();
}
void conveyorRun(int speed) { analogWrite(IN1, speed); digitalWrite(IN2, 0); delay(10); }
void SortTrash() {
conveyorRun(255);
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) { delay(50); return; }
rfid_str = "";
Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++) rfid_str += String(mfrc522.uid.uidByte[i], HEX);
Serial.println(rfid_str);
while (digitalRead(IR)); conveyorRun(0); MoveToStart();
if (rfid_str == R) {
MoveToRedBox(); nonBioNum++;
lcd.clear(); lcd.setCursor(0,0); lcd.print("NON-BIO"); lcd.setCursor(0,1); lcd.print("Sorted!"); delay(1000);
} else if (rfid_str == G) {
MoveToGreenBox(); bioNum++;
lcd.clear(); lcd.setCursor(0,0); lcd.print("BIO"); lcd.setCursor(0,1); lcd.print("Sorted!"); delay(1000);
} else if (rfid_str == B) {
MoveToBlueBox(); recNum++;
lcd.clear(); lcd.setCursor(0,0); lcd.print("RECYCLABLE"); lcd.setCursor(0,1); lcd.print("Sorted!"); delay(1000);
} else {
conveyorRun(255);
lcd.clear(); lcd.setCursor(0,0); lcd.print("Unknown!"); lcd.setCursor(0,1); lcd.print("Check trash!"); delay(2000); conveyorRun(0);
}
myArmHome(); lcd.clear();
}
void MoveToStart() {
myArm.ChassisCmd(0); myArm.ClawsCmd(120); myArm.ShoulderCmd(110);
myArm.ElbowCmd(70); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90);
}
// TODO: Calibrate these values during hardware testing
void MoveToRedBox() { myArm.ChassisCmd(75); myArm.ElbowCmd(120); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToGreenBox() { myArm.ChassisCmd(95); myArm.ElbowCmd(115); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToBlueBox() { myArm.ChassisCmd(175); myArm.ShoulderCmd(125); myArm.ElbowCmd(70); myArm.ClawsCmd(120); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90); myArm.ChassisCmd(90); }
void myArmHome() { myArm.ShoulderCmd(90); myArm.ElbowCmd(90); myArm.ChassisCmd(90); myArm.ClawsCmd(90); }
09 Code Breakdown
Libraries
| Library | Purpose |
|---|---|
| Wire.h | I2C communication |
| hd44780.h / hd44780_I2Cexp.h | LCD1602 display control |
| MFRC522_I2C.h | RFID tag reading via I2C |
| ACB_ARM.h | Robotic arm servo control |
Key Functions
SortTrash()
The main sorting function. Runs the conveyor, reads the RFID tag, waits for IR confirmation, picks up the object, and routes it to the matching bin. If the UID is unknown, the conveyor moves the object out and an Unknown message is displayed on the LCD.
MoveToRedBox(), MoveToGreenBox(), MoveToBlueBox()
Each function moves the arm to the corresponding bin position and releases the claw to deposit the object. Servo angle values require calibration based on the physical placement of the bins.
myArmHome()
Returns all servo joints to the neutral home position (90 degrees each) after every sorting operation.
General Program Workflow
- On startup, the LCD displays "Smart Trash Bin Sorter" for 2 seconds, then switches to the bin count display.
- The conveyor runs continuously, polling the RFID reader.
- When a tag is detected, the program reads the UID and waits for the IR sensor to confirm arrival.
- The arm picks up the object and places it in the matching bin (Red, Green, or Blue).
- The bin count increments and is shown on the LCD.
- If the UID is unrecognized, the conveyor moves the object out and the LCD shows "Unknown!"
10 Testing and Calibration
Bin Position Calibration
Place each bin within the arm's reach and run the system with a tagged object. Observe where the arm drops it and adjust the servo angles incrementally. Start with ChassisCmd (left/right rotation), then fine-tune ShoulderCmd and ElbowCmd.
Project 5
Smart Inspection & Sorting Line + MQTT Dashboard
Custom Project — Acebott QE031 Smart Factory Education Kit – Level 1
06 Hardware Setup
Pin Connections
| Component | ESP32 Pin |
|---|---|
| DC Motor Driver IN1 | GPIO 16 |
| DC Motor Driver IN2 | GPIO 17 |
| IR Obstacle Sensor | GPIO 32 |
| Chassis Servo | GPIO 5 |
| Shoulder Servo | GPIO 12 |
| Elbow Servo | GPIO 18 |
| Claw Servo | GPIO 19 |
| RFID Module (I2C) | SDA: GPIO 21 / SCL: GPIO 22 |
| LCD1602 (I2C) | SDA: GPIO 21 / SCL: GPIO 22 (shared bus) |
Defect Detection Logic
This project uses two automatic defect detection methods — no manual intervention required:
- Unknown RFID UID — if the scanned tag does not match any known UID (R, G, B), the item is classified as defective and sent to the reject lane.
- IR detected without RFID scan — if the IR sensor detects an object on the belt without a corresponding RFID read, the item is classified as untagged/defective and sent to the reject lane.
07 Software Setup
Step 1 — Install Libraries
Install via Arduino Library Manager:
- ACB_ARM — Acebott robotic arm library
- MFRC522_I2C — RFID module via I2C
- hd44780 — LCD1602 I2C display
- PubSubClient — MQTT client by Nick O'Leary
Step 2 — Configure Wi-Fi and MQTT
Before uploading, replace the placeholders with your own values:
- YOUR_WIFI_NAME and YOUR_WIFI_PASSWORD — your Wi-Fi credentials
- YOUR_BROKER_URL — your HiveMQ Broker URL (from Section 05)
- YOUR_USERNAME and YOUR_PASSWORD — the HiveMQ credentials you created
Step 3 — Node-RED Topics
In your Node-RED dashboard (see Section 05), add mqtt in nodes for these topics:
| Node Name | MQTT Topic |
|---|---|
| Inventory | inspection/inventory |
| Sorted | inspection/sorted |
| Defect | inspection/defect |
| Status | inspection/status |
Step 4 — Upload the Code
- Select ESP32 Dev Module and the correct COM port.
- Click Upload.
- Open Serial Monitor at 115200 baud to verify connection messages.
08 Code
P5_SmartInspectionSortingLine.ino
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#include "MFRC522_I2C.h"
#include <ACB_ARM.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqtt_broker = "YOUR_BROKER_URL";
const int mqtt_port = 8883;
const char* mqtt_username = "YOUR_USERNAME";
const char* mqtt_password = "YOUR_PASSWORD";
const char* topic_inventory = "inspection/inventory";
const char* topic_sorted = "inspection/sorted";
const char* topic_defect = "inspection/defect";
const char* topic_status = "inspection/status";
#define IN1 16
#define IN2 17
#define IR 32
#define CHASSIS_PIN 5
#define SHOULDER_PIN 12
#define ELBOW_PIN 18
#define CLAW_PIN 19
#define R "444fb4eba2a81"
#define G "493f54eba2a81"
#define B "434144fba2a81"
const int i2cAddress = 0x27;
const int numRows = 2;
const int numCols = 16;
hd44780_I2Cexp lcd(i2cAddress, numRows, numCols);
MFRC522_I2C mfrc522(0x28, -1);
ACB_ARM myArm;
WiFiClientSecure espClient;
PubSubClient mqttClient(espClient);
String rfid_str = "";
int rNum = 0;
int gNum = 0;
int bNum = 0;
int defNum = 0;
void connectWiFi() {
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println("
WiFi connected!");
}
void connectMQTT() {
espClient.setInsecure();
mqttClient.setServer(mqtt_broker, mqtt_port);
while (!mqttClient.connected()) {
String clientId = "ESP32Client-" + String(random(0xffff), HEX);
if (mqttClient.connect(clientId.c_str(), mqtt_username, mqtt_password)) {
Serial.println("Connected to HiveMQ!");
} else { delay(2000); }
}
}
void publishInventory() {
String payload = "R:" + String(rNum) + " G:" + String(gNum) + " B:" + String(bNum) + " DEF:" + String(defNum);
mqttClient.publish(topic_inventory, payload.c_str());
Serial.println("Published: " + payload);
}
void setup() {
Serial.begin(115200);
Wire.begin();
mfrc522.PCD_Init();
pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IR, INPUT);
lcd.begin(numCols, numRows); lcd.backlight(); delay(500); lcd.clear();
myArm.ARM_init(CHASSIS_PIN, SHOULDER_PIN, ELBOW_PIN, CLAW_PIN);
myArm.Speed(40);
connectWiFi(); connectMQTT();
}
void loop() {
if (!mqttClient.connected()) connectMQTT();
mqttClient.loop();
lcd.setCursor(0, 0); lcd.print("R:"); lcd.print(rNum);
lcd.setCursor(4, 0); lcd.print("G:"); lcd.print(gNum);
lcd.setCursor(8, 0); lcd.print("B:"); lcd.print(bNum);
lcd.setCursor(0, 1); lcd.print("DEF:"); lcd.print(defNum);
publishInventory();
Inspect();
}
void conveyorRun(int speed) { analogWrite(IN1, speed); digitalWrite(IN2, 0); delay(10); }
void Inspect() {
conveyorRun(255);
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
delay(50);
if (!digitalRead(IR)) {
conveyorRun(0); MoveToStart(); MoveToReject(); defNum++;
mqttClient.publish(topic_defect, "No RFID - Defective item rejected");
publishInventory(); myArmHome();
}
return;
}
rfid_str = "";
for (byte i = 0; i < mfrc522.uid.size; i++) rfid_str += String(mfrc522.uid.uidByte[i], HEX);
Serial.println(rfid_str);
while (digitalRead(IR)); conveyorRun(0); MoveToStart();
if (rfid_str == R) {
MoveToR(); rNum++; mqttClient.publish(topic_sorted, "Red item sorted");
lcd.clear(); lcd.setCursor(0,0); lcd.print("Sorted: RED"); delay(1000);
} else if (rfid_str == G) {
MoveToG(); gNum++; mqttClient.publish(topic_sorted, "Green item sorted");
lcd.clear(); lcd.setCursor(0,0); lcd.print("Sorted: GREEN"); delay(1000);
} else if (rfid_str == B) {
MoveToB(); bNum++; mqttClient.publish(topic_sorted, "Blue item sorted");
lcd.clear(); lcd.setCursor(0,0); lcd.print("Sorted: BLUE"); delay(1000);
} else {
MoveToReject(); defNum++; mqttClient.publish(topic_defect, "Unknown RFID - Defective item rejected");
lcd.clear(); lcd.setCursor(0,0); lcd.print("DEFECTIVE!"); delay(1000);
}
publishInventory(); myArmHome(); lcd.clear();
}
void MoveToStart() {
myArm.ChassisCmd(0); myArm.ClawsCmd(120); myArm.ShoulderCmd(110);
myArm.ElbowCmd(70); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90);
}
void MoveToR() { myArm.ChassisCmd(75); myArm.ElbowCmd(120); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToG() { myArm.ChassisCmd(95); myArm.ElbowCmd(115); myArm.ShoulderCmd(135); delay(500); myArm.ClawsCmd(110); }
void MoveToB() { myArm.ChassisCmd(82); myArm.ElbowCmd(75); myArm.ShoulderCmd(116); delay(500); myArm.ClawsCmd(110); }
void MoveToReject() { myArm.ChassisCmd(175); myArm.ShoulderCmd(125); myArm.ElbowCmd(70); myArm.ClawsCmd(120); myArm.ClawsCmd(90); myArm.ElbowCmd(90); myArm.ShoulderCmd(90); myArm.ChassisCmd(90); }
void myArmHome() { myArm.ShoulderCmd(90); myArm.ElbowCmd(90); myArm.ChassisCmd(90); myArm.ClawsCmd(90); }
09 Code Breakdown
Libraries
| Library | Purpose |
|---|---|
| Wire.h | I2C communication for RFID and LCD |
| hd44780.h / hd44780_I2Cexp.h | LCD1602 display control |
| MFRC522_I2C.h | RFID tag reading |
| ACB_ARM.h | Robotic arm servo control |
| WiFi.h | Wi-Fi connectivity |
| WiFiClientSecure.h | TLS secure connection for MQTT |
| PubSubClient.h | MQTT publish/subscribe client |
Key Functions
Inspect()
The main inspection function. Runs the conveyor, checks for RFID and IR events, routes good items to the correct lane, and routes defective or untagged items to the reject lane. All events are published to MQTT.
MoveToReject()
Moves the robotic arm to the reject lane (ChassisCmd 175 — far side of rotation) and releases the object, placing rejected items in a separate area from sorted items.
publishInventory()
Publishes the current sorted item counts and defect count as a formatted string (e.g., "R:2 G:1 B:3 DEF:1") to the inspection/inventory topic after every sort and reject event.
General Program Workflow
- The ESP32 connects to Wi-Fi and HiveMQ on startup.
- Every loop updates the LCD with sorted and defect counts and publishes inventory to MQTT.
- The conveyor runs and the RFID reader polls for tags.
- If a valid tag is detected, the program waits for IR confirmation, stops the belt, and routes the object to the matching lane (R, G, or B).
- If the tag is unknown, the object is sent to the reject lane and the defect count increments.
- If the IR sensor detects an object with no RFID scan, the object is also rejected as untagged.
- All events appear live on the Node-RED dashboard via HiveMQ.
10 Testing and Calibration
Defect Detection Test
Place an untagged object on the conveyor belt. The IR sensor should detect it and trigger the reject sequence. Check the Serial Monitor and Node-RED dashboard to confirm the "No RFID — Defective item rejected" message appears.
Sorting Accuracy Test
Test each tagged item one at a time and confirm it is routed to the correct output lane. If any item goes to the wrong lane, adjust the servo angles in the corresponding MoveToX() function.
11 System Demonstration
The videos below demonstrate all five Smart Factory projects in action — from the joystick-controlled robotic arm to the cloud-connected inspection and sorting line.
12 Conclusion
The Acebott Education Solution Series QE031 Smart Factory Education Kit – Level 1 is a comprehensive and practical platform for exploring industrial automation, IoT, and embedded systems through five progressively advanced hands-on projects. From a joystick-controlled robotic arm to a cloud-connected inspection and sorting line, each project introduces concepts directly applicable to real-world smart manufacturing environments.
By working through these projects, students and makers gain practical experience in servo control, color and RFID identification, conveyor system integration, and MQTT-based IoT cloud monitoring — skills that are increasingly relevant in modern engineering and technology careers.
Possible Improvements and Future Enhancements
- Combine the color sensor and RFID reader for redundant, more reliable object identification.
- Integrate a mobile app dashboard for monitoring warehouse and inspection data on a smartphone.
- Implement a database (e.g., InfluxDB or Firebase) to log historical inventory and defect data over time.
- Add a camera module for visual inspection and AI-based defect detection.
- Extend the system with additional conveyor lanes for multi-category sorting with more than three destinations.
13 References
- Acebott Official Website — acebott.com
- Acebott QE031 Smart Factory Education Kit Documentation — acebott.com/product/aecbott-qe031-smart-factory-for-esp32/
- Acebott Tutorial Resources — acebott.com/tutorial/
- Arduino Official Documentation — arduino.cc
- Espressif ESP32 Documentation — docs.espressif.com
- PubSubClient MQTT Library — github.com/knolleary/pubsubclient
- HiveMQ Cloud MQTT Broker — hivemq.com
- Node-RED Official Documentation — nodered.org
14 Project Authors
- Sofia Lorin Pardillo
- Angella Llanto
Quality Checked by:
- Miles Darren Bagnol
- Lukie-Mar Lonzaga
- Elijah Joseph Orias
