Skip to main content

IP Networking — Ethernet, WiFi, UDP, MQTT

Once you need more than two devices talking, or you want to reach the rest of a network rather than another microcontroller, you cross over from raw radios into IP networking. NodeBlue offers two ways onto an IP network, with two different module layouts:

  • Ethernet — the board has its own IP stack (via a Wiznet W5500/W5100 chip and an nEthernet module). Higher-level transports — UDP and MQTT — are then separate modules (nUDP, nMQTTInterface + nMQTTInput + nMQTTOutput) wired into the design.
  • WiFi via ESP8266 — the IP stack lives on the ESP8266 module itself. The board only sees a UART. nESP8266 handles UDP / TCP inside the module (via its Com. Mode setting); you don't add a separate nUDP for this path.

So the same design doesn't move automatically from Ethernet to WiFi — they're laid out differently. The sections below walk through each.

Getting on the network​

Ethernet (W5500 etc.)​

For boards with an Ethernet shield (Wiznet W5500 / W5100 family), drop in an nEthernet module. It's the on-board IP stack.

ParameterDescription
SPI port + CS pinHow the chip is wired to the MCU.
MAC addressA unique 6-byte hardware address (use a random one if your shield doesn't have a printed MAC).
IP modeStatic (fixed IP / mask / gateway / DNS) or DHCP (ask the router).
Static IP / netmask / gateway / DNSOnly when IP mode is Static.

Once initialised, nEthernet is rarely wired directly — it's the carrier on which nUDP / nMQTTInterface run. The Examples/04-Communication/Ethernet design shows the bring-up.

WiFi via ESP8266​

If your project doesn't have a wired LAN, the easy path is an ESP8266 module connected over a UART. The ESP runs its own WiFi and IP stack — nUDP and nMQTT* are not used on this path; the nESP8266 module talks UDP or TCP itself, via its Com. Mode parameter.

ParameterDescription
PortThe hardware UART the ESP module is wired to.
Op. ModeStation (join a WiFi network) or Soft-AP (the board becomes the WiFi network).
Com. ModeUDP or TCP — the transport the ESP relays in and out of the board.
SSID / Key / SecurityWiFi credentials (when in Station mode), or the AP credentials it will advertise (Soft-AP mode).
ChannelWiFi channel (1–13) — when in Soft-AP mode.
Host Name / Host PortThe peer address / port the ESP forwards packets to.
Nb PipesHow many simultaneous TCP/UDP connections the ESP juggles.
Buffer sizeReceive-buffer size in bytes.

You wire data directly into / out of nESP8266's inputs and outputs — the WiFi link and the UDP (or TCP) framing both live inside the module.

note

Boards with native WiFi (ESP32, certain Arduino MKR / Nano IoT variants) follow the same self-contained pattern through their own platform-specific module: the WiFi stack and the UDP/TCP framing are bundled together.

UDP (on top of Ethernet)​

For Ethernet boards, the nUDP module is the no-frills IP transport: "send this packet of bytes to this IP and port; hope it arrives". Perfect for fast control loops, sensor streaming and anywhere you'd rather drop the occasional packet than buffer up latency.

ParameterDescription
Listen PortThe port the module listens on for incoming packets.
Dest IPThe IPv4 address packets are sent to (entered as four bytes).
Dest PortThe port at the destination.

Anything wired into its input becomes a UDP packet to (Dest IP, Dest Port); incoming packets land on the output. The Examples/04-Communication/UDP design shows the basics — small text packets between two boards.

caution

nUDP runs on top of nEthernet. For UDP over WiFi, don't add an nUDP — configure the nESP8266 module's Com. Mode to UDP instead, and it handles the framing itself.

MQTT​

For projects spanning boards, gateways and a backend, MQTT's publish/subscribe model is hard to beat. A central broker holds named topics; each board publishes to topics and subscribes to others. NodeBlue splits the pattern across three modules:

ModuleRole
nMQTTInterfaceThe connection to the broker — host, port, credentials, client id. One per board.
nMQTTInputSubscribes to a topic. Its output emits the payload of every matching incoming message.
nMQTTOutputPublishes to a topic. Each buffer arriving on its input becomes a message.

A typical pattern: every sensor board publishes to home/livingroom/temperature (etc.), and a dashboard board subscribes to home/+/temperature to display them all. Topic wildcards (+ for one level, # for everything beneath) let one subscriber handle many sources without enumerating them.

MQTT brokers commonly run on a Raspberry Pi or any always-on machine on your LAN (Mosquitto is the standard). Once one's up, a NodeBlue board joining the network only needs the broker's IP, a client id, and which topics to publish/subscribe.

Picking between them​

SetupModules
Wired LAN, fire-and-forget packetsnEthernet + nUDP
Wired LAN, pub/subnEthernet + nMQTTInterface + nMQTTInput/nMQTTOutput
WiFi, UDPnESP8266 with Com. Mode = UDP — all in one module
WiFi, TCPnESP8266 with Com. Mode = TCP — all in one module

Two lower-level buses — SPI and I²C — are used internally by a lot of modules (sensors, displays, the radio chips themselves). Start with SPI.