course_zephyr_rtos_rpi_4b

Chapter 18: Networked Environmental Monitor - Architectural Design


Introduction | Theory | Lab | Course Home


System Architecture

The Networked Environmental Monitor is designed as a modular, multi-threaded application that leverages the networking capabilities of the Raspberry Pi 4B. The architecture is centered around a message-passing paradigm, which decouples the different components of the system and allows for concurrent operation.

graph TD
    subgraph Hardware
        A[BME280 Sensor] --> B(I2C Bus);
    end

    subgraph Zephyr RTOS on Raspberry Pi 4B
        B --> C[Sensor Thread];
        C -->|Sensor Data| D[Message Queue];
        D --> E[Web Server Thread];
        E --> F(TCP/IP Stack);
    end

    subgraph Network
        F --> G[Ethernet];
        G --> H[Web Browser];
    end

    I[Main Thread] --> C;
    I --> E;
    I --> J[Shell Interface];
    K[Power Management] --> C;
    K --> E;
    K --> F;

Core Components:

Thread Design and Communication

The multi-threaded architecture allows for concurrent operation, which is essential for a responsive and efficient embedded system.

Why a Message Queue?

A message queue is the ideal communication primitive for this application for several reasons:

Power Management Strategy

While the Raspberry Pi 4B is not a low-power device, we can still apply power management principles:

Web Server Design

A simple HTTP server will be implemented using Zephyr’s socket APIs. The server will have a single endpoint (/) that returns the latest sensor data.

HTTP/1.1 200 OK
Content-Type: text/html

<html>
<head><title>Smart Weather Station</title></head>
<body>
<h1>Smart Weather Station</h1>
<p>Temperature: 25.5 C</p>
<p>Humidity: 45.2 %</p>
<p>Pressure: 1012.5 hPa</p>
</body>
</html>

Modular and Configurable Design

Following the principles from Chapters 14 and 15, the project will be structured in a modular and configurable way:

This architectural design provides a solid foundation for building a robust, efficient, and maintainable Networked Environmental Monitor. The next section will provide the step-by-step guide to implementing this design.

Next: Implementation Lab