CoAP
Introduction to CoAP
The Constrained Application Protocol (CoAP) and its associated standard are used to support ARTIK communication on a Thread network by way of a Thread border router.
Let's take a moment to understand how CoAP compares to MQTT.
In terms of data capabilities, CoAP by itself is very similar to the more mature MQTT standard. Both can carry data over Wi-Fi®. CoAP is also well suited to low-bandwidth IoT wireless networks. It is a point-to-point protocol and allows even inexpensive devices to talk directly to each other without a central broker or Wi-Fi.
CoAP over Thread
When CoAP is paired with Thread, it becomes an ideal way to integrate an assortment of local devices with each other and into the Internet environment.
- Every device node uses a low-power 802.15.4 radio (same as ZigBee). These radios are quite inexpensive to implement, when compared to Wi-Fi.
- Nodes talk to each other directly and establish their own local network that self-adjusts to other nodes joining and leaving.
- When connected to the Internet through a gateway device, each node is directly addressable by an IPv6-format address.
- Thread defines standard command names to control and monitor all common IoT devices (lighting, switches, thermostats, etc.)
The table below provides a quick comparison summary.
Topic | MQTT | CoAP + Thread |
---|---|---|
Connection to Internet | TCP | UDP |
Protocol | IPv4/6 | IPv6 |
Security | SSL/TLS | DTLS |
Communication path | through a central broker (like Mosquitto) |
point-to-point / mesh |
Wireless standard | 802.11 (Wi-Fi) power-hungry, always on |
802.15.4 (same as ZigBee) low-power, sleepy |
Command naming standard | None (we chose ones like insTemp, setOn, etc. in our MQTT tutorials) |
Thread-defined standard |
One way to look at the usage models for the two might be as follows.
MQTT: Convenient for communicating custom data sets or large data blocks between line-powered devices equipped with Wi-Fi.
CoAP: Best for low-power battery-operated controls and sensors with minimal and commonplace data transfer needs.