Creating Demo Devices with Raspberry Pi

Aug 20, 2024

Lecture Notes

Introduction

  • Check of microphone audibility.
  • Greetings and congratulations on recent success in lunar landing (Chandrayan 3).
  • Overview of the day's tasks: creating demo devices and setting up Raspberry Pi virtual environment.

Tasks Overview

Task 1: Creating Demo Devices

  • Focus on simulating device data using MQTT (Message Queuing Telemetry Transport).
  • Discussion on creating dummy devices to simulate real device behavior.

Task 2: Raspberry Pi Virtual Setup

  • Setup involves creating a virtual environment for Raspberry Pi.
  • SSH (Secure Shell) setup instructions for those with actual Raspberry Pi devices.

MQTT Overview

  • MQTT is a lightweight messaging protocol used in IoT (Internet of Things) environments.
  • Previous session ended on publishing test data.
  • Today's focus: using MQTT to create devices that behave like real devices.

JSON Data Format

  • JSON (JavaScript Object Notation) is used for data interchange.
  • Explanation of JSON format in Python, using dictionaries for data representation.
  • Example provided for JSON data structure: device ID, temperature, humidity.

Code Implementation

Creating Dummy Devices

  • Device 1 (Dev 1): Simulates data using random values for temperature and humidity.

    • Temperature range: 20-25
    • Humidity range: 55-65
    • Timestamp added for data logs.
  • Device 2 (Dev 2): Simulates a water quality sensor device.

    • Additional parameters: pH and TDS (Total Dissolved Solids).
    • pH range: 3.0-9.0
    • TDS range: 0.5-2.5

Running Simulated Devices

  • Python scripts for devices run in command prompt to simulate continuous data generation.
  • Use of Python's random module to generate random sensor data values.

Raspberry Pi Virtual Machine Setup

Installation and Configuration

  • Introduction to QEMU (Quick Emulator) for Raspberry Pi virtualization.
  • Steps to enable SSH:
    • Access Raspberry Pi Config: Navigate to SSH settings, enable SSH.

SSH Setup with PuTTY

  • Download PuTTY for SSH communication.
  • Steps to connect to Raspberry Pi: use localhost for connection.
  • Login credentials for Raspberry Pi: username 'pi', password 'raspberry'.

MQTT Broker Installation

  • Attempt to install Mosquitto MQTT broker on Raspberry Pi VM.
  • Troubleshooting steps for installation issues, including alternative repositories.

Next Steps

  • Plan to install MQTT broker and set up Python client scripts for MQTT communication.
  • Future tasks include building control codes and simulating cloud server interaction on the local machine.

Troubleshooting and Support

  • Open invitation for students to reach out with any issues or questions during setup.

Closing

  • Encourage students to learn and troubleshoot independently.
  • Next class will focus on making up any lost time and completing setup.