An Open Connectivity Foundation (OCF) based prediction-assisted optimal control framework for smart homes that optimizes energy consumption while maximizing occupant thermal comfort. This is the first scalable, secure, and interoperable optimal control solution for smart-home IoT networks.
- 36.82% Energy Savings - Significant reduction in HVAC energy consumption
- 3.36ms Round Trip Time - Ultra-low latency for real-time control
- 5s Average Response Time - Fast actuator control and adjustment
- R² > 0.94 - High accuracy in energy and environmental parameter prediction
Traditional Home Energy Management Systems (HEMS) face significant challenges:
- Interoperability issues across heterogeneous IoT devices
- Energy vs. Comfort trade-off not adequately addressed
- Scalability limitations with proprietary protocols
- Security and privacy concerns in smart home networks
Our solution addresses these challenges through:
- OCF-IoTivity Framework - Standardized, secure device connectivity
- Edge Intelligence - LSTM models deployed on IoT devices for real-time predictions
- Improved Firefly Algorithm - Enhanced optimization with inertia weight approach
- Dual-Objective Optimization - Balances energy efficiency and occupant comfort
-
✅ Real-time Environmental Monitoring
- Temperature, humidity, air velocity sensing
- Mean radiant temperature measurement
- Energy consumption tracking
-
✅ Predictive Analytics
- LSTM-based energy consumption prediction
- Environmental parameter forecasting
- PMV (Predicted Mean Vote) comfort prediction
-
✅ Intelligent Optimization
- Modified Firefly Algorithm with logarithmic inertia weight
- Multi-objective optimization (energy + comfort)
- User preference-based control (α parameter)
-
✅ OCF Connectivity
- Seamless peer-to-peer device communication
- Protocol-agnostic interoperability
- Secure device on-boarding and provisioning
-
✅ Mobile Application
- Real-time environment monitoring
- User preference configuration
- Energy consumption visualization
Figure 1: Schematic diagram of energy conserving Active Chilled Beam system
The ACB system consists of:
- Air Handling Unit: Supply fan, air mixer, and cooling coils
- Water Chilling Unit: Compressor, water pump, condenser, evaporator, and expansion valve
- Control System:
- Dynamic prediction models for energy and environmental parameters
- PMV-based occupant comfort calculation
- Optimization model using improved Firefly Algorithm
- Optimal actuator control for ACB components
Energy consumption is modeled as: E = EC[(Ta, Hr), OF]
Where:
-
Ta= Air Temperature -
Hr= Relative Humidity -
OF= Operating Frequency (Fan, Pump, Compressor)
Figure 2: Training and offloading of dynamic inference model to provide edge intelligence
- Raspberry Pi 4 Model B (or equivalent)
- Ubuntu Server 20.04 LTS (preferred over Raspbian for better IoTivity support)
- Python 3.8 or higher
- Java Development Kit (JDK) 8 or higher
- Git
# Download Ubuntu Server 20.04 LTS for Raspberry Pi
# Use Raspberry Pi Imager or balenaEtcher to flash the SD card
# Insert the SD card into Raspberry Pi and bootWhy Ubuntu instead of Raspbian?
- Better IoTivity 2.2.2 support and compatibility
- More comprehensive package repositories
- Better remote development tools support
- Enhanced security features
# Update system
sudo apt-get update
sudo apt-get upgrade -y
# Install essential tools
sudo apt-get install -y git build-essential python3-pip
sudo apt-get install -y openssh-server
# Enable SSH (if not already enabled)
sudo systemctl enable ssh
sudo systemctl start ssh
# Note your Raspberry Pi's IP address
hostname -IPurpose: PuTTY initiates SSH commands allowing the IoT platform to send instructions remotely to the Raspberry Pi.
Installation (Windows):
# Download from: https://www.putty.org/
# Install PuTTY executable
# Alternative: Use Windows Terminal
# Windows Terminal also supports SSH natively
ssh ubuntu@<raspberry-pi-ip>Connection Steps:
- Open PuTTY
- Enter Raspberry Pi IP address in "Host Name"
- Port: 22
- Connection Type: SSH
- Click "Open"
- Login with username and password
Other SSH Alternatives:
- Windows Terminal (built-in SSH)
- MobaXterm
- Git Bash
- PowerShell SSH client
Purpose: WinSCP is an FTP-based system used to transfer files from the platform to the device, including IoTivity 2.2.2 and Python scripts.
Installation:
# Download from: https://winscp.net/
# Install WinSCPConfiguration Steps:
- Open WinSCP
- File Protocol: SFTP
- Host name:
<Raspberry Pi IP address> - Port: 22
- Username:
ubuntu(or your username) - Password:
<your password> - Click "Login"
Files to Transfer:
- IoTivity source code
- Python scripts
- TFLite models
- Configuration files
# From your local machine
ssh ubuntu@<raspberry-pi-ip>
# Or use PuTTY with the IP address# Clone IoTivity version 2.2.2 from GitHub
git clone --recursive --depth 1 --single-branch --branch 2.2.2 \
https://github.com/iotivity/iotivity-lite.git iotivity-222
cd iotivity-222# Install dependencies
sudo apt-get install -y \
build-essential \
git \
scons \
libboost-dev \
libboost-program-options-dev \
libboost-thread-dev \
uuid-dev \
libssl-dev \
libtool \
libglib2.0-dev
# Build IoTivity server
./build-server-lite.sh# Run the IoTivity server
./run-server-lite.shExpected Output:
Starting IoTivity Server...
OCF Server Started Successfully
Listening on port 5683
Waiting for client connections...
# Download Eclipse IDE for Java Developers
# https://www.eclipse.org/downloads/
# Install EclipsePurpose: Remote systems allow compiling and executing Java code remotely on the IoT device using remote compiler.
Configuration Steps:
-
Install Remote System Explorer
- Open Eclipse
- Go to
Help→Install New Software - Search for "Remote System Explorer"
- Install RSE (Remote System Explorer)
- Restart Eclipse
-
Create SSH Connection
- Open
Remote Systemsperspective - Right-click in
Remote Systemsview →New Connection - Select
Linuxas operating system - Click
Next
- Open
-
Enter Connection Details
- Host name:
<Raspberry Pi IP address> - Connection name:
RPi-IoT-Device - Description:
Raspberry Pi IoT Device - Click
Next
- Host name:
-
Configure Services
- Select
ssh.files(for file transfer) - Select
ssh.shells(for remote terminal) - Select
ssh.terminals(for remote execution) - Click
Next
- Select
-
Set Authentication
- User ID:
ubuntu - Password:
<your password> - Check "Save password"
- Click
Finish
- User ID:
-
Test Connection
- Right-click on the connection →
Connect - Expand
Sftp Files→Rootto browse files - Right-click →
Launch Terminalto open remote shell
- Right-click on the connection →
# In Eclipse, configure the IoTivity libraries
# Project → Properties → Java Build Path → Libraries
# Add External JARs → Browse to IoTivity Java bindingsSteps:
- In Eclipse, open
Remote Systemsview - Expand your Raspberry Pi connection
- Right-click →
Launch Terminal - Navigate to IoTivity directory:
cd ~/iotivity-222- Start IoTivity server:
./run-server-lite.sh- In Eclipse, run the OCF Client Java code
- Observe client-server communication in the terminal
# On Raspberry Pi (via SSH)
pip3 install --upgrade pip
pip3 install tensorflow-lite
pip3 install flask
pip3 install numpy
pip3 install pandas
pip3 install mysql-connector-python
# Install additional requirements
pip3 install -r requirements.txtFiles to Transfer:
-
Python Scripts:
ocf_server.pyflask_server.pysensor_drivers.py
-
TFLite Models:
energy_model.tfliteenvironment_model.tflitepmv_model.tflite
-
Configuration Files:
config.yamliotivity_config.json
Transfer Process:
- Open WinSCP and connect to Raspberry Pi
- Navigate to target directory on RPi (e.g.,
/home/ubuntu/iot-system/) - Drag and drop files from local system to RPi
- Verify file permissions:
chmod +x *.py
chmod +x *.sh# Install MySQL on IoT Platform
sudo apt-get install mysql-server
# Secure installation
sudo mysql_secure_installation
# Create database
mysql -u root -p
CREATE DATABASE smart_home_db;
USE smart_home_db;
SOURCE schema.sql;
# Create user for application
CREATE USER 'iot_user'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON smart_home_db.* TO 'iot_user'@'%';
FLUSH PRIVILEGES;# Terminal 1: Start OCF Server
cd ~/iot-system
python3 ocf_server.py
# Terminal 2: Start Flask Server
python3 flask_server.py# Terminal 1: Start OCF Client (Eclipse or command line)
cd aiot-platform
java -jar ocf-client.jar
# Terminal 2: Start Optimization Engine
python optimization_engine.pyExpected Console Output:
┌─────────────────────────────────────────────┐
│ OCF CLIENT-SERVER OUTPUT │
├─────────────────────────────────────────────┤
│ [CLIENT] Discovering OCF devices... │
│ [CLIENT] Device found: RPi-IoT-Device │
│ [CLIENT] Connecting to: coap://192.168.x.x │
│ │
│ [SERVER] Client connected from 192.168.x.x │
│ [SERVER] Sending resource information... │
│ │
│ [CLIENT] Received environmental data: │
│ ├─ Temperature: 18.5°C │
│ ├─ Humidity: 51.96% │
│ ├─ CO2: 445.66 ppm │
│ └─ Energy: 2.52 kWh │
│ │
│ [CLIENT] Requesting predictions... │
│ [SERVER] Running TFLite models... │
│ [SERVER] Predictions complete │
│ │
│ [CLIENT] Received predictions: │
│ ├─ Predicted Temp: 19.2°C │
│ ├─ Predicted Humidity: 53.4% │
│ ├─ Predicted Energy: 2.8 kWh │
│ └─ PMV: 0.1 (Comfort) │
│ │
│ [OPTIMIZATION] Running Firefly Algorithm... │
│ [OPTIMIZATION] Optimal control found: │
│ ├─ Fan Frequency: 37 Hz │
│ ├─ Pump Frequency: 40 Hz │
│ └─ Compressor Frequency: 43 Hz │
│ │
│ [CLIENT] Sending control commands... │
│ [SERVER] Actuators updated successfully │
│ │
│ ✓ Energy Saving: 28.5% │
│ ✓ Comfort Index: 0 (Neutral/Comfortable) │
│ ✓ Response Time: 4.8s │
│ ✓ Round Trip Time: 3.2ms │
└─────────────────────────────────────────────┘
Figure 3: Android client for getting occupant preference
## 📊 Results
**Key Findings:**
- Maximum energy savings: **36.82%** (at α = 1.0)
- Average improvement over baseline FA: **7%**
- Best balanced performance: **30.3%** savings at α = 0.5
### OCF Server Endpoints
#### 1. Get Environmental Data
```http
GET coap://[device-ip]:5683/oic/rd?rt=oic.wk.rdpub
Response:
{
"temperature": 18.5,
"humidity": 51.96,
"CO2": 445.66,
"energy_consumption": 2.52,
"timestamp": "2023-10-15T14:30:00Z"
}GET coap://[device-ip]:5683/predictResponse:
{
"temperature_prediction": 19.2,
"humidity_prediction": 53.4,
"energy_prediction": 2.8,
"pmv": 0.1,
"comfort_index": "neutral"
}POST coap://[device-ip]:5683/actuator/controlRequest Body:
{
"fan_frequency": 37,
"pump_frequency": 40,
"compressor_frequency": 43
}Response:
{
"status": "success",
"message": "Actuators updated successfully",
"updated_at": "2023-10-15T14:31:00Z"
}GET http://[device-ip]:5000/statusResponse:
{
"device_status": "online",
"ocf_server": "running",
"models_loaded": true,
"last_update": "2023-10-15T14:30:00Z"
}POST http://[server-ip]:8080/optimizeRequest Body:
{
"current_temperature": 18.5,
"current_humidity": 51.96,
"user_preference": 0.5,
"constraints": {
"temp_min": 20,
"temp_max": 27,
"humidity_min": 45,
"humidity_max": 65
}
}Response:
{
"optimal_control": {
"fan_frequency": 37,
"pump_frequency": 40,
"compressor_frequency": 43
},
"predictions": {
"energy_saving": 28.5,
"comfort_index": 0,
"predicted_temperature": 19.2,
"predicted_humidity": 53.4
},
"algorithm": "improved_firefly",
"iterations": 245,
"convergence_time": 1.2
}Title: An OCF-IoTivity enabled smart-home optimal indoor environment control system for energy and comfort optimization
Authors: Anam Nawaz Khan, Atif Rizwan, Rashid Ahmad, Do Hyeun Kim
Journal: Internet of Things
Volume: 22
Article Number: 100712
Year: 2023
Publisher: Elsevier
DOI: 10.1016/j.iot.2023.100712
License: CC BY-NC-ND 4.0
Khan, A. N., Rizwan, A., Ahmad, R., & Kim, D. H. (2023). An OCF-IoTivity
enabled smart-home optimal indoor environment control system for energy
and comfort optimization. Internet of Things, 22, 100712.
https://doi.org/10.1016/j.iot.2023.100712
@article{khan2023ocf,
title={An OCF-IoTivity enabled smart-home optimal indoor environment control system for energy and comfort optimization},
author={Khan, Anam Nawaz and Rizwan, Atif and Ahmad, Rashid and Kim, Do Hyeun},
journal={Internet of Things},
volume={22},
pages={100712},
year={2023},
publisher={Elsevier},
doi={10.1016/j.iot.2023.100712},
issn={2542-6605},
url={https://www.sciencedirect.com/science/article/pii/S2542660523000355}
}- Publisher: Elsevier - Internet of Things
- DOI: https://doi.org/10.1016/j.iot.2023.100712
- PDF: Download from Publisher
- Java: 51.8% (OCF Client, Eclipse IDE integration)
- Python: 48.2% (Optimization, ML models, Flask server)
We welcome contributions! Please see our Contributing Guidelines.
- Fork the repository
- Clone your fork
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
# Ensure all dependencies are installed
sudo apt-get install -y build-essential git scons \
libboost-dev libboost-program-options-dev \
libboost-thread-dev uuid-dev libssl-dev
# Clean and rebuild
cd iotivity-222
./clean.sh
./build-server-lite.sh# On Raspberry Pi, ensure SSH is running
sudo systemctl status ssh
sudo systemctl start ssh
# Check firewall
sudo ufw allow 22- Verify network connectivity
- Check file permissions on Raspberry Pi
- Ensure sufficient storage space
- Try SFTP protocol instead of SCP
- Verify SSH credentials
- Check network firewall settings
- Ensure RSE plugins are properly installed
- Try reconnecting: Right-click → Disconnect → Connect
This work was supported by:
-
Institute for Information & communications Technology Promotion (IITP) Republic of Korea
- Grant NO. 2022-0-00980: Cooperative Information Intelligence Framework
- Grant NO. 2021-0-00188: Open source development for AI-enabled IoT platforms
-
Jeju National University - Mobile Computing Lab
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Made with ❤️ for sustainable smart homes



