English · Français
This Flutter app monitors and configures a connected IoT system (DHT11 sensor) in real time. It connects to a Firebase Realtime Database to display temperature and humidity data, chart their evolution over time, and configure alert thresholds with hysteresis.
- Current state: real-time temperature and humidity
- Trend chart: sensor data over several time ranges
- Threshold configuration: temperature limits with hysteresis
- Alert history: paginated list of threshold-crossing events
- Offline mode: data persistence through Firebase
- Auto refresh: real-time data updates
- Frontend: Flutter (Material Design 3)
- Backend: Firebase Realtime Database
- State: Provider
- Charts: fl_chart
- Data model: dedicated models for each data type
- Flutter SDK (^3.6.0)
- Firebase account
- Android Studio / VS Code
-
Clone the repository
git clone https://github.com/Yunaluman/rc_mobile_app.git cd rc_mobile_app -
Install dependencies
flutter pub get
-
Configure Firebase
Add your
firebase_options.dartfile at the project root with:- apiKey
- databaseURL
- the other fields required by FirebaseOptions
-
Run the app
flutter run
lib/
├── main.dart # App entry point
├── firebase_options.dart # Firebase configuration
├── models/ # Data models
│ ├── current_state.dart
│ ├── sensor_reading.dart
│ ├── threshold_event.dart
│ └── time_filter.dart
├── services/ # Business logic services
│ ├── firebase_service.dart
│ ├── sensor_service.dart
│ ├── current_state_service.dart
│ ├── sensor_reading_service.dart
│ └── threshold_event_service.dart
├── utils/ # Utilities
│ └── map_converter.dart
├── screens/ # Main screens
│ └── home_screen.dart
└── widgets/ # Reusable widgets
├── current_state_widget.dart
├── sensor_readings_chart.dart
├── threshold_events_widget.dart
└── threshold_config_widget.dart
The main screen has several sections:
- Current state: current temperature and humidity, color-coded against the thresholds
- Threshold configuration: adjust the temperature alert thresholds
- Trend chart: data evolution with several time filters
- Event list: history of threshold crossings
Set a target temperature with hysteresis:
- Turn on edit mode with the switch
- Use the slider to set the target temperature
- High (+1 °C) and low (−1 °C) thresholds are computed automatically
- Confirm with the "Save" button
Current sensor state:
temperature: current temperature (°C)humidity: current humidity (%)thresholdLow: low temperature thresholdthresholdHigh: high temperature thresholdlastUpdate: last update dateisOverThreshold: whether the temperature is outside the thresholds
A historical sensor reading:
temperature: measured temperature (°C)humidity: measured humidity (%)timestamp: date and time of the measurement
A threshold-crossing event:
temperature: temperature at the time of the event (°C)humidity: humidity at the time of the event (%)timestamp: date and time of the eventeventType: event type (crossing, back to normal)thresholdHigh: high threshold at the time of the eventthresholdLow: low threshold at the time of the event
Base service for talking to Firebase Realtime Database:
- Connection initialization
- CRUD methods
- Data stream handling
- Connectivity checks
- Safe data type conversion
Main service coordinating all sensor services:
- Initializes the specialized services
- Manages app state
- Unified data access interface
- Methods to update thresholds and create events
Handles the current sensor state:
- Fetching and updating state
- Temperature threshold configuration
- Threshold-crossing monitoring
Handles historical sensor readings:
- Fetching data by time filter
- Processing and filtering readings
Handles threshold-crossing events:
- Creating and fetching events
- Notifying new events
The system uses hysteresis to avoid rapid flapping between states:
- The user sets a target temperature (e.g. 23 °C)
- The system applies a hysteresis margin automatically (±1 °C)
- The high threshold is set to 24 °C and the low threshold to 22 °C
- A crossing event is created only when:
- the temperature rises above the high threshold (> 24 °C)
- the temperature drops below the low threshold (< 22 °C)
- The status returns to normal only once the temperature is back within the acceptable range
This avoids false positives and spurious alerts on small temperature fluctuations.
- Safe conversion of Firebase data types
- Error and connectivity handling
- Data caching for offline mode
- Smart data refresh
- Detailed debug logs
- User authentication
- Push notifications on threshold crossings
- Support for other sensor types
- Historical data export
- Advanced admin interface
Distributed under the MIT license. See the LICENSE file for details.
Built with ❤️ by Yunaluman THERESE