A practical real-time IoT sensor data pipeline on GCP with serverless processing and live dashboard.
📺 Watch the full development walkthrough and demo in Turkish: 🔗 Project Video Link
View Live Dashboard - Real-time sensor data visualization
- Overview
- Architecture
- Features
- Technology Stack
- Getting Started
- Project Structure
- Deployment
- Monitoring & Logging
- Dashboard & Visualization
- Performance
- Security
- Contributing
This project implements a scalable, real-time IoT sensor data processing pipeline using Google Cloud Platform services. The system simulates sensor data collection, processes it through serverless functions, stores it in multiple databases, and provides live visualization through an interactive dashboard.
- ⚡ Low-latency Ingestion: with Google Pub/Sub
- 🔄 Serverless Processing: via Cloud Functions Gen2
- 💾 Hybrid Storage: Firestore (real-time) + BigQuery (analytics)
- 🎛️ Threshold Filtering: Ignores data changes <5% to reduce noise
- 📊 Dashboard Insights: Interactive Looker Studio visualization
- 🛡️ Secure Access Control: IAM-based permissions and service accounts
graph LR
A[Sensor Simulator] --> B[Pub/Sub Topic]
B --> C[Cloud Function]
C --> D[Firestore]
C --> E[BigQuery]
E --> F[Looker Studio]
D --> G[Real-time Apps]
- Sensor Simulator generates temperature/humidity data every 5 seconds
- Pub/Sub queues messages for reliable delivery
- Cloud Function processes messages with intelligent filtering
- Dual Storage ensures both real-time access and analytics capability
- Dashboard provides live visualization and monitoring
- 🌡️ Sensor Data Simulation: Temperature (20-30°C) and Humidity (40-60%)
- 🔄 Intelligent Filtering: Only stores data with >5% change
- ⚡ Serverless Processing: Auto-scaling Cloud Functions Gen2
- 💾 Multi-Database Storage: Firestore + BigQuery integration
- 📊 Real-time Dashboard: Live charts and metrics
- 🛡️ Error Handling: Comprehensive exception management
- 📝 Detailed Logging: Execution tracking and debugging
- 🔐 Security: IAM roles and service account authentication
- 📈 Performance Monitoring: Cloud Functions metrics
- 🎯 Cost Optimization: Smart data filtering reduces storage costs
| Category | Technology | Purpose |
|---|---|---|
| Backend | Python 3.13 | Core application logic |
| Messaging | Google Pub/Sub | Asynchronous message queuing |
| Compute | Cloud Functions Gen2 | Serverless data processing |
| Database | Cloud Firestore | Real-time NoSQL database |
| Analytics | BigQuery | Data warehouse and analytics |
| Visualization | Looker Studio | Interactive dashboard |
| Authentication | Service Accounts | Secure API access |
- Google Cloud Platform account
- Python 3.13+
- Google Cloud CLI
- Virtual environment support
- Clone the repository
git clone https://github.com/your-username/iot-sensor-processing.git
cd iot-sensor-processing- Set up virtual environment
python -m venv venv
# Windows
.\venv\Scripts\activate
# macOS/Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Configure Google Cloud
# Set up authentication
set GOOGLE_APPLICATION_CREDENTIALS=path/to/your/service-account-key.json
# Configure project
gcloud config set project your-project-id- Deploy Cloud Function
cd cloud_function_code
gcloud functions deploy process_sensor_data \
--entry-point process_sensor_data \
--runtime python313 \
--trigger-topic iot-sensor-data \
--region europe-west3- Run sensor simulator
python sensor_data_publisher.pyiot-sensor-processing/
├── 📄 sensor_data_publisher.py # Main sensor data simulator
├── 🔑 service-account-key.json # GCP authentication key
├── 📁 cloud_function_code/ # Cloud Function source
│ ├── 📄 main.py # Function logic
│ └── 📄 requirements.txt # Python dependencies
├── 📁 publisher_function/ # Alternative HTTP publisher
│ ├── 📄 main.py # HTTP trigger function
│ └── 📄 requirements.txt # Dependencies
├── 📁 venv/ # Python virtual environment
└── 📄 README.md # This file
gcloud functions deploy process_sensor_data \
--entry-point process_sensor_data \
--runtime python313 \
--trigger-topic iot-sensor-data \
--region europe-west3 \
--memory 256MB \
--timeout 60sgcloud pubsub topics create iot-sensor-data- Navigate to Firestore in GCP Console
- Create database in Native mode
- Choose region:
europe-west3 - Collection will be auto-created:
sensor_readings
-- Create dataset
CREATE SCHEMA `sensora_dataset`;
-- Create table
CREATE TABLE `sensora_dataset.sensor_readings` (
temperature FLOAT64,
humidity FLOAT64,
device_id STRING,
timestamp TIMESTAMP
);Our interactive Looker Studio dashboard provides:
- 🌡️ Current temperature reading
- 💧 Current humidity level
- ⏰ Last data received timestamp
- 📊 Total records count
- 📈 Temperature trend over time
- 💧 Humidity variation chart
- 🔄 Combined temperature + humidity correlation
- 📅 Date range selector
- 🔍 Device ID filtering
- 🔄 Auto-refresh every 5 minutes
- 📱 Mobile-accessible interface (via Looker Studio)
- 🎯 Smart Filtering: 5% change threshold reduces storage by ~60%
- ⚡ Parallel Processing: Simultaneous Firestore + BigQuery writes
- 🔄 Auto-scaling: Serverless functions scale with demand
- 💾 Efficient Storage: Optimized data structures
- 🔑 Service Account: Dedicated service account with minimal permissions
- 🛡️ IAM Roles: Principle of least privilege
- 🔐 API Security: Secure API key management
- 🌐 Network Security: VPC and firewall rules
{
"roles": [
"roles/cloudfunctions.invoker",
"roles/pubsub.publisher",
"roles/datastore.user",
"roles/bigquery.dataEditor"
]
}- 📈 Invocation count and frequency
- ⏱️ Execution time metrics
- ❌ Error rate tracking
- 💾 Memory usage analysis
# Example log outputs
print(f"Received message: {sensor_data}")
print(f"Data saved to Firestore. Document ID: {doc_ref.id}")
print("Data inserted into BigQuery successfully.")
print("Change less than 5%, data not written.")def changed(old, new):
"""Returns True if change is greater than 5%"""
if old is None or old == 0:
return True
diff = abs(new - old) / abs(old) * 100
return diff >= 5{
"temperature": 25.34,
"humidity": 52.18,
"device_id": "sensor-001",
"timestamp": 1716590123
}# Test sensor simulator
python sensor_data_publisher.py
# Check Cloud Function logs
gcloud functions logs read process_sensor_data --region=europe-west3- ✅ Pub/Sub message publishing
- ✅ Cloud Function trigger response
- ✅ Firestore data persistence
- ✅ BigQuery data insertion
- ✅ Dashboard data visualization
- Google Cloud Platform for the cloud infrastructure
- Looker Studio for powerful data visualization capabilities
- Cloud Functions for serverless computing flexibility
- Academic Project developed for Cloud Technologies course
This project showcases foundational cloud architecture principles and practical IoT data processing patterns.