# IoT Connectivity using MQTT

<figure><img src="/files/8fWErDdNr98nbB9sp3Ac" alt=""><figcaption></figcaption></figure>

## Internet of Things

IoT protocols are sets of rules and standards that govern how devices in an IoT ecosystem exchange data and interact with each other. They define how data is exchanged, what format it should be in, and how it should be encrypted and authenticated for security purposes. Most popular IoT protocols include REST API and MQTT.

REST APIs, or RESTful APIs, are interfaces that enable interaction between different software applications. REST (Representational State Transfer) is an architectural style that utilizes a stateless communication protocol, typically HTTP. REST APIs operate by using standard HTTP methods, such as GET, POST, PUT, PATCH, and DELETE. These methods correspond to create, read, update, and delete (or CRUD) operations, respectively. Each request from a client to a server is stateless, meaning it contains all the information the server needs to fulfill the request. Responses from the server are typically in the form of resources, such as HTML, XML, JSON, or plain text.

MQTT (Message Queuing Telemetry Transport) is a communications protocol designed for IoT devices with extremely high latency and restricted low bandwidth. It is a TCP-based protocol relying on the publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. MQTT allows for messaging between device to cloud and cloud to device. This makes for easy broadcasting messages to groups of things. The heart of the MQTT protocol is the MQTT broker. All communications must be received by the broker, who will then sort them, ascertain who subscribed to each one, and deliver the messages to the clients who have subscribed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.tesa.or.th/tesa-developer/tesa-university-program/rt-thread-iot-os/university-program/edge-ai-workshop/iot-connectivity-using-mqtt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
