This guide shows how to connect the GrowSpace developer tag to an Arduino Mega 2560 board over serial, and how to receive and parse position data in real time using the lec and lep commands. It also provides example code and a method for building stable, high-speed communication using the Mega 2560’s hardware serial support.
⚠️ The UNO board has only one hardware serial port, which can cause errors during high-speed communication. The Mega 2560 provides Serial1–3, enabling stable communication.
Arduino IDE Setup and Board Connection
Install and launch the Arduino IDE
Apply the following settings from the top menu
Tools > Board > Arduino Mega or Mega 2560
Tools > Port > select the connected COM port (e.g., COM3)
Connect the Arduino Mega 2560 to your PC via USB
Hardware Pin Connection
Connect as follows, using the right connector (5V only) of the GrowSpace developer tag:
Developer Tag Pin
Arduino Mega Pin
TX
RX1 (Pin 19)
RX
TX1 (Pin 18)
5V
5V
GND
GND
🔄 TX ↔ RX must be cross-connected for communication to work.
Below is an example pin layout for the Arduino Mega board.
Connect based on the Serial1 port’s TX1 (pin 18) / RX1 (pin 19).
The developer tag connected to the Arduino Mega 2560
// --- Full lec parsing ---
void parseLEC(String line) {
Serial.println("[LEC Distance + Position Result]");
int posIndex = line.indexOf("POS,");
if (posIndex == -1) {
Serial.println("→ Missing position info");
return;
}
String distPart = line.substring(0, posIndex - 1);
String posPart = line.substring(posIndex);
Serial.println("▶ Anchor distance info:");
int anchorIdx = 0;
int anStart = 0;
while ((anStart = distPart.indexOf("AN", anStart)) != -1) {
int idStart = anStart + 2;
int idEnd = distPart.indexOf(",", idStart);
String id = distPart.substring(idStart, idEnd);
int valStart = idEnd + 1;
float x = distPart.substring(valStart, distPart.indexOf(",", valStart)).toFloat();
valStart = distPart.indexOf(",", valStart) + 1;
float y = distPart.substring(valStart, distPart.indexOf(",", valStart)).toFloat();
valStart = distPart.indexOf(",", valStart) + 1;
float z = distPart.substring(valStart, distPart.indexOf(",", valStart)).toFloat();
valStart = distPart.indexOf(",", valStart) + 1;
float d = distPart.substring(valStart, distPart.indexOf(",", valStart)).toFloat();
Serial.print("AN"); Serial.print(anchorIdx++); Serial.print(" (ID "); Serial.print(id); Serial.print("): ");
Serial.print("x="); Serial.print(x); Serial.print(", y="); Serial.print(y); Serial.print(", z="); Serial.print(z);
Serial.print(" → distance: "); Serial.print(d); Serial.println("m");
anStart = valStart;
}
Serial.println("▶ Tag position info:");
parseLEP(posPart);
}
lep execution result
lec execution result
Wrap-Up
With this guide, you can set up serial communication between the Arduino Mega 2560 and the GrowSpace developer tag, and practice parsing and printing real-time position data based on the lec and lep commands.
lep: Check X, Y, Z coordinates + Quality Factor (QF)