Smart Lab Guardian is a comprehensive Flutter application designed to monitor laboratory safety in real-time. The app provides continuous monitoring of critical environmental parameters and alerts users when safety thresholds are breached.
The dashboard provides an at-a-glance view of all critical lab parameters:
-
Live Sensor Readings
- Temperature monitoring (Β°C)
- Gas level detection (ppm)
- Fire detection status
- Distance/proximity sensing (cm)
-
Visual Status Indicators
- Color-coded cards for each sensor
- Red indicators for threshold breaches
- Normal state indicators in blue/green/orange
-
Historical Charts
- Line charts showing trends over time
- Last 20 data points displayed
- Threshold lines overlaid on charts
- Smooth curve interpolation for better visualization
-
Auto-Refresh
- Pull-to-refresh functionality
- Real-time updates every second
- Automatic chart updates
Comprehensive alert management and logging:
-
Active Alerts Section
- Real-time display of current threshold breaches
- Visual warning indicators
- Alert count badge
- Color-coded severity (red for active alerts, green for normal)
-
Alert History
- Complete log of all alerts
- Timestamped entries
- Severity classification (Info, Warning, Critical)
- Color-coded alert cards
- Searchable history
-
Alert Types
- Temperature exceeds maximum threshold
- Gas level exceeds maximum threshold
- Fire detected
- Distance below minimum threshold
-
Alert Management
- Clear all logs option
- Persistent storage of alert history
- Automatic alert generation
Customizable safety parameters:
-
Threshold Configuration
- Temperature threshold (15Β°C - 50Β°C)
- Gas level threshold (0 - 100 ppm)
- Minimum distance threshold (5 - 100 cm)
- Interactive sliders for easy adjustment
- Real-time value display
-
Data Management
- Clear sensor history
- Clear all stored data
- Reset thresholds to defaults
- Confirmation dialogs for destructive actions
-
Persistent Storage
- Settings saved locally
- Automatic loading on app restart
- SharedPreferences integration
Comprehensive data logging:
-
Sensor Reading History
- Last 1000 sensor readings stored
- Timestamped entries
- All sensor values in each entry
- Latest reading highlighted
-
Summary Statistics
- Average temperature
- Average gas level
- Average distance
- Total reading count
-
Data Visualization
- Card-based layout
- Color-coded sensor values
- Easy-to-read format
- Chronological ordering
-
Data Management
- Clear history option
- Automatic pruning (keeps last 1000)
- Export capability (future enhancement)
Intuitive bottom navigation bar:
- Dashboard Tab - Main monitoring view
- Alerts Tab - Alert notifications (with badge when active)
- History Tab - Sensor reading logs
- Settings Tab - Configuration and data management
Robust state handling with Riverpod:
-
Reactive Updates
- Automatic UI updates on state changes
- Stream-based sensor data
- Provider-based state propagation
-
Auto-Save Features
- Periodic history saving (every 5 seconds)
- Automatic alert logging
- Background data persistence
-
Provider Architecture
- Separation of concerns
- Testable components
- Clean dependency injection
Sensor Service β Stream Provider β UI Components
β
State Notifiers
β
Storage Service
βββββββββββββββββββββββββββββββββββββββ
β Main App (Riverpod) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
βββββββββ΄βββββββββ
β β
βΌ βΌ
ββββββββββββ ββββββββββββ
β Services β βProviders β
ββββββββββββ ββββββββββββ
β β
βΌ βΌ
ββββββββββββ ββββββββββββ
β Models β β Screens β
ββββββββββββ ββββββββββββ
- SensorData: Sensor reading data structure
- SensorThresholds: Configurable safety limits
- AlertLog: Alert event records
- SensorService: Generates/receives sensor data
- StorageService: Persists data locally
- sensorServiceProvider: Service instance
- storageServiceProvider: Storage instance
- sensorDataStreamProvider: Real-time data stream
- thresholdsProvider: Threshold configuration
- historyProvider: Reading history
- alertLogsProvider: Alert logs
- activeAlertsProvider: Current alerts
- DashboardScreen: Main monitoring interface
- AlertsScreen: Alert management
- HistoryScreen: Data logs
- SettingsScreen: Configuration
sensor_thresholds: Threshold configuration JSONsensor_history: Array of last 1000 readingsalert_logs: Array of last 500 alerts
- History: 1000 sensor readings (~100KB)
- Alerts: 500 alert logs (~50KB)
- Total: ~150KB maximum storage
The app includes a sophisticated sensor simulator:
- Temperature: 20Β°C - 40Β°C range with gradual drift
- Gas Level: 0 - 100 ppm with fluctuations
- Fire Detection: Random 2% probability events
- Distance: 5 - 200 cm with movement simulation
- Realistic value changes
- Natural variations
- Threshold breach scenarios
- Easily replaceable with real sensors
The app is designed for easy integration with real sensors:
- Serial/USB (Arduino, ESP32)
- HTTP/REST APIs
- MQTT (IoT networks)
- Bluetooth Low Energy
- WebSocket (real-time connections)
All sensor integration happens in SensorService:
- Clear interface definition
- Stream-based architecture
- JSON data format
- Comprehensive documentation
See SENSOR_INTEGRATION_EXAMPLES.md for detailed examples.
- Stream-based updates (no polling overhead)
- Efficient chart rendering (last 20 points)
- Lazy loading of history
- Automatic data pruning
- Memory-efficient storage
- Sensor data: 1 Hz (1 reading/second)
- History save: 0.2 Hz (every 5 seconds)
- UI refresh: Real-time on data change
- Chart update: Real-time on data change
- All data stored locally
- No cloud synchronization (by default)
- No user tracking
- No analytics collection
- No special permissions required for simulation mode
- Real sensor mode may require:
- Bluetooth (for BLE sensors)
- Location (Android BLE requirement)
- Internet (for HTTP/MQTT sensors)
- USB (for serial sensors)
- High contrast indicators
- Color-coded status (accessible color palette)
- Clear text labels
- Large touch targets
- Screen reader compatible (Material Design)
In lib/services/storage_service.dart:
static const int _maxHistoryItems = 1000;
static const int _maxAlertLogs = 500;In lib/models/sensor_data.dart:
factory SensorThresholds.defaults() => const SensorThresholds(
maxTemperature: 30.0,
maxGasLevel: 50.0,
minDistance: 20.0,
);In lib/providers/sensor_providers.dart:
return service.startSensorStream(interval: 1000);Potential additions:
- Export data to CSV/Excel
- Email/SMS notifications
- Cloud synchronization
- Multiple location monitoring
- Historical data analysis
- Predictive alerts
- Sensor calibration interface
- Multi-language support
- Dark mode theme
- Widget for home screen
- Unit tests for data models
- Widget tests for UI components
- Integration tests (can be added)
- Simulation testing included
test/sensor_data_test.dart- Model teststest/widget_test.dart- UI tests
flutter_riverpod- State managementfl_chart- Chart renderingshared_preferences- Local storageintl- Date formatting
http- REST API integrationmqtt_client- MQTT integrationflutter_blue_plus- BLE integrationusb_serial- Serial integrationweb_socket_channel- WebSocket integration
MIT License - Free for personal and commercial use
For questions or issues:
- Check README.md
- Review SETUP.md
- See SENSOR_INTEGRATION_EXAMPLES.md
- Open GitHub issue