-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensor-api.yaml
More file actions
572 lines (557 loc) · 18.1 KB
/
sensor-api.yaml
File metadata and controls
572 lines (557 loc) · 18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
openapi: 3.0.3
info:
title: ESP8266 Sensor Data API
description: API for receiving comprehensive sensor data from ESP8266 devices including environmental readings, device diagnostics, and performance metrics
version: 2.0.0
contact:
name: Sensor Monitoring System
email: admin@example.com
servers:
- url: https://your-api-domain.com/api
description: Production server
paths:
/sensor-data:
post:
summary: Submit sensor readings
description: Endpoint to receive temperature and humidity data from ESP8266 devices
operationId: submitSensorData
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SensorReading'
examples:
comprehensive_reading:
summary: Comprehensive sensor reading with full data payload
value:
sensor_data:
temperature: 75.8
temperature_unit: "F"
humidity: 52.3
heat_index: 77.2
dew_point: 56.4
absolute_humidity: 10.1
comfort_level: "comfortable"
metadata:
timestamp: 1716742800
timestamp_iso: "2025-05-26T17:00:00Z"
local_time: "2025-05-26 12:00:00 CDT"
device_id: "AA:BB:CC:DD:EE:FF"
sensor_type: "DHT22"
firmware_version: "2.1.0"
transmission_type: "full"
device_info:
chip_id: "abc12345"
flash_chip_id: "def67890"
sketch_size: 295936
free_sketch_space: 2752512
sdk_version: "3.0.5"
boot_version: 7
reset_reason: "External System"
power_management:
vcc_voltage: 3.28
deep_sleep_duration: 300
wake_reason: "timer"
connectivity:
wifi_ssid: "ASUS_I"
wifi_rssi: -48
wifi_quality: "excellent"
wifi_channel: 6
ip_address: "192.168.1.105"
gateway: "192.168.1.1"
performance:
free_heap: 47832
heap_fragmentation: 6
max_free_block: 44128
cpu_frequency: 80
uptime: "23s"
wifi_connect_time_ms: 3420
sensor_read_time_ms: 253
loop_execution_time_ms: 1847
statistics:
total_readings: 144
successful_transmissions: 141
failed_transmissions: 3
sensor_failures: 2
wifi_disconnects: 1
api_errors: 1
average_temperature_24h: 73.2
min_temperature_24h: 68.5
max_temperature_24h: 78.9
average_humidity_24h: 48.7
min_humidity_24h: 35.2
max_humidity_24h: 67.1
data_quality_score: 97.9
diagnostics:
recent_errors:
- "wifi_timeout"
- "api_failed"
responses:
'200':
description: Data received successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Invalid request data
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/sensor-data/latest:
get:
summary: Get latest readings from all sensors
description: Retrieve the most recent temperature and humidity reading from all ESP8266 devices
operationId: getAllLatestSensorData
responses:
'200':
description: Latest sensor data from all devices retrieved successfully
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "success"
data:
type: array
items:
$ref: '#/components/schemas/SensorReading'
examples:
all_latest_readings:
summary: Latest readings from multiple devices
value:
status: "success"
data:
- sensor_data:
temperature: 68.1
temperature_unit: "F"
humidity: 58.7
heat_index: 70.2
dew_point: 52.1
absolute_humidity: 8.9
comfort_level: "comfortable"
metadata:
timestamp: 1640999800
timestamp_iso: "2025-05-26T18:30:00Z"
local_time: "2025-05-26 13:30:00 CDT"
device_id: "AA:BB:CC:DD:EE:FF"
sensor_type: "DHT22"
firmware_version: "2.1.0"
transmission_type: "full"
- sensor_data:
temperature: 71.3
temperature_unit: "F"
humidity: 62.1
heat_index: 74.8
dew_point: 57.2
absolute_humidity: 11.2
comfort_level: "comfortable"
metadata:
timestamp: 1640999750
timestamp_iso: "2025-05-26T18:29:10Z"
local_time: "2025-05-26 13:29:10 CDT"
device_id: "11:22:33:44:55:66"
sensor_type: "DHT22"
firmware_version: "2.1.0"
transmission_type: "full"
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/sensor-data/{device_id}/latest:
get:
summary: Get latest sensor reading
description: Retrieve the most recent temperature and humidity reading for a specific device
operationId: getLatestSensorData
parameters:
- name: device_id
in: path
required: true
description: Unique identifier for the ESP8266 device (MAC address)
schema:
type: string
pattern: "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$"
example: "AA:BB:CC:DD:EE:FF"
responses:
'200':
description: Latest sensor data retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SensorReading'
examples:
latest_reading:
summary: Latest comprehensive sensor reading
value:
sensor_data:
temperature: 68.1
temperature_unit: "F"
humidity: 58.7
heat_index: 70.2
dew_point: 52.1
absolute_humidity: 8.9
comfort_level: "comfortable"
metadata:
timestamp: 1640999800
timestamp_iso: "2025-05-26T18:30:00Z"
local_time: "2025-05-26 13:30:00 CDT"
device_id: "AA:BB:CC:DD:EE:FF"
sensor_type: "DHT22"
firmware_version: "2.1.0"
transmission_type: "full"
'404':
description: Device not found or no data available
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
device_not_found:
summary: Device not found
value:
status: "error"
message: "No data found for device AA:BB:CC:DD:EE:FF"
details: []
'400':
description: Invalid device ID format
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
SensorReading:
type: object
required:
- sensor_data
- metadata
properties:
sensor_data:
$ref: '#/components/schemas/SensorData'
metadata:
$ref: '#/components/schemas/Metadata'
device_info:
$ref: '#/components/schemas/DeviceInfo'
power_management:
$ref: '#/components/schemas/PowerManagement'
connectivity:
$ref: '#/components/schemas/Connectivity'
performance:
$ref: '#/components/schemas/Performance'
statistics:
$ref: '#/components/schemas/Statistics'
diagnostics:
$ref: '#/components/schemas/Diagnostics'
SensorData:
type: object
required:
- temperature
- humidity
properties:
temperature:
type: number
format: float
description: Temperature reading
example: 75.8
minimum: -40
maximum: 150
temperature_unit:
type: string
description: Temperature unit
example: "F"
enum: ["F", "C"]
humidity:
type: number
format: float
description: Relative humidity percentage
example: 52.3
minimum: 0
maximum: 100
heat_index:
type: number
format: float
description: Calculated heat index
example: 77.2
dew_point:
type: number
format: float
description: Calculated dew point
example: 56.4
absolute_humidity:
type: number
format: float
description: Absolute humidity in g/m³
example: 10.1
comfort_level:
type: string
description: Comfort level assessment
example: "comfortable"
enum: ["very_dry", "dry", "comfortable", "humid", "very_humid"]
Metadata:
type: object
required:
- timestamp
- device_id
properties:
timestamp:
type: integer
format: int64
description: Unix timestamp when the reading was taken
example: 1716742800
timestamp_iso:
type: string
format: date-time
description: ISO 8601 formatted timestamp
example: "2025-05-26T17:00:00Z"
local_time:
type: string
description: Local time representation
example: "2025-05-26 12:00:00 CDT"
device_id:
type: string
description: Unique identifier for the ESP8266 device (MAC address)
example: "AA:BB:CC:DD:EE:FF"
pattern: "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$"
sensor_type:
type: string
description: Type of sensor used
example: "DHT22"
firmware_version:
type: string
description: Firmware version of the device
example: "2.1.0"
transmission_type:
type: string
description: Type of data transmission
example: "full"
enum: ["full", "basic", "minimal"]
DeviceInfo:
type: object
properties:
chip_id:
type: string
description: Chip identifier
example: "abc12345"
flash_chip_id:
type: string
description: Flash chip identifier
example: "def67890"
sketch_size:
type: integer
description: Size of the compiled sketch in bytes
example: 295936
free_sketch_space:
type: integer
description: Available flash memory in bytes
example: 2752512
sdk_version:
type: string
description: SDK version
example: "3.0.5"
boot_version:
type: integer
description: Boot loader version
example: 7
reset_reason:
type: string
description: Reason for last reset
example: "External System"
PowerManagement:
type: object
properties:
vcc_voltage:
type: number
format: float
description: Supply voltage in volts
example: 3.28
deep_sleep_duration:
type: integer
description: Deep sleep duration in seconds
example: 300
wake_reason:
type: string
description: Reason for waking from sleep
example: "timer"
Connectivity:
type: object
properties:
wifi_ssid:
type: string
description: WiFi network name
example: "ASUS_I"
wifi_rssi:
type: integer
description: WiFi signal strength in dBm
example: -48
wifi_quality:
type: string
description: WiFi connection quality assessment
example: "excellent"
enum: ["poor", "fair", "good", "excellent"]
wifi_channel:
type: integer
description: WiFi channel number
example: 6
ip_address:
type: string
format: ipv4
description: Device IP address
example: "192.168.1.105"
gateway:
type: string
format: ipv4
description: Gateway IP address
example: "192.168.1.1"
Performance:
type: object
properties:
free_heap:
type: integer
description: Free heap memory in bytes
example: 47832
heap_fragmentation:
type: integer
description: Heap fragmentation percentage
example: 6
max_free_block:
type: integer
description: Largest free memory block in bytes
example: 44128
cpu_frequency:
type: integer
description: CPU frequency in MHz
example: 80
uptime:
type: string
description: Device uptime
example: "23s"
wifi_connect_time_ms:
type: integer
description: WiFi connection time in milliseconds
example: 3420
sensor_read_time_ms:
type: integer
description: Sensor reading time in milliseconds
example: 253
loop_execution_time_ms:
type: integer
description: Main loop execution time in milliseconds
example: 1847
Statistics:
type: object
properties:
total_readings:
type: integer
description: Total number of sensor readings taken
example: 144
successful_transmissions:
type: integer
description: Number of successful data transmissions
example: 141
failed_transmissions:
type: integer
description: Number of failed data transmissions
example: 3
sensor_failures:
type: integer
description: Number of sensor reading failures
example: 2
wifi_disconnects:
type: integer
description: Number of WiFi disconnections
example: 1
api_errors:
type: integer
description: Number of API errors encountered
example: 1
average_temperature_24h:
type: number
format: float
description: 24-hour average temperature
example: 73.2
min_temperature_24h:
type: number
format: float
description: 24-hour minimum temperature
example: 68.5
max_temperature_24h:
type: number
format: float
description: 24-hour maximum temperature
example: 78.9
average_humidity_24h:
type: number
format: float
description: 24-hour average humidity
example: 48.7
min_humidity_24h:
type: number
format: float
description: 24-hour minimum humidity
example: 35.2
max_humidity_24h:
type: number
format: float
description: 24-hour maximum humidity
example: 67.1
data_quality_score:
type: number
format: float
description: Overall data quality score (0-100)
example: 97.9
minimum: 0
maximum: 100
Diagnostics:
type: object
properties:
recent_errors:
type: array
description: List of recent error codes
items:
type: string
example: ["wifi_timeout", "api_failed"]
SuccessResponse:
type: object
properties:
status:
type: string
example: "success"
message:
type: string
example: "Sensor data received successfully"
id:
type: string
description: Unique identifier for the stored reading
example: "reading_12345"
ErrorResponse:
type: object
properties:
status:
type: string
example: "error"
message:
type: string
example: "Invalid sensor data format"
details:
type: array
items:
type: string
example: ["Temperature value out of range", "Missing device_id field"]