MegunoLink supports UDP connections with your Arduino through WiFi or wired ethernet connections. The ESP8266 and ESP32 boards support WiFi connections while the EtherTen and Ethernet Shield support wired LAN connections.

To create a UDP connection:

  1. Open a connection manager visualizer
  2. Choose UDP from the Add Connection drop-down menu
Add a UDP connection

Create a new connection by selecting UDP from the Add Connection menu.

MegunoLink will create a configuration panel for the new UDP connection:

Edit UDP connection settings

The UDP configuration panel

The title box (top-left corner) lets you give the connection a name. This is useful to keep track when you have multiple connections. The name you enter here will be displayed on the Connect button shown in visualizers.

The Receive port is the UDP port that MegunoLink will listen on. Values less than 1,023 are reserved by the system while values between 1024 and 49,152 may be used by other applications. Generally any number between 49,152 and 65,535 should be fine.

The Destination IP address and port is the address that MegunoLink will send commands or messages to. The IP address 255.255.255.255 is a broadcast address. Messages will be sent to all devices listening on the destination port.

Click the Connect button to open the connection and begin receiving data. Only one program can use the port at any time so MegunoLink will show an error if another program already has the port open.

Sending UDP Data from an ESP8266 Arduino

This example sketch demonstrates plotting data and sending messages through a UDP connection receiving on port 52,791. It uses the ESP8266 Arduino toolchain with tzapu’s WiFiManager to attach to a wireless network.

Processing Commands sent over a UDP Connection

This example sketch demonstrates receiving commands sent over a UDP connection. Commands are sent to port 52790 and processed using the command dispatcher. The sketch handles Hello and GetADCValue commands replying with a greeting and a measurement from the adc converter, respectively. The ADC value is sent to a MegunoLink table. You can open the Arduino code and MegunoLink project file from MegunoLink’s Library Examples menu.

Handling UDP commands

Start typing and press Enter to search