# IoT Network Project
## Project Overview
Simulate an IoT network by building a simple sensor data collection system. Multiple sensor client programs send periodic data to a central server which collects, stores, and displays the data. This project demonstrates UDP communication, client-server architecture, and IoT networking concepts.
## Why UDP for IoT
This project uses UDP instead of TCP to demonstrate why IoT applications often prefer UDP. Sensor data is small and can be sent in a single datagram. If a reading is lost, the next reading will arrive shortly and the loss is acceptable. The overhead of TCP connection establishment is unnecessary for simple periodic data transmission. Battery-powered sensors benefit from the lower overhead of UDP.
## Sensor Client Description
Each sensor client simulates a sensor device such as a temperature sensor, humidity sensor, or light sensor. The sensor has a unique device ID and a sensor type. At regular intervals it generates a simulated reading, creates a JSON message containing device ID, sensor type, reading value, and timestamp, and sends it as a UDP datagram to the collector server address and port.
## Collector Server Description
The collector server creates a UDP socket and binds it to a configured port. It continuously receives datagrams from sensors. For each received datagram it parses the JSON message, extracts the device information and reading, stores it in a dictionary organized by device ID, and prints the received data. It also tracks the last time each sensor was heard from to detect sensors that have gone offline.
## Data Display
The server periodically prints a summary table showing each device ID, sensor type, latest reading, and time since last update. Devices that have not sent data for more than twice the expected interval are flagged as potentially offline.
## Network Concepts Demonstrated
UDP socket binding and receiving demonstrates the server side of UDP communication. Sending datagrams demonstrates the client side. Multiple independent sensors sending to the same server demonstrates many-to-one UDP communication. The JSON message format demonstrates how IoT protocols structure data. Detecting offline sensors demonstrates how server applications track connected clients even with connectionless UDP.
## Extensions to Try
Add persistence by saving sensor readings to a database. Add a web dashboard that displays sensor data in a browser. Add support for sensor registration so the server knows which sensors should be active. Implement data encryption for the sensor messages. Add alerting when sensor readings exceed thresholds.Back to Subject