AI and IoT Project: Smart Waste Sorting
Intermediate7/6/2026- Author: IoTSpark Maker

AI and IoT Project: Smart Waste Sorting

Use AI, a Raspberry Pi, and various sensors to build a device that recognizes objects and automatically sorts waste, helping raise environmental awareness.

AI and IoTRaspberry PiAI Waste Sorting
7 steps8 components
← Back to project
Detailed guide

Part 2: Setting Up the Raspberry Pi's Working Environment

1. Installing Raspberry Pi OS; 2. Installing the required Python libraries; 3. Installing OpenCV for image processing; 4. Installing TensorFlow Lite for the AI model; 5. Installing MQTT for IoT connectivity; 6. Verifying the environment.

Updated 31/08/2026

Part 2: Setting Up the Raspberry Pi's Working Environment

1. Installing Raspberry Pi OS

To get started, install Raspberry Pi OS. Download the Raspberry Pi Imager tool from the official site. Once installed, follow these steps:

  1. Open Raspberry Pi Imager.

  2. Select "Choose OS" and pick "Raspberry Pi OS (64-bit)".

  3. Select your SD card under "Choose Storage".

  4. Click "Write" to start the flashing process.

Once done, insert the SD card into the Raspberry Pi and boot it up.

2. Installing the Required Python Libraries

To install the required libraries, open a terminal and run:

sudo apt update
sudo apt install python3-pip python3-dev

Next, install additional libraries:

sudo apt install python3-numpy python3-scipy

3. Installing OpenCV for Image Processing

OpenCV is a key library for image processing. Install it with:

sudo apt install python3-opencv

To verify the install, run:

python3 -c "import cv2; print(cv2.__version__)"

Note: the OpenCV version in the Raspberry Pi OS repository may be outdated. For advanced features, consider building from source or using a pre-built wheel.

4. Installing TensorFlow Lite for the AI Model

TensorFlow Lite supports running an AI model on a Raspberry Pi. Install it with:

pip3 install tflite-runtime

Note: make sure the TensorFlow Lite version is compatible with the Raspberry Pi 5.

5. Installing MQTT for IoT Connectivity

MQTT is a lightweight IoT protocol. Install the Paho MQTT library with:

pip3 install paho-mqtt

You can also install an MQTT broker like Mosquitto:

sudo apt install mosquitto mosquitto-clients

6. Verifying the Environment

To make sure everything works, run the following in a terminal:

python3 -c "import paho.mqtt.client as mqtt; print('MQTT Client OK')"
python3 -c "import cv2; print('OpenCV OK')"
python3 -c "import tflite_runtime.interpreter as tflite; print('TensorFlow Lite OK')"

Warning: if you get an error, recheck the installation steps and version compatibility.