MegunoLink supports TCP Client connections from your Arduino sketch to a TCP Server hosted by MegunoLink. Your Arduino sketch can connect to MegunoLink over WiFi or wired Ethernet. Arduino hardware supporting TCP connections includes:

  • ESP8266, a low-cost Arduino with built-in WiFi
  • ESP32, a low-cost Arduino with built-in WiFi and Bluetooth
  • EtherTen, an Uno compatible Arduino with built-in Ethernet
  • Ethernet shield, an Arduino compatible shield that adds an Ethernet connection
create TCP Client connection

Create new connections from the Add Connection menu.

Plot data, build interfaces

MegunoLink works just as well over TCP as serial. Check out the overview and learn about interface panels and data visualization.

Creating a TCP Server

To create a TCP Server in MegunoLink:

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

A configuration panel for the new TCP Server connection will be added to the Connection Manager:

TCP Server Configuration

A TCP Server connection panel that will host a server listening on local port 11,000

Configuring the Connection

The TCP Server connection panel displayed in the Connection Manager is used to configure the connection:

TCP Server Configuration

Configure the TCP Server in the Connection Manager visualizer

The controls for configuring the connection are:

  • Connection name: a free-form name to help you identify the connection. This name will be displayed on the Connection Selector.
  • Port: the local port that MegunoLink will open for remote clients to connect to.
  • Delete connection: remove the connection from the project.
  • Listen/Close: start/stop the TCP Server that listens for connections.
  • Connections: Remote clients that have connected to the server. The selected client will receive any commands sent from MegunoLink.

Arduino TCP Client

For your Arduino program to connect MegunoLink it must open a TCP Client connection. You need to know:

  1. The IP address of the computer running MegunoLink. This article shows how to find your IP address.
  2. The port that MegunoLink is listening on. This port is set in the TCP Server configuration panel.

Use the WiFiClient class to create a WiFi client in your Arduino program.

For example, to send data to a plot in MegunoLink using a TCP Client connection on a wireless Arduino such as the ESP32 or ESP8266, you can use the sketch below. Make sure that you:

  • Setup a WiFiConfig library with the SSID and password for your WiFi connection, or enter them directly into the code.
  • Set the Host variable to the IP address of the computer running MegunoLink and the Port variable to the port that MegunoLink is listening on.

Start typing and press Enter to search