This project implements a real-time temperature and humidity monitoring system using a **Raspberry Pi 4** and an **HTU21D sensor**. The system reads environmental data via I2C, processes it using a C program, and displays the results on a web dashboard using Nginx.
The Temperature-Humidity-Sensor is the first module in a series of sensors for GNU/Linux intended for the construction of weather microstations that will be responsible for measuring air quality.
This module monitors temperature and humidity in real time using a Raspberry Pi 4 and an HTU21D sensor. The sensor reads the environmental data, sends it via I2C, processes it with a C program, and displays the results on a web dashboard using Nginx.
---
## System Architecture
The system is structured as a simple data pipeline that connects the sensor, processing logic, and web interface. Data flows continuously from the physical environment to the user in a clear and modular way.
---
### Hardware and Communication Layer
The HTU21D sensor measures temperature and humidity and communicates with the Raspberry Pi using the I2C protocol. This allows the Raspberry Pi to request and receive raw data from the sensor.
---
### Data Processing Layer
## Objective
A C program interacts with the I2C interface to read the sensor data. It converts the raw binary values into human-readable units such as degrees Celsius and percentage humidity, and formats the result as JSON.
The objective is to learn about the development of drivers to establish communication between a sensor (hardware) responsible for collecting data and a set of programs (software) that process this data, and design a target compatible with a Raspberry Pi 4 to create weather microstations responsible for monitoring air quality.
---
### Data Storage Layer
The JSON file stores the latest sensor readings. It acts as an intermediate layer, separating the data acquisition process from the web interface.
---
### Web Server Layer
Nginx serves the JSON file and the web page over HTTP. It allows other devices on the network to access the system through a browser.
---
### Presentation Layer
The web page uses JavaScript to periodically request the JSON file and update the displayed values dynamically, enabling near real-time visualization.
---
## System Architecture
### Overall Flow
The module is designed as a simple data channel where we connect the sensor HTU21D to a web interface for real-time data visualization.
As follows:
HTU21D Sensor → I2C → C Program → JSON File → Nginx → Web Browser
Data is captured by the sensor, processed by the C program, stored as JSON, served by Nginx, and displayed in the browser. This structure keeps the system simple, modular, and easy to maintain.
The sensor collects temperature and humidity data, sends it via the I2C Protocol to a Raspberry Pi 4, which reads and converts it into temperature and humidity values using a C program,then stores them in a JSON file. Nginx serves this file along with the web interface (HTML), where a JavaScript script fetches the data and updates the displayed values in real time.
---
## Materials
### Hardware
@ -247,30 +221,3 @@ http://192.168.1.100

---
## Real-Time Updates
JavaScript fetch:
```javascript
fetch('./data/HTU21D.json?nocache=' + Date.now())
```
**What it does:**
* Prevents browser cache
* Forces fresh data request
## Conclusion
This project integrates:
* Embedded systems (sensor + Raspberry Pi)
* C programming
* Linux system configuration
* Web development (Nginx + JS)
It demonstrates a complete pipeline from hardware acquisition to real-time web visualization.