A PostgreSQL and RStudio portfolio project that analyzes simulated IoT sensor readings from manufacturing equipment.
The project monitors robotic arms, CNC machines, and conveyor belts for early signs of failure. It detects:
- Temperature spikes
- Excessive vibration
- Cycle-time delays
- Voltage drops
- Sequential events that may suggest a root cause
- PostgreSQL schema design
- SQL window functions
- Time-series rolling averages and standard deviations
- Z-score anomaly detection
- Threshold tuning
- Sequential event dependency using
LAG() - Root-cause preprocessing
- RStudio data extraction and filtering
- R visualizations and CSV exports
The mock data script creates:
- 3 manufacturing machines
- 120 readings per machine
- 360 total IoT sensor records
- 5-minute sensor intervals
- Embedded anomaly windows for testing
01_create_schema.sql02_insert_mock_data.sql03_create_feature_view.sql04_anomaly_analysis.sql05_rstudio_analysis.R
- Create a PostgreSQL database named
manufacturing_analytics. - Open DBeaver and connect to the database.
- Run the four SQL scripts in numerical order.
- Confirm that
asset_health.sensor_readingscontains 360 rows. - Review
asset_health.anomaly_results.
Install the required packages:
install.packages(c(
"DBI",
"RPostgres",
"dplyr",
"ggplot2",
"readr",
"lubridate"
))Set your PostgreSQL password before running the script:
Sys.setenv(PGPASSWORD = "your_password")Optional connection settings:
Sys.setenv(
PGDATABASE = "manufacturing_analytics",
PGHOST = "localhost",
PGPORT = "5432",
PGUSER = "postgres"
)Run:
source("05_rstudio_analysis.R")Developed a PostgreSQL-based manufacturing asset health analytics system using 360 simulated IoT sensor readings. Applied rolling window statistics, z-score anomaly detection, and sequential event analysis to identify temperature, vibration, voltage, and cycle-time abnormalities. Enhanced the SQL pipeline with RStudio visualizations and machine-level risk summaries.