Raspberry Pi 5 Autonomous Robot HAT

## 🍎 What is This Project?


An AI-powered fruit sorting system developed for the 

TEKNOFEST Agricultural Technologies competition.


Fruits travel along a conveyor belt into an inspection 

chamber. A camera captures each fruit's image and feeds 

it to the Raspberry Pi 5, which runs a trained AI vision 

model in real time to classify the fruit as healthy or 

rotten — in milliseconds.


Based on the AI decision:

✅ Healthy fruit → Servo arm stays closed → 

  fruit continues on the belt to the next stage

❌ Rotten fruit → Servo arm opens → 

  fruit is deflected off the belt to the reject bin


The entire process is fully autonomous, requiring 

zero human intervention on the sorting line.


---


## ❓ Why Did We Design a Custom PCB?


When we started building the fruit sorting system, the 

first question was: how do we power and control all of 

this from a Raspberry Pi 5?


The Raspberry Pi 5 is a powerful single-board computer 

but it is not designed to directly drive motors, servos, 

fans, or high-current LEDs. Its GPIO pins output only 

3.3V at a few milliamps — far from enough to run a 

real-world electromechanical sorting system.


Off-the-shelf solutions created more problems than they 

solved:

- Separate motor driver boards, servo controllers, and 

 power distribution modules would require a rats nest 

 of wiring between components

- Multiple power supplies for different voltage rails 

 (5V logic, 7V servos, 12V motors) with no clean 

 integration

- No unified solar + adapter dual-source input on any 

 ready-made board

- No compact form factor that mounts cleanly on the Pi

- Impossible to fit inside a compact sorting machine 

 enclosure with loose modules everywhere


The solution was clear: design a single, purpose-built 

HAT that handles everything in one board — power, 

motor drive, servo control, sensing interfaces, 

illumination, and cooling.


---


## ⚙️ How It Works — Step by Step


1. DC motor drives the conveyor belt at a controlled speed

2. 3x laser ToF distance sensors detect when a fruit 

  enters the inspection zone and trigger the camera

3. Raspberry Pi 5 captures the image and runs the 

  AI classification model (trained on healthy/rotten 

  fruit datasets)

4. AI outputs a decision: healthy or rotten

5. If rotten: MG996R servo arm actuates, deflecting 

  the fruit to the reject channel

6. If healthy: servo holds position, fruit passes through

7. 28BYJ-48 stepper motor handles auxiliary 

  positioning/guidance mechanisms

8. LED lighting (Q1) provides constant, uniform 

  illumination inside the inspection chamber for 

  consistent AI vision input regardless of 

  ambient light conditions

9. Dual fans (Q2, Q3) keep the HAT's power components 

  and Raspberry Pi 5 cool during continuous 

  AI inference workload


---


## 🎯 What This HAT Solves


### 1. Unified Power Management

One board, two input sources (solar + 12V adapter), 

three regulated output rails (5V, 7V, 12V) — all with 

proper protection diodes, current sensing, and filtering.

No external power distribution board needed.


### 2. Logic Level Translation

Raspberry Pi 5 GPIO operates at 3.3V. Servos and the 

TB6612FNG motor driver need 5V logic.

The SN74AHCT125DR level shifter on the HAT bridges 

this gap transparently — no external modules required.


### 3. Controlled Illumination (Q1 — AO3400A)

AI vision quality depends entirely on consistent 

lighting. Any variation in ambient light causes the 

model's accuracy to drop dramatically.

The HAT provides a dedicated MOSFET-switched LED 

output (Q1) that the Raspberry Pi 5 controls directly 

via GPIO — ensuring the inspection chamber is always 

illuminated at exactly the same intensity, regardless 

of environment.


### 4. Dual Fan Thermal Management (Q2, Q3 — AO3400A)

Running a real-time AI vision model on Raspberry Pi 5 

continuously generates significant heat. In an enclosed 

sorting machine enclosure this becomes critical.

Two independent PWM-controlled fan outputs (Q2, Q3) 

allow the system to manage thermal performance 

intelligently:

- Q2: Cools the HAT's power components 

 (regulators, motor driver)

- Q3: Dedicated airflow for the Raspberry Pi 5 

 during peak AI inference load


### 5. Compact, Competition-Ready Form Factor

At exactly 85mm x 56mm — the Raspberry Pi 5 HAT 

standard — the board stacks directly on top of the 

Pi with no additional mounting hardware.

The entire compute + power + control stack fits in 

the palm of your hand, making mechanical integration 

inside the sorting machine enclosure straightforward.


### 6. Solar-Ready for Field Deployment

Agricultural sorting shouldn't be limited to 

facilities with wall power. The HAT's dual-source 

input (12V adapter + 100W solar panel) means the 

system can operate anywhere — in a barn, in a 

field, or at a TEKNOFEST demonstration booth.


---


## ⚡ Power Architecture — Dual Source (Solar + Adapter)


Designed for both field deployment and indoor use:

- J1: 12V / 6A DC Barrel Jack — indoor/workshop use

- J2: 100W Solar Panel input (~17V) — outdoor field use


Both sources are OR-ed via SS10100-SMC Schottky diodes 

(10A/100V) to prevent back-feeding. Three switching 

regulators distribute power:

- 17V → 12V (LM5118MH): Solar step-down

- 12V → 5V/3A (TPS5430DDA): Logic, sensors, USB

- 12V → 7V/5A (TPS54560BDDAR): MG996R servo motors


---


## 🦾 Actuator & Motor Summary


| Motor | Driver | Function |

|-------|--------|----------|

| 2x DC Motor | TB6612FNG (socketed) | Conveyor belt drive |

| 3x MG996R Servo | SN74AHCT125DR + GPIO | Fruit sorting arm |

| 28BYJ-48 Stepper | ULN2003ADR (U3) | Auxiliary positioning |


DC motor leads are soldered directly to PCB mounting 

pads for vibration-resistant, connector-free attachment.


---


## 🛠️ PCB Specifications


- Layers: 2 (F.Cu, B.Cu)

- Dimensions: 85mm x 56mm (Raspberry Pi 5 HAT standard)

- Mounts directly on Raspberry Pi 5 via 2x20 GPIO header

- Full GND copper pour on both layers

- Power trace widths: up to 3mm (7V servo rail)

- Surface finish: HASL / ENIG

- Copper weight: 1oz


---


## 📚 About the Team


Designed by Ceren Önal and Mustafa, engineering students 

competing in TEKNOFEST — Turkey's largest aerospace and 

technology festival — under the Agricultural Technologies 

category.


The project began as a graduation thesis and evolved into 

a full competition system targeting real-world fruit 

sorting automation for small and medium-scale farms.


---


## 💬 Words to PCBWay


This HAT board is the brain stem of an AI-powered fruit 

sorting system competing at TEKNOFEST — Turkey's largest 

technology competition with millions of viewers and 

national media coverage.


Integrating dual-source power management, four motor 

types, ToF sensing, AI-triggered camera, controlled LED 

illumination, and dual fan thermal management — all on 

a 2-layer 85x56mm PCB that mounts directly onto a 

Raspberry Pi 5 — demanded manufacturing precision that 

only PCBWay can deliver.


We would be honored to represent PCBWay at TEKNOFEST 

and will document every stage: PCB assembly, AI model 

training, sorting system tests, and our competition 

results — sharing it all with the maker community!

Apply for sponsorship >>
13800+ Projects Sponsored
Jul 18,2026
34 viewsReport item
  • Comments(0)
  • Likes(0)
Upload photo
You can only upload 5 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000