Skip to content

shivamskr151/Raspberry-Pi-Kafka

Repository files navigation

Raspberry Pi Kafka Project

A Python-based Kafka messaging system designed for Raspberry Pi applications. This project provides a robust framework for handling real-time messaging between Raspberry Pi devices and other systems using Apache Kafka.

Features

  • Kafka Producer: Sends messages and commands to Kafka topics
  • Kafka Consumer: Receives and processes messages from Kafka topics
  • Command Handler: Extensible command processing system
  • Status Management: Real-time status monitoring and reporting
  • Configuration Management: Dynamic configuration updates
  • Action Execution: Remote action execution capabilities

Prerequisites

  • Python 3.7+
  • Apache Kafka server
  • Raspberry Pi (or any Python-compatible device)

Installation

  1. Clone the repository:
git clone https://github.com/shivamskr151/Raspberry-Pi-Kafka.git
cd Raspberry-Pi-Kafka
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Configuration

Update the Kafka configuration in kafka_config.py:

KAFKA_BOOTSTRAP_SERVERS = ['localhost:9092']  # Your Kafka server
TOPIC_NAME = 'raspi-commands'                 # Your topic name

Usage

Running the Application

python raspi_kafka.py

Sending Commands

The system supports various commands:

  • get_status: Retrieve current system status
  • set_config: Update system configuration
  • execute_action: Execute specific actions

Example Usage

from kafka_producer import KafkaMessageProducer

producer = KafkaMessageProducer()
producer.send_command('get_status', {'device_id': 'raspi-001'})

Project Structure

Raspi-Kafka/
├── raspi_kafka.py      # Main application entry point
├── kafka_producer.py   # Kafka message producer
├── kafka_consumer.py   # Kafka message consumer
├── kafka_config.py     # Configuration settings
├── requirements.txt    # Python dependencies
└── README.md          # This file

Architecture

The project follows a modular architecture:

  1. KafkaMessageProducer: Handles message publishing to Kafka topics
  2. KafkaMessageConsumer: Manages message consumption and processing
  3. RaspiKafkaManager: Orchestrates the overall system and command handling
  4. Command Handlers: Extensible system for processing different command types

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is open source and available under the MIT License.

Author

Shivam Kumar - GitHub

Support

For issues and questions, please open an issue on GitHub.

About

A minimal setup to run Apache Kafka on Raspberry Pi for edge data streaming. Ideal for IoT applications involving real-time sensor data collection, processing, and forwarding to cloud or local consumers.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages