UART Data Format
This is the newest version of μLanding's UART protocol.
The standard UART protocol is used for our serial transmission interface. The protocol may be modified based on your specific requirement. Contact us to request a change in protocol or other requirements you may have with your system.
Communication Protocol
The communication protocol is:
- Standard UART
- Baud rate is 115200 b/s
- Data length is 8 bits, plus one start bit and one stop bit, and no parity bit
- I/O standard is 3.3V LVTTL
Connection Interface
In the UART data format, the GREEN port is TX pin and the WHITE port is the RX pin. The RED and BLACK port keep the same, as 5V DC power supply and Ground, respectively.

user interface on μLanding™ for UART
Data Format for Serial Transmission Interface
The frame of output data consists of 6 Bytes. The byte structure is explained below. Note that an 'x' refers to a variable bit containing dynamic data.
Byte 1 | 0xFE | Packet Header |
Byte 2 | 0x01 | Version ID |
Byte 3 | 0bxxxxxxxx | Altitude (Least Significant 8 Bits) |
Byte 4 | 0bxxxxxxxx | Altitude (Most Significant 8 Bits) |
Byte 5 | 0bxxxxxxxx | SNR (signal to noise ratio) this is helpful in analyzing data. |
Byte 6 | 0bxxxxxxxx | Checksum (see formula below) |
Explanation
Altitude:
The altitude bytes can be combined (total 16 bits) to represent the altitude information in centimeters. The structure would be: 0x[MSB][LSB], where MSB and LSB are each two hexadecminal numbers (8 bits).
Altitude data will be '0' (Byte 3 and Byte 4 are both 0) if it is not valid.
SNR:
The definition of SNR is this case is '10*log10(Power of Signal/Power of Noise Floor)', and its range is from 0 dB to 60 dB. The altitude reading will be associated with SNR to indicate the quality of the reflections.
Checksum:
The Checksum Byte could be used in the following:
checksum = (Version_ID + Altitude_H + Altitude_L + SNR) & 0xFF
If checksum = 1, check passed
if checksum = 0, check failed
Example Python 2.7 Code for receiving/showing data on PC
Note: Please download necessary Python package before running this example script.
from serial import Serial
import struct
serial = Serial('/dev/ttyUSB0', 115200, 8, 'N', 1) ### This serial port name may be various on OS or machine
print serial.isOpen()
serial.flushInput()
serial.flushOutput()
while (1):
byte = struct.unpack('B', serial.read(1))[0]
if (byte == 0xFE):
byte2 = struct.unpack('B', serial.read(1))[0]
byte3 = struct.unpack('B', serial.read(1))[0]
byte4 = struct.unpack('B', serial.read(1))[0]
byte5 = struct.unpack('B', serial.read(1))[0]
byte6 = struct.unpack('B', serial.read(1))[0]
header = byte
version_id = byte2
lsb_byte = byte3
msb_byte = byte4
snr = byte5
check_sum_transmitter = byte6
check_sum_receiver = (byte2 + byte3 + byte4 + byte5) & 0xFF
ALTITUDE = byte3 + (byte4 << 8)
### Print received data
if (check_sum_receiver == check_sum_transmitter):
if (ALTITUDE > 0):
print "checksum passed and altitude data is valid! Altitude: " + str(ALTITUDE) + ", SNR:" + str(snr) + '\r\n'""
else:
print "checksum passed, but altitude data is not valid! "
else:
print "checksum failed!!!" + '\r\n'
else:
continue
Example Arduino Code for receiving/showing data on PC
Note: Please install Arduino IDE before running this example script.
// This function is called only once, at reset.
void setup() {
Serial.begin(115200);
Serial.println("uLanding Readout");
}
// This function is called continuously, after setup() completes.
void loop() {
int altitude = 0;
int data[64];
int data_packet[6];
int idx;
int receiver_checksum;
int SNR;
/// Buffer size = default 64 Bytes, this depends on setting from Arduino board!
while (Serial.available() == 63) {
delay(20);
for(int i=0;i<64;i++){
data[i]=Serial.read();
}
for (int j=0;j<12;j++){
if (data[10+j] == 0xFE && data[10+j+1] == 0x01){
idx = j;
break;
}
}
data_packet[0] = data[10+idx];
data_packet[1] = data[11+idx];
data_packet[2] = data[12+idx];
data_packet[3] = data[13+idx];
data_packet[4] = data[14+idx];
data_packet[5] = data[15+idx];
altitude = data_packet[2] + (data_packet[3] << 8);
SNR = data_packet[4];
receiver_checksum = (data_packet[1] + data_packet[2] + data_packet[3] + data_packet[4]) & 0xff;
/// Print received data
if (receiver_checksum == data_packet[5]){
if (altitude > 0){
Serial.print("Checksum passed, Altitude: ");
Serial.print (altitude);
Serial.print(", SNR: ");
Serial.print (SNR);
Serial.print("\n\r");
}else{
Serial.print("Checksum passed, but altitude data is not valid");
}
}else{
Serial.print ("Checksum failed!!!");
Serial.print("\n\r");
}
}
}
Updated over 4 years ago