Skip to content

Nairobi · East Africa

Smart Home & IoT

How IoT Devices Communicate: Protocols, MQTT and Matter

Compare Wi-Fi, BLE, Zigbee, Thread, LoRaWAN, NB-IoT and cellular, then learn how MQTT, CoAP and Matter move data, with a working MQTT example for East Africa.

TechBytes EA Engineering Team· · 11 min read

Close-up of a circuit board

IoT projects often start with a sensor and a dashboard, and only later confront the question that decides cost, battery life and reliability: how does the data actually get from the device to the system that uses it? The answer has two halves, the radio or network link and the messaging protocol on top of it, and the right combination for a Nairobi office is very different from the right combination for a borehole in Laikipia. This guide compares the main connectivity options, explains how MQTT, CoAP and Matter work, and includes a working MQTT example you can run today.

Key takeaways

  • Separate the problem into link (Wi-Fi, BLE, Zigbee, Thread, LoRaWAN, cellular) and messaging (MQTT, CoAP, HTTP, Matter). Choose each on its own merits.
  • Range, power and data rate trade off against each other. No single radio wins on all three.
  • MQTT is the workhorse for telemetry: lightweight, publish/subscribe, and tolerant of unreliable links when used with sensible QoS and session settings.
  • Matter standardises device control in homes and buildings; it is not a general-purpose telemetry protocol.
  • In East Africa, coverage maps and operator support for LPWAN and cellular IoT plans matter as much as datasheets. Test on site before you commit.

A useful mental model:

+--------------------------------------------------------------+
| Application data model  (Matter clusters, JSON, Protobuf)    |
+--------------------------------------------------------------+
| Messaging protocol      (MQTT, CoAP, HTTP, Matter IM)        |
+--------------------------------------------------------------+
| Transport / network     (TCP, UDP, IPv4/IPv6, 6LoWPAN)       |
+--------------------------------------------------------------+
| Link / radio            (Wi-Fi, BLE, 802.15.4, LoRa, LTE)    |
+--------------------------------------------------------------+

Some technologies span layers. LoRaWAN defines both the radio usage and a MAC layer with its own network server, so you typically bridge it into MQTT or HTTP at the network server. Zigbee defines its own network and application layers, so a Zigbee coordinator translates into IP-based protocols for the rest of the system. Thread provides IPv6 directly, which is why Matter can run on top of it unchanged.

Smart thermostat mounted on a wallConnected devices add convenience, and a new set of security responsibilities.

Connectivity options compared

TechnologyTypical rangeData ratePowerTopologySpectrumTypical uses
Wi-Fi (802.11)Tens of metres indoorsHigh (Mbps and up)HighStar (AP)Unlicensed 2.4/5/6 GHzCameras, appliances, gateways
Bluetooth Low EnergyUp to tens of metresLow to moderateVery lowStar, mesh (BLE Mesh)Unlicensed 2.4 GHzWearables, beacons, commissioning
Zigbee (802.15.4)10-100 m per hopLow (250 kbps radio)Very lowMeshUnlicensed 2.4 GHzHome and building sensors
Thread (802.15.4)10-100 m per hopLow (250 kbps radio)Very lowIPv6 meshUnlicensed 2.4 GHzMatter sensors, locks
Z-WaveTens of metres per hopLowVery lowMeshUnlicensed sub-GHz (regional)Home automation
LoRaWANKilometres (rural), less in citiesVery low (bps to kbps)Very lowStar of starsUnlicensed sub-GHz (regional plan)Metering, agriculture, asset tracking
NB-IoT / LTE-MCellular coverageLow (LTE-M higher than NB-IoT)Low (with PSM/eDRX)Operator networkLicensedSmart meters, trackers
LTE / 4G / 5GCellular coverageHighHighOperator networkLicensedGateways, video, vehicles

Ranges are indicative. Walls, terrain, antenna placement and interference all matter, and the only reliable number is the one you measure on site.

Short-range: Wi-Fi and BLE

Wi-Fi is everywhere and needs no extra gateway, which makes it attractive for prototypes and mains-powered devices. Its weaknesses are power consumption and the operational load of many clients on a single access point. In offices, put IoT devices on their own SSID and VLAN.

Bluetooth Low Energy (BLE) dominates wearables, beacons and phone-to-device setup. It is also how Matter devices are commissioned. BLE Mesh exists, but in buildings it is less common than Zigbee or Thread.

Low-power mesh: Zigbee, Thread and Z-Wave

Zigbee and Thread share IEEE 802.15.4 radios but differ above that. Zigbee has its own network and application layers, so it needs a coordinator that translates. Thread carries IPv6 packets end to end through border routers, which is cleaner for modern IP-based systems and is the low-power transport for Matter.

Z-Wave uses sub-GHz frequencies that differ by region, so devices must match the local frequency plan. Availability in East Africa is limited compared with Zigbee and Wi-Fi.

Long range: LoRaWAN

LoRaWAN is a low-power wide-area network (LPWAN) designed for small, infrequent messages over long distances. Devices transmit to one or more gateways, which forward packets to a network server that handles deduplication, security and device management. An application server then consumes the data, usually via MQTT or HTTP webhooks.

LoRaWAN fits agriculture, water metering, cold-chain monitoring and remote infrastructure in East Africa well because you can deploy your own gateways where there is no cellular coverage, backhauling over a single LTE or satellite link. Two cautions:

  • Regional parameters. LoRaWAN uses region-specific channel plans. Confirm the plan applicable in Kenya, Uganda or Tanzania against the LoRa Alliance regional parameters and the national regulator before buying hardware.
  • Duty cycle and payload size. LoRaWAN is for bytes, not megabytes. Firmware updates over the air are slow and must be planned.

Cellular IoT: NB-IoT, LTE-M and LTE

NB-IoT and LTE-M are cellular standards for low-power devices, with power-saving modes (PSM and eDRX) that let a device sleep for long periods. LTE-M supports mobility and higher data rates; NB-IoT is optimised for static devices with very small payloads and deep indoor coverage.

The practical question in East Africa is operator support. Network availability for NB-IoT and LTE-M, roaming arrangements and IoT data plans vary by operator and change over time, so speak to Safaricom, Airtel or your regional operator's enterprise team about current coverage and pricing before you design around them. Standard LTE with a managed IoT SIM is often the pragmatic default for gateways, because 4G coverage is broad across towns and main corridors.

Messaging protocols

MQTT

MQTT is a lightweight publish/subscribe protocol standardised by OASIS (MQTT 3.1.1 and MQTT 5). Devices connect to a broker over TCP and publish messages to topics; other clients subscribe to topics they care about. Publishers and subscribers never talk directly, which decouples devices from applications.

Core concepts:

  • Topics are hierarchical strings such as site/nairobi-hq/floor2/room201/temperature. Subscribers can use wildcards: + for one level, # for all remaining levels.
  • QoS levels: 0 (at most once), 1 (at least once, duplicates possible), 2 (exactly once, more overhead). QoS 1 with idempotent processing is the usual choice for telemetry.
  • Retained messages let the broker hold the last value on a topic, so a new subscriber immediately learns the current state.
  • Last Will and Testament (LWT) is a message the broker publishes if a client disconnects unexpectedly, which is ideal for online/offline status.
  • Persistent sessions let a broker queue QoS 1 and 2 messages for a client that briefly drops off, useful on flaky LTE links.
  • Ports: 1883 for plain TCP, 8883 for MQTT over TLS. Always use TLS when traffic leaves the site.

A working MQTT example

Run a local broker (Eclipse Mosquitto is a common open-source choice) and test with the command-line clients:

# Terminal 1: subscribe to everything under the site
mosquitto_sub -h localhost -t 'site/nairobi-hq/#' -v

# Terminal 2: publish a reading
mosquitto_pub -h localhost -t 'site/nairobi-hq/floor2/room201/temperature' -m '{"c": 24.6}'

A Python device client using the Eclipse Paho library (version 2.x, installed with pip install paho-mqtt):

import json
import random
import time

import paho.mqtt.client as mqtt

BROKER = "localhost"
PORT = 1883  # use 8883 with client.tls_set() in production
DEVICE_ID = "room201-sensor"
BASE = "site/nairobi-hq/floor2/room201"


def on_connect(client, userdata, flags, reason_code, properties):
    if reason_code.is_failure:
        print(f"Connect failed: {reason_code}")
        return
    print("Connected")
    # Announce we are online (retained so dashboards see current status)
    client.publish(f"{BASE}/status", "online", qos=1, retain=True)
    # Listen for commands addressed to this device
    client.subscribe(f"{BASE}/cmd/#", qos=1)


def on_message(client, userdata, msg):
    print(f"Command on {msg.topic}: {msg.payload.decode()}")


client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id=DEVICE_ID)
client.on_connect = on_connect
client.on_message = on_message

# If we drop off unexpectedly, the broker publishes "offline" for us
client.will_set(f"{BASE}/status", "offline", qos=1, retain=True)

client.connect(BROKER, PORT, keepalive=60)
client.loop_start()

try:
    while True:
        reading = {"c": round(random.uniform(22.0, 27.0), 1), "ts": int(time.time())}
        client.publish(f"{BASE}/temperature", json.dumps(reading), qos=1)
        time.sleep(30)
except KeyboardInterrupt:
    client.publish(f"{BASE}/status", "offline", qos=1, retain=True)
    client.loop_stop()
    client.disconnect()

Points worth noticing: the LWT provides reliable offline detection, retained status messages give dashboards an immediate view, and QoS 1 combined with a timestamp in the payload lets the consumer discard duplicates.

For production, enable TLS (client.tls_set() and port 8883), give each device its own credentials or client certificate, and use broker access control lists so a device can only publish under its own topic prefix.

CoAP

The Constrained Application Protocol (CoAP, RFC 7252) is a compact, REST-like protocol over UDP. It uses familiar methods (GET, PUT, POST, DELETE) and resource URIs, but with a small binary header suited to constrained devices. CoAP uses UDP port 5683, and DTLS on 5684 for security. Its Observe extension lets a client subscribe to changes on a resource.

CoAP fits device-to-device or device-to-gateway communication on constrained IPv6 networks such as Thread. It is less common than MQTT in commercial cloud platforms, so many deployments terminate CoAP at a gateway and forward to MQTT or HTTP.

HTTP and webhooks

HTTP is heavier than MQTT, but it is universal and easy to secure with existing tooling. It is a reasonable choice for gateways that send batched data a few times an hour, and for integrating LoRaWAN network servers with business applications via webhooks.

Matter

Matter is a device interoperability standard, primarily for homes and small buildings. It defines a data model of device types and clusters (for example, On/Off, Level Control, Door Lock, Temperature Measurement) and an interaction model for reading attributes, writing attributes, invoking commands and subscribing to changes. It runs over IPv6 on Wi-Fi, Ethernet and Thread, with BLE used for commissioning.

The important distinction: Matter answers "how does a controller turn on this light, from any vendor?" MQTT answers "how do I move telemetry from thousands of sensors into my platform?" A building may use both, with a local controller bridging Matter devices into an MQTT-based monitoring system.

Putting it together: reference architectures

Office building monitoring:

[Thread/Zigbee sensors] -> [Border router / coordinator]
                                  |
                          [Local gateway: Home Assistant,
                           Node-RED or custom service]
                                  |  MQTT over TLS (8883)
                                  v
                        [MQTT broker: on-prem or cloud]
                                  |
                 +----------------+----------------+
                 |                                 |
       [Time-series DB + dashboards]     [Alerting: SMS, email]

Remote agricultural or water site:

  1. LoRaWAN soil moisture or tank level sensors report every 15-30 minutes.
  2. A solar-powered LoRaWAN gateway with an LTE modem backhauls to the network server.
  3. The network server publishes decoded payloads to MQTT.
  4. A rules engine triggers pump control or sends an SMS alert through an SMS gateway provider.
  5. If the LTE link drops, the gateway buffers where supported, and the application tolerates late data using device timestamps.

For hosting, latency to the nearest hyperscaler regions (South Africa, Europe and the Middle East) is generally fine for telemetry. For data subject to the Kenya Data Protection Act 2019, such as data linked to identifiable people, consider local hosting options from providers such as Safaricom, iXAfrica or Africa Data Centres, and document your cross-border transfer basis.

Security cameras mounted on a buildingCameras and sensors belong on their own network segment, away from laptops and phones.

Choosing a combination: a decision checklist

  • How far does the data need to travel, and is there mains power at the device?
  • How often does the device report, and how big is each message?
  • Does the device need to receive commands quickly, or only send data?
  • Is there reliable cellular coverage at the site? Have you measured it?
  • Will you run your own gateways (Zigbee, Thread, LoRaWAN) or rely on an operator (cellular)?
  • Which messaging protocol does your platform ingest natively?
  • How will devices be identified, authenticated and updated over their lifetime?
  • What is the total cost per device per year, including SIMs, gateways and maintenance visits?

Pitfalls

  • Picking a radio from the datasheet alone. Rated ranges assume ideal conditions. Survey the site.
  • Using QoS 2 everywhere. It adds round trips and broker state. Use QoS 1 and make processing idempotent.
  • Flat topic namespaces. Design topics around site, location and device from the start; renaming later is painful.
  • Shared credentials across devices. One leaked password then compromises the fleet. Use per-device identities.
  • Ignoring time. Devices that reconnect after outages may flush old data. Always include device timestamps and sync clocks via NTP or the network.
  • Underestimating gateway power. A remote gateway needs a correctly sized solar panel and battery for the cloudy season, not the average day.

FAQ

Is MQTT secure?

MQTT itself is a messaging protocol; security comes from TLS, authentication and broker access control. With TLS on port 8883, per-device credentials or certificates and strict topic ACLs, it is suitable for production.

Should I use LoRaWAN or NB-IoT?

LoRaWAN suits sites where you control the infrastructure and coverage is poor, at the cost of running gateways. NB-IoT or LTE-M avoids gateways but depends on operator coverage, plans and module support. Check current operator offerings before deciding.

Does Matter replace MQTT?

No. Matter standardises control of consumer and building devices; MQTT moves telemetry and events between devices and platforms. They solve different problems and often coexist.

Can I run an MQTT broker locally in Kenya?

Yes. A broker such as Mosquitto runs comfortably on modest hardware or a local VM. Running it on-site keeps automation working during internet outages, and you can bridge to a cloud broker for remote dashboards.

How TechBytes can help

We design IoT systems end to end: radio surveys, gateway and power design, MQTT broker architecture and integration with your business applications. If you are planning a monitoring or automation project, our network infrastructure team can assess coverage and connectivity, and our AI and automation team can build the data pipeline and rules on top. For the device layer in homes, see our guide to the best smart home technologies in 2026.

WhatsApp