Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📡 Task 2 — Sensor Data Simulation

Python Rich Internship License

Decodelabs IoT Internship Program

Simulates real IoT sensor data — temperature, humidity, motion and heat index —
using sine-wave day/night patterns and the official NOAA Rothfusz equation.
Logs all readings to CSV and JSON in real time.


📌 Goal

"Simulate sensor data collection using software or basic hardware (if available)."

This project fulfils all Task 2 requirements purely in software — no physical hardware needed. The simulation is scientifically grounded: it uses real meteorological math, not just random().


✅ Requirements Coverage

Requirement Implementation
Simulate temperature, humidity, motion sensor_simulator.py — sine-wave + Gaussian noise
Display sensor values main_terminal.py — live Rich terminal UI
Store / log the generated data data_logger.py — CSV + JSON dual logging

📁 Files

task2-sensor-simulation/
│
├── sensor_simulator.py     # Core sensor engine — DHT22 + PIR simulation
├── data_logger.py          # Dual logger — CSV for analysis, JSON for API
├── main_terminal.py        # Live terminal display using Rich library
├── requirements.txt        # Dependencies
└── README.md

✨ Key Features

Feature Detail
🌡️ Sine-wave simulation Day/night temperature cycle — not random numbers
💧 Inverse humidity Humidity drops when temp rises (psychrometric effect)
🎯 PIR simulation 25% motion probability during day, 4% at night
🔥 NOAA Heat Index Official Rothfusz (1990) regression equation
😊 Comfort level 5-tier classification (Comfortable → Oppressive)
💾 Dual logging CSV for Excel analysis, JSON for REST API
🇧🇩 BD-calibrated 27.5°C base temp, 68% humidity (Bangladesh defaults)

🧮 Heat Index Formula

NOAA Rothfusz (1990) regression equation:

HI = −8.785 + 1.611·T + 2.339·RH − 0.146·T·RH
     − 0.012·T² − 0.016·RH² + 0.002·T²·RH
     + 7.255×10⁻⁴·T·RH² − 3.582×10⁻⁶·T²·RH²

Source: Steadman, R.G. (1979). Journal of Applied Meteorology and Climatology, Vol. 18.


⚙️ Installation & Run

Install dependencies:

pip install -r requirements.txt

Run live terminal demo:

python main_terminal.py

Sample terminal output:

╭─────────── EnviroSense Pro — Live Sensor Feed ────────────╮
│  Sensor           Reading        Status                    │
│  Temperature      29.3 °C        NORMAL                   │
│  Humidity         71.2 %         NORMAL                   │
│  Heat Index       34.6 °C        OK                       │
│  Motion (PIR)     DETECTED       ALERT                    │
│  Comfort Level    MODERATE                                 │
╰── Step #12 | 2025-05-28 14:32:05 | Logging to CSV + JSON ─╯

Output files (auto-created):

data/sensor_data.csv    ← full historical log
data/sensor_data.json   ← last 100 readings

📦 Sample JSON Output

{
  "timestamp": "2025-05-28T14:32:05.123456",
  "temperature_c": 29.3,
  "humidity_pct": 71.2,
  "motion_detected": true,
  "heat_index_c": 34.6,
  "comfort_level": "MODERATE",
  "step": 12
}

👨‍💻 Author

Rafi Ul Islam
2nd Year — IoT & Robotics Engineering
University of Frontier Technology, Bangladesh (UFTB)

GitHub LinkedIn


Part of the Decodelabs IoT Internship Program — Task 2 of 3

About

IoT sensor data simulation using sine-wave patterns and NOAA Heat Index formula | Decodelabs Internship

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages