iotlabkit 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iotlabkit-1.0.0/LICENSE +21 -0
- iotlabkit-1.0.0/PKG-INFO +550 -0
- iotlabkit-1.0.0/README.md +498 -0
- iotlabkit-1.0.0/pyproject.toml +86 -0
- iotlabkit-1.0.0/setup.cfg +4 -0
- iotlabkit-1.0.0/src/iotlabkit/__init__.py +30 -0
- iotlabkit-1.0.0/src/iotlabkit/cli.py +239 -0
- iotlabkit-1.0.0/src/iotlabkit/coap_util.py +322 -0
- iotlabkit-1.0.0/src/iotlabkit/data/beijing_air/beijing_sample.csv +801 -0
- iotlabkit-1.0.0/src/iotlabkit/data/india_air/city_day_sample.csv +901 -0
- iotlabkit-1.0.0/src/iotlabkit/data/occupancy/datatraining.txt +801 -0
- iotlabkit-1.0.0/src/iotlabkit/doctor.py +160 -0
- iotlabkit-1.0.0/src/iotlabkit/generator.py +110 -0
- iotlabkit-1.0.0/src/iotlabkit/registry.py +705 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_05.py +436 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_06.py +404 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_07.py +249 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_08.py +278 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_09.py +329 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_10.py +338 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_11.py +347 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_12.py +317 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_13.py +272 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_14.py +287 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_15.py +411 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_16.py +382 -0
- iotlabkit-1.0.0/src/iotlabkit/templates/program_17.py +422 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/PKG-INFO +550 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/SOURCES.txt +38 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/dependency_links.txt +1 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/entry_points.txt +2 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/requires.txt +33 -0
- iotlabkit-1.0.0/src/iotlabkit.egg-info/top_level.txt +1 -0
- iotlabkit-1.0.0/tests/test_api_parsing.py +138 -0
- iotlabkit-1.0.0/tests/test_cli.py +70 -0
- iotlabkit-1.0.0/tests/test_coap_util.py +65 -0
- iotlabkit-1.0.0/tests/test_doctor.py +52 -0
- iotlabkit-1.0.0/tests/test_generator.py +55 -0
- iotlabkit-1.0.0/tests/test_ml_pipeline.py +114 -0
- iotlabkit-1.0.0/tests/test_registry.py +57 -0
iotlabkit-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iotlabkit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
iotlabkit-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iotlabkit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Beginner-Friendly IoT Lab Code Generator for MSc/MCA Practicals (Programs 5-17)
|
|
5
|
+
Author: IoT Lab Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: iot,mqtt,coap,rest-api,machine-learning,data-analytics,education,laboratory,code-generator
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Education
|
|
20
|
+
Classifier: Topic :: Home Automation
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: analytics
|
|
26
|
+
Requires-Dist: requests>=2.28.0; extra == "analytics"
|
|
27
|
+
Requires-Dist: pandas>=1.5.0; extra == "analytics"
|
|
28
|
+
Requires-Dist: matplotlib>=3.6.0; extra == "analytics"
|
|
29
|
+
Provides-Extra: ml
|
|
30
|
+
Requires-Dist: pandas>=1.5.0; extra == "ml"
|
|
31
|
+
Requires-Dist: matplotlib>=3.6.0; extra == "ml"
|
|
32
|
+
Requires-Dist: scikit-learn>=1.2.0; extra == "ml"
|
|
33
|
+
Requires-Dist: joblib>=1.2.0; extra == "ml"
|
|
34
|
+
Provides-Extra: iot
|
|
35
|
+
Requires-Dist: requests>=2.28.0; extra == "iot"
|
|
36
|
+
Requires-Dist: paho-mqtt>=1.6.1; extra == "iot"
|
|
37
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "iot"
|
|
38
|
+
Provides-Extra: dashboard
|
|
39
|
+
Requires-Dist: streamlit>=1.25.0; extra == "dashboard"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: requests>=2.28.0; extra == "all"
|
|
44
|
+
Requires-Dist: pandas>=1.5.0; extra == "all"
|
|
45
|
+
Requires-Dist: matplotlib>=3.6.0; extra == "all"
|
|
46
|
+
Requires-Dist: scikit-learn>=1.2.0; extra == "all"
|
|
47
|
+
Requires-Dist: joblib>=1.2.0; extra == "all"
|
|
48
|
+
Requires-Dist: paho-mqtt>=1.6.1; extra == "all"
|
|
49
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "all"
|
|
50
|
+
Requires-Dist: streamlit>=1.25.0; extra == "all"
|
|
51
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
52
|
+
|
|
53
|
+
# iotlabkit — Beginner-Friendly IoT Lab Code Generator
|
|
54
|
+
|
|
55
|
+
[](https://www.python.org/downloads/)
|
|
56
|
+
[](LICENSE)
|
|
57
|
+
[](#3-supported-practical-programs)
|
|
58
|
+
[](#program-8--coap-client-and-server)
|
|
59
|
+
|
|
60
|
+
A complete, beginner-friendly Python package and CLI tool designed specifically for **MSc / MCA Semester 3 IoT Laboratory practicals**.
|
|
61
|
+
|
|
62
|
+
`iotlabkit` generates complete, readable, production-grade project code for **Programs 5 through 17**, supporting two interchangeable presentation modes:
|
|
63
|
+
- **Learning Mode (`--mode learning`)**: Rich architectural diagrams, plain-English comments, troubleshooting tips, function walkthroughs, and viva questions.
|
|
64
|
+
- **Exam Mode (`--mode exam`)**: Concise, minimal, practical code ready for university laboratory examination submission.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Table of Contents
|
|
69
|
+
|
|
70
|
+
1. [What is iotlabkit?](#1-what-is-iotlabkit)
|
|
71
|
+
2. [What Can It Do?](#2-what-can-it-do)
|
|
72
|
+
3. [Supported Practical Programs](#3-supported-practical-programs)
|
|
73
|
+
4. [Python Installation Guide](#4-python-installation-guide)
|
|
74
|
+
5. [Creating a Virtual Environment](#5-creating-a-virtual-environment)
|
|
75
|
+
6. [Installing iotlabkit](#6-installing-iotlabkit)
|
|
76
|
+
7. [Listing Practicals (`list`)](#7-listing-practicals-list)
|
|
77
|
+
8. [Inspecting a Practical (`info`)](#8-inspecting-a-practical-info)
|
|
78
|
+
9. [Generating a Project (`create`)](#9-generating-a-project-create)
|
|
79
|
+
10. [Installing Project Dependencies](#10-installing-project-dependencies)
|
|
80
|
+
11. [Configuring Cloud Services & Credentials](#11-configuring-cloud-services--credentials)
|
|
81
|
+
12. [Dataset Management & Offline Testing](#12-dataset-management--offline-testing)
|
|
82
|
+
13. [Running Each Practical](#13-running-each-practical)
|
|
83
|
+
14. [Running Diagnostics (`doctor`)](#14-running-diagnostics-doctor)
|
|
84
|
+
15. [Troubleshooting & Common Errors](#15-troubleshooting--common-errors)
|
|
85
|
+
16. [Uninstalling the Package](#16-uninstalling-the-package)
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 1. What is iotlabkit?
|
|
90
|
+
|
|
91
|
+
In university IoT laboratory curricula, students often face hurdles configuring diverse communication protocols (HTTP REST, MQTT, CoAP), cloud databases (Supabase, Firebase, ThingsBoard), and machine learning pipelines (Decision Trees, Linear Regression, Random Forests).
|
|
92
|
+
|
|
93
|
+
`iotlabkit` solves this by automating the boilerplate generation while maintaining **100% genuine code, real APIs, and authentic datasets**. It does not generate fake sensor readings or synthetic ML data. Every project generated is self-contained and immediately runnable.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 2. What Can It Do?
|
|
98
|
+
|
|
99
|
+
- **Generates complete, runnable projects** with a single command: `iotlabkit create <id>`.
|
|
100
|
+
- **Supports 13 university practicals** across Communication, Analytics, and Machine Learning layers.
|
|
101
|
+
- **Built-in Pure-Python RFC 7252 CoAP implementation**: Runs CoAP client and server on UDP port 56830 with **zero external pip dependencies**.
|
|
102
|
+
- **Real live API integrations**: Connects directly to Open-Meteo Weather, Open-Meteo Air Quality, USGS Earthquakes, and ISS Orbital coordinates.
|
|
103
|
+
- **Authentic datasets bundled & downloadable**: Pre-bundles balanced genuine subsets of UCI Occupancy (#357), UCI Beijing PM2.5 (#501), and Kaggle India Air Quality (`city_day.csv`), with official downloaders for the full datasets.
|
|
104
|
+
- **Dual Presentation Modes**: Switch effortlessly between verbose educational code (`learning`) and concise exam submission code (`exam`).
|
|
105
|
+
- **Interactive Web Dashboards**: Generates instant Streamlit dashboards for real-time visualization.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 3. Supported Practical Programs
|
|
110
|
+
|
|
111
|
+
Strictly implements Programs 5 through 17 from the syllabus. Programs 1–4 and 18 are excluded.
|
|
112
|
+
|
|
113
|
+
| ID | Title | Layer | External Dependencies | Internet Needed? | Cloud Keys? |
|
|
114
|
+
| :-: | :--- | :--- | :--- | :-: | :-: |
|
|
115
|
+
| **5** | **HTTP REST API + Cloud DB + Dashboard** | Communication | Flask, Requests, Streamlit | Yes | Yes (Supabase/Firebase) |
|
|
116
|
+
| **6** | **MQTT + Cloud DB + Dashboard** | Communication | Paho-MQTT, Requests, Streamlit | Yes | Yes (Supabase/Firebase) |
|
|
117
|
+
| **7** | **ThingsBoard + MQTT Telemetry** | Communication | Paho-MQTT, python-dotenv | Yes | Yes (Device Token) |
|
|
118
|
+
| **8** | **CoAP Client and Server** | Communication | *None (Standard Library)* | **No** | **No** |
|
|
119
|
+
| **9** | **Online & Local MQTT Brokers** | Communication | Paho-MQTT, python-dotenv | Online only | No |
|
|
120
|
+
| **10** | **CoAP Environmental Monitoring** | Communication | Requests, Streamlit | Yes | Yes (Supabase/Firebase) |
|
|
121
|
+
| **11** | **ISS Real-Time Orbit Tracking** | Data Analytics | Requests, Pandas, Matplotlib, Streamlit | Yes | No |
|
|
122
|
+
| **12** | **USGS Global Earthquake Analysis** | Data Analytics | Requests, Pandas, Matplotlib, Streamlit | Yes | No |
|
|
123
|
+
| **13** | **Kochi Weather Trend Analysis** | Data Analytics | Requests, Pandas, Matplotlib, Streamlit | Yes | No |
|
|
124
|
+
| **14** | **Kochi Hourly Air Quality Analysis** | Data Analytics | Requests, Pandas, Matplotlib, Streamlit | Yes | No |
|
|
125
|
+
| **15** | **Decision Tree Occupancy Detection** | Machine Learning | Scikit-learn, Pandas, Joblib, Matplotlib | **No** (Bundled) | No |
|
|
126
|
+
| **16** | **Linear Regression Temp Prediction** | Machine Learning | Scikit-learn, Pandas, Joblib, Matplotlib | **No** (Bundled) | No |
|
|
127
|
+
| **17** | **Random Forest Air Quality Classifier**| Machine Learning | Scikit-learn, Pandas, Joblib, Matplotlib | **No** (Bundled) | No |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 4. Python Installation Guide
|
|
132
|
+
|
|
133
|
+
Verify you have Python 3.9 or higher installed:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python3 --version
|
|
137
|
+
# Output should be Python 3.9.x, 3.10.x, 3.11.x, 3.12.x, or 3.13.x
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Linux (Ubuntu / Debian)
|
|
141
|
+
```bash
|
|
142
|
+
sudo apt update
|
|
143
|
+
sudo apt install -y python3 python3-pip python3-venv
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Linux (Fedora / RHEL)
|
|
147
|
+
```bash
|
|
148
|
+
sudo dnf install -y python3 python3-pip
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Windows (PowerShell)
|
|
152
|
+
Download the official Python installer from [python.org](https://www.python.org/downloads/). During installation, **make sure to check the box: "Add Python to PATH"**.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 5. Creating a Virtual Environment
|
|
157
|
+
|
|
158
|
+
Always use a Python virtual environment to keep your system packages clean.
|
|
159
|
+
|
|
160
|
+
### On Linux / macOS (Bash)
|
|
161
|
+
```bash
|
|
162
|
+
# Create a virtual environment named .venv
|
|
163
|
+
python3 -m venv .venv
|
|
164
|
+
|
|
165
|
+
# Activate the virtual environment
|
|
166
|
+
source .venv/bin/activate
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### On Windows (PowerShell)
|
|
170
|
+
```powershell
|
|
171
|
+
# Create a virtual environment named .venv
|
|
172
|
+
python -m venv .venv
|
|
173
|
+
|
|
174
|
+
# Activate the virtual environment
|
|
175
|
+
.\.venv\Scripts\Activate.ps1
|
|
176
|
+
```
|
|
177
|
+
*(If PowerShell shows an execution policy error, run: `Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned`)*
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 6. Installing iotlabkit
|
|
182
|
+
|
|
183
|
+
Install `iotlabkit` in editable development mode directly from this repository:
|
|
184
|
+
|
|
185
|
+
### Linux / macOS
|
|
186
|
+
```bash
|
|
187
|
+
python3 -m pip install -e .
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Windows
|
|
191
|
+
```powershell
|
|
192
|
+
python -m pip install -e .
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
To install optional extra dependencies (e.g. for ML or dashboards):
|
|
196
|
+
```bash
|
|
197
|
+
pip install -e ".[all]" # Install all dependencies
|
|
198
|
+
pip install -e ".[analytics]" # Pandas, Matplotlib, Requests
|
|
199
|
+
pip install -e ".[ml]" # Scikit-learn, Joblib, Pandas, Matplotlib
|
|
200
|
+
pip install -e ".[iot]" # Paho-MQTT, Requests, Python-dotenv
|
|
201
|
+
pip install -e ".[dashboard]" # Streamlit
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Verify installation:
|
|
205
|
+
```bash
|
|
206
|
+
iotlabkit --version
|
|
207
|
+
# Output: iotlabkit 1.0.0
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 7. Listing Practicals (`list`)
|
|
213
|
+
|
|
214
|
+
To view all supported programs and their operational flags:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
iotlabkit list
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Sample output:
|
|
221
|
+
```
|
|
222
|
+
==========================================================================================
|
|
223
|
+
iotlabkit — MSc/MCA IoT Laboratory Practicals (Programs 5-17)
|
|
224
|
+
==========================================================================================
|
|
225
|
+
ID | Title | Net | Keys | Broker | Data | Server
|
|
226
|
+
------------------------------------------------------------------------------------------
|
|
227
|
+
--- Communication and Application Layer ---
|
|
228
|
+
5 | HTTP REST API + Cloud Database + Dashboard | Yes | Yes | No | No | Yes
|
|
229
|
+
6 | MQTT + Cloud Database + Dashboard | Yes | Yes | Yes | No | No
|
|
230
|
+
7 | ThingsBoard + MQTT Telemetry | Yes | Yes | Yes | No | No
|
|
231
|
+
8 | CoAP Client and Server Environmental Monit... | No | No | No | No | Yes
|
|
232
|
+
...
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 8. Inspecting a Practical (`info`)
|
|
238
|
+
|
|
239
|
+
To view detailed prerequisites, objectives, generated files, and viva questions for any program:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
iotlabkit info 8
|
|
243
|
+
iotlabkit info 15
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 9. Generating a Project (`create`)
|
|
249
|
+
|
|
250
|
+
Generate a practical project using its program number:
|
|
251
|
+
|
|
252
|
+
### Learning Mode (Default)
|
|
253
|
+
Generates complete educational code with detailed docstrings, architecture diagrams, step-by-step instructions, and comprehensive viva Q&A:
|
|
254
|
+
```bash
|
|
255
|
+
iotlabkit create 5
|
|
256
|
+
iotlabkit create 12
|
|
257
|
+
iotlabkit create 15
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Exam Mode (`--mode exam`)
|
|
261
|
+
Generates concise, focused, production-grade code designed for laboratory examination submission:
|
|
262
|
+
```bash
|
|
263
|
+
iotlabkit create 5 --mode exam
|
|
264
|
+
iotlabkit create 15 --mode exam
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Custom Output Directory & Overwrite Flags
|
|
268
|
+
```bash
|
|
269
|
+
# Generate into a custom directory name
|
|
270
|
+
iotlabkit create 8 --output my_coap_lab
|
|
271
|
+
|
|
272
|
+
# Overwrite existing files without interactive prompt
|
|
273
|
+
iotlabkit create 8 --force
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## 10. Installing Project Dependencies
|
|
279
|
+
|
|
280
|
+
Each generated project contains a self-contained `requirements.txt`:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
cd lab05
|
|
284
|
+
pip install -r requirements.txt
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
*(Note: Program 8 uses pure standard library and requires **zero** external pip packages!)*
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## 11. Configuring Cloud Services & Credentials
|
|
292
|
+
|
|
293
|
+
For programs requiring cloud integration (Programs 5, 6, 7, and 10), each generated project includes a `.env.example` template.
|
|
294
|
+
|
|
295
|
+
1. Navigate to the project folder and copy the template:
|
|
296
|
+
```bash
|
|
297
|
+
# Linux / macOS:
|
|
298
|
+
cp .env.example .env
|
|
299
|
+
|
|
300
|
+
# Windows (PowerShell):
|
|
301
|
+
Copy-Item .env.example .env
|
|
302
|
+
```
|
|
303
|
+
2. Open `.env` in any text editor (VS Code, Notepad, Nano).
|
|
304
|
+
|
|
305
|
+
### Supabase Setup (Programs 5, 6, 10)
|
|
306
|
+
- Sign up at [supabase.com](https://supabase.com).
|
|
307
|
+
- Create a project.
|
|
308
|
+
- Open the SQL Editor and run the provided `supabase_schema.sql` file.
|
|
309
|
+
- Copy your **Project URL** and **anon public key** into `.env`:
|
|
310
|
+
```ini
|
|
311
|
+
SUPABASE_URL=https://your-project-ref.supabase.co
|
|
312
|
+
SUPABASE_KEY=your-anon-public-key
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Firebase Setup (Programs 5, 6, 10 Alternative)
|
|
316
|
+
- Open [Firebase Console](https://console.firebase.google.com).
|
|
317
|
+
- Create a project -> Build -> **Realtime Database**.
|
|
318
|
+
- In `.env`:
|
|
319
|
+
```ini
|
|
320
|
+
CLOUD_PROVIDER=firebase
|
|
321
|
+
FIREBASE_DATABASE_URL=https://your-project.firebaseio.com
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### ThingsBoard Setup (Program 7)
|
|
325
|
+
- Sign up at [thingsboard.cloud](https://thingsboard.cloud).
|
|
326
|
+
- Navigate to **Entities -> Devices -> Add new device** (e.g. `Lab_Sensor_01`).
|
|
327
|
+
- Copy the **Access Token** from Device Details.
|
|
328
|
+
- In `.env`:
|
|
329
|
+
```ini
|
|
330
|
+
THINGSBOARD_ACCESS_TOKEN=your-device-access-token
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
> **Offline Fallback Guarantee**: If cloud credentials are not supplied, Programs 5, 6, and 10 automatically fall back to local JSON caching (`data/local_*.json`) so you can complete and test the practical offline without internet!
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## 12. Dataset Management & Offline Testing
|
|
338
|
+
|
|
339
|
+
- **Program 15 (Occupancy Detection)**: Comes pre-bundled with 800 authentic records from UCI Dataset #357 in `data/datatraining.txt`. Run `python data/download_dataset.py` to fetch the full 8,143 records.
|
|
340
|
+
- **Program 16 (Beijing Temperature)**: Comes pre-bundled with 800 authentic records from UCI Dataset #501 in `data/beijing_sample.csv`. Run `python column_inspection.py` to inspect features.
|
|
341
|
+
- **Program 17 (India Air Quality)**: Comes pre-bundled with 900 balanced records across all 6 CPCB categories in `data/city_day_sample.csv`. Run `python data/download_dataset.py` for full Kaggle dataset instructions.
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## 13. Running Each Practical
|
|
346
|
+
|
|
347
|
+
### Program 5 — HTTP REST API + Cloud DB + Dashboard
|
|
348
|
+
```bash
|
|
349
|
+
# Terminal 1: Start REST Server
|
|
350
|
+
python server.py
|
|
351
|
+
|
|
352
|
+
# Terminal 2: Stream Sensor Telemetry
|
|
353
|
+
python client_sender.py
|
|
354
|
+
|
|
355
|
+
# Terminal 3: Launch Web Dashboard
|
|
356
|
+
streamlit run dashboard.py
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Program 6 — MQTT + Cloud DB + Dashboard
|
|
360
|
+
```bash
|
|
361
|
+
# Terminal 1: Start Subscriber
|
|
362
|
+
python subscriber.py
|
|
363
|
+
|
|
364
|
+
# Terminal 2: Publish Real Readings
|
|
365
|
+
python publisher.py
|
|
366
|
+
|
|
367
|
+
# Terminal 3: View Dashboard
|
|
368
|
+
streamlit run dashboard.py
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Program 7 — ThingsBoard + MQTT
|
|
372
|
+
```bash
|
|
373
|
+
python main.py
|
|
374
|
+
# Follow `thingsboard_dashboard_guide.md` to configure ThingsBoard widgets.
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Program 8 — CoAP Client and Server (Zero Dependencies!)
|
|
378
|
+
```bash
|
|
379
|
+
# Terminal 1: Start CoAP Server
|
|
380
|
+
python server.py
|
|
381
|
+
|
|
382
|
+
# Terminal 2: Query CoAP Server
|
|
383
|
+
python client.py
|
|
384
|
+
|
|
385
|
+
# Continuous live observation:
|
|
386
|
+
python client.py --watch 3
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Program 9 — Online & Local MQTT Brokers
|
|
390
|
+
```bash
|
|
391
|
+
# Online Mode (HiveMQ Public Cloud Broker):
|
|
392
|
+
python subscriber.py --broker online
|
|
393
|
+
python publisher.py --broker online
|
|
394
|
+
|
|
395
|
+
# Local Mode (Mosquitto Edge Broker):
|
|
396
|
+
python subscriber.py --broker local
|
|
397
|
+
python publisher.py --broker local
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Program 10 — CoAP Environmental Monitoring (Open-Meteo)
|
|
401
|
+
```bash
|
|
402
|
+
# Terminal 1: CoAP Server (fetches Open-Meteo & serves CoAP)
|
|
403
|
+
python coap_env_server.py
|
|
404
|
+
|
|
405
|
+
# Terminal 2: CoAP Client (queries CoAP & stores to DB)
|
|
406
|
+
python coap_env_client.py
|
|
407
|
+
|
|
408
|
+
# Terminal 3: Dashboard
|
|
409
|
+
streamlit run dashboard.py
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Program 11 — ISS Location Tracking
|
|
413
|
+
```bash
|
|
414
|
+
# Collect 100 live orbital points at 5-second intervals (~8.3 minutes):
|
|
415
|
+
python collector.py --count 100 --interval 5
|
|
416
|
+
|
|
417
|
+
# Compute orbital statistics & generate trend plots:
|
|
418
|
+
python analyzer.py
|
|
419
|
+
|
|
420
|
+
# View interactive orbit map:
|
|
421
|
+
streamlit run dashboard.py
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Program 12 — USGS Earthquake Analysis
|
|
425
|
+
```bash
|
|
426
|
+
# Retrieve past 7 weeks of live seismic data from USGS:
|
|
427
|
+
python fetch_data.py
|
|
428
|
+
|
|
429
|
+
# Compute statistical distribution & plots:
|
|
430
|
+
python analyzer.py
|
|
431
|
+
|
|
432
|
+
# Launch interactive seismic dashboard:
|
|
433
|
+
streamlit run dashboard.py
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Program 13 — Weather Analysis (Kochi)
|
|
437
|
+
```bash
|
|
438
|
+
# Fetch hourly meteorological data from Open-Meteo:
|
|
439
|
+
python fetch_weather.py
|
|
440
|
+
|
|
441
|
+
# Compute Pearson correlation & trend curves:
|
|
442
|
+
python analyzer.py
|
|
443
|
+
|
|
444
|
+
# Launch dashboard:
|
|
445
|
+
streamlit run dashboard.py
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Program 14 — Air Quality Analysis (Kochi)
|
|
449
|
+
```bash
|
|
450
|
+
# Fetch hourly PM10, PM2.5, and US AQI:
|
|
451
|
+
python fetch_air_quality.py
|
|
452
|
+
|
|
453
|
+
# Calculate particulate statistics & WHO threshold curves:
|
|
454
|
+
python analyzer.py
|
|
455
|
+
|
|
456
|
+
# Launch dashboard:
|
|
457
|
+
streamlit run dashboard.py
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Program 15 — Decision Tree Room Occupancy Classifier
|
|
461
|
+
```bash
|
|
462
|
+
# Train Decision Tree model and export artifacts:
|
|
463
|
+
python train.py
|
|
464
|
+
|
|
465
|
+
# Classify occupancy for a new sensor reading:
|
|
466
|
+
python predict.py --temp 23.2 --humidity 27.2 --light 426 --co2 721
|
|
467
|
+
|
|
468
|
+
# Launch Streamlit predictor:
|
|
469
|
+
streamlit run dashboard.py
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Program 16 — Linear Regression Temperature Prediction
|
|
473
|
+
```bash
|
|
474
|
+
# Inspect actual dataset columns:
|
|
475
|
+
python column_inspection.py
|
|
476
|
+
|
|
477
|
+
# Train Linear Regression model (MAE, RMSE, R²):
|
|
478
|
+
python train.py
|
|
479
|
+
|
|
480
|
+
# Predict temperature for new readings:
|
|
481
|
+
python predict.py --dewp -16.0 --pres 1020.0 --pm25 120.0 --wind 2.0
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Program 17 — Random Forest Air Quality Classification
|
|
485
|
+
```bash
|
|
486
|
+
# Train Random Forest classifier across 6 CPCB classes:
|
|
487
|
+
python train.py
|
|
488
|
+
|
|
489
|
+
# Predict air quality bucket for new pollutant readings:
|
|
490
|
+
python predict.py --pm25 85 --pm10 140 --no2 32 --co 1.2 --so2 15 --o3 45
|
|
491
|
+
|
|
492
|
+
# Launch interactive dashboard:
|
|
493
|
+
streamlit run dashboard.py
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
## 14. Running Diagnostics (`doctor`)
|
|
499
|
+
|
|
500
|
+
Check your Python environment, installed tools, and optional packages:
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
iotlabkit doctor
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
The doctor tool safely checks environment variables without exposing sensitive secret values.
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## 15. Troubleshooting & Common Errors
|
|
511
|
+
|
|
512
|
+
### `Errno 111: Connection Refused` (Programs 5, 8, 10)
|
|
513
|
+
**Cause:** The client was started before the corresponding server was active.
|
|
514
|
+
**Fix:** Keep Terminal 1 running with the server (`python server.py`) before running the client script in Terminal 2.
|
|
515
|
+
|
|
516
|
+
### `ModuleNotFoundError: No module named 'iotlabkit'`
|
|
517
|
+
**Cause:** Package was not installed in editable mode or virtual environment is not activated.
|
|
518
|
+
**Fix:** Activate your virtual environment and run `pip install -e .`.
|
|
519
|
+
|
|
520
|
+
### `Mosquitto Connection Refused (Port 1883)` (Program 9 Local Mode)
|
|
521
|
+
**Cause:** Mosquitto service is not running on your computer.
|
|
522
|
+
**Fix:**
|
|
523
|
+
- Linux: `sudo systemctl start mosquitto`
|
|
524
|
+
- Windows: Start Mosquitto from the Services window or run `net start mosquitto`.
|
|
525
|
+
|
|
526
|
+
### `Supabase 401 Unauthorized` (Programs 5, 6, 10)
|
|
527
|
+
**Cause:** Invalid `SUPABASE_KEY` or missing `anon` key.
|
|
528
|
+
**Fix:** Check that your `.env` contains the full `anon` key from Project Settings -> API.
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## 16. Uninstalling the Package
|
|
533
|
+
|
|
534
|
+
To remove `iotlabkit` from your environment:
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
pip uninstall iotlabkit -y
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## License
|
|
543
|
+
|
|
544
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
545
|
+
Datasets and APIs used belong to their respective creators:
|
|
546
|
+
- UCI Machine Learning Repository (Occupancy Detection #357, Beijing PM2.5 #501) — CC BY 4.0
|
|
547
|
+
- Rohan Rao Indian Air Quality Dataset (`city_day.csv`) — CC0: Public Domain
|
|
548
|
+
- Open-Meteo & Open-Meteo Air Quality APIs — Non-commercial educational use
|
|
549
|
+
- USGS Earthquake API — U.S. Geological Survey (Public Domain)
|
|
550
|
+
- Open-Notify & WhereTheISS APIs — Open satellite telemetry data
|