2023-01-29 Simplifying Data Transfer With The Labii Serial Port Widget

2023-01-29

What is serial port?

A serial port is a type of interface that allows communication between a computer and an external device. It transfers data one bit at a time over a single communication line (serial line) and is commonly used to connect a wide range of peripheral devices such as printers, scanners, and other industrial or scientific instruments. Serial ports use either the RS-232 or the RS-485 standard for communication, and are typically accessed through a DB-9 or DB-25 connector on the computer.

There are a variety of research equipment that use serial ports to transfer data. Some examples include:

  1. Spectrometers: Used in chemical and physical research to measure the intensity of light across a range of wavelengths.

  2. Data Loggers: Used in environmental and geological research to record data such as temperature, humidity, and pressure.

  3. Microscopes: Used in biological and medical research to magnify and observe specimens.

  4. Electroencephalography (EEG) Devices: Used in neuroscience research to measure electrical activity in the brain.

  5. Chromatographs: Used in analytical chemistry to separate and analyze compounds in a mixture.

  6. Mass Spectrometers: Used in molecular biology and biochemistry to identify and quantify the components of a sample.

  7. X-ray Diffractometers: Used in materials science research to determine the crystal structure of a sample.

These devices typically use serial ports to transfer data from the equipment to a computer for analysis and storage. The serial port provides a reliable and low-cost means of data transfer that is well suited for many research applications.

Serial port support in Labii

To help researchers to easily communicate with their equipment and retrieve the data needed for their research, Labii provides a serial port widget for supporting data communication with research equipment. It provides a convenient and efficient means of data transfer that helps researchers focus on their work rather than worrying about the underlying technical details of data transfer.

BBC Micro Bit

In this article, I will utilize the BBC micro bit to evaluate the capabilities of reading and writing through the serial port.

The BBC micro bit is a pocket-sized, programmable computer that was developed by the BBC for use in computer education. It has an ARM Cortex-M0 processor, accelerometer, compass, Bluetooth, and several programmable I/O pins. It can be used to create simple interactive projects, from games and music to art and robotics.

Programming Micro Bits to support serial ports

1. Open https://makecode.microbit.org/#editor

2. Begin by displaying the heart icon, accompanied by the power up start melody, then proceed to configure the serial port. Within the serial port configuration, route all data to the USB and set the baud rate to 9600.

basic.showIcon(IconNames.Heart)
music.startMelody(music.builtInMelody(Melodies.PowerUp), MelodyOptions.Once)
serial.redirect(
	SerialPin.USB_TX,
	SerialPin.USB_RX,
	BaudRate.BaudRate9600
)

3. For button A being pressed, add a high pitch tone, serial write the temperature number, and then display the temperature number.

input.onButtonPressed(Button.A, function () {
    music.playTone(988, music.beat(BeatFraction.Whole))
    serial.writeNumber(input.temperature())
    basic.showNumber(input.temperature())
})

4. For button B being pressed, serial write string “LABII”, and then start melody “ba ding”.

input.onButtonPressed(Button.B, function () {
    serial.writeString("LABII")
    music.startMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once)
})

5. For serial on data received “new line()”, show string for serial read until “new line()”, and then start melody “ba ding”.

serial.onDataReceived(serial.delimiters(Delimiters.NewLine), function () {
    basic.showString(serial.readUntil(serial.delimiters(Delimiters.NewLine)))
    music.startMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once)
})

6. Leave it empty for forever.

basic.forever(function () {
	
})

7. Paired to your micro bit and click Download to program it.

See all source code at https://github.com/Labii/labii-serialport

Using the Labii serial port widget to read and write data

  1. Connect your micro bit to your computer

  2. Login to Labii at https://www.labii.app , add a new column with widget “Serial Port”.

    1. baudRate: A positive, non-zero value indicating the baud rate at which serial communication should be established. Default to 9600.

    2. dataBits: The number of data bits per frame.

    3. stopBits: The number of stop bits at the end of a frame.

    4. parity: The parity mode.

    5. bufferSize: A positive, non-zero value indicating the size of the read and write buffers that should be created. flowControl: The flow control mode.

    1. Open add record form

    2. Click Connect button, in the pomp out, select BBC micro:bit and click Connect

    3. Press button A in the micro bit

    4. You shall hear tone High B and a temperature number displayed in your micro bit. At the same time, your serial port in Labii will display the temperature.

    5. Click Disconnect button to close the connection.

    1. Open a record contains the serial port column,

    2. Click Edit to provide a value “LABII”, click Submit.

    3. Once submitted, the Write button will show up.

    4. Click Write button, in the pomp out, select BBC micro:bit and click Connect

    5. Your micro bit should display “LABII” and play melody “ba ding”

    6. Click Disconnect to close the connection.

Other serial port widgets

To support the research community and simplify data transfer, Labii is dedicated to developing more serial port-related widgets that facilitate communication between Labii and research equipment. By providing a wide range of software solutions for different equipment types, Labii aims to make data transfer more efficient, reliable, and accessible for researchers. This will allow researchers to focus on their work and minimize the time spent on technical details. With a commitment to innovation and an understanding of the research community's needs, Labii is poised to play a vital role in advancing research through improved data communication.

Summary

The Labii Serial Port Widget is a software solution for supporting data communication between a computer and research equipment via the serial port. With its intuitive interface and customizable options, the Labii Serial Port Widget streamlines data communication in research and helps researchers focus on their work. To learn more, schedule a meeting with Labii representatives (https://call.skd.labii.com) or create an account (https://www.labii.com/signup/) to try it out yourself.

Last updated