4.2 KiB
Serial Studio and LTE modem HUAWEI K5161H
Overview
This project demonstrates how to use Serial Studio to visualize signal quality data from a LTE modem HUAWEI K5161H.
Three methods of sending data are described:
The examples are implemented on OS Archlinux, in which Serial Studio can be:
- run from AppImage
- installed from Arch User Repository (AUR) manually or by AUR helper, e.g.
yay
yay -S serial-studio-bin
- compiled by cmake
Data from HUAWEI K5161H can be get by url API http://192.168.9.1/api/device/signal
Python was used to receive, process and generate data frames.
Method 1 - Virtual Serial Port
Create Virtual Serial Port
- Install socat
sudo pacman -S socat
- Create a linked pair of virtual serial ports, ttyV0 for listening and ttyV1 for sending data
socat -d -d pty,rawer,echo=0,link=/tmp/ttyV0,b9600 pty,rawer,echo=0,link=/tmp/ttyV1,b9600
- You can check the operation of the virtul serial ports by reading the file
/tmp/ttyV0
and writing data to the filecat /tmp/ttyV0
/tmp/ttyV1
echo 100 > /tmp/ttyV1
- Install
python-pyserial
sudo pacman -S python-pyserial
- Run a Python script
lte_serial.py
to process data and send it to the virtual serial port/tmp/ttyV1
python lte_serial.py
Serial Studio configuration for Virtual Serial Port
- Run Serial Studio
- Select DEVICE SETUP → I/O Interface: Serial Port
- Select FRAME PARSING → Parse via JSON Project File
- Select Project file →
lte.json
- Manually enter COM Port →
/tmp/ttyV0
and press Enter - Select Baud Rate → 9600
- Click Connect in upper right corner
After get first frame of data Serial Studio will automatic open dashboard with plots.
Method 2 - MQTT
Prepare MQTT broker
- Install MQTT broker Mosquitto
sudo pacman -S mosquitto
- Run MQTT broker with default settings
mosquitto --verbose
- You can check MQTT broker by sending data
mosquitto_pub -m "abcd,100,50,75,89" -t "lte"
- Install Python client library for MQTT - paho
sudo pacman -S python-paho-mqtt
- Run a Python script
lte_mqtt.py
to process and send data to the MQTT brokerpython lte_mqtt.py
Serial Studio Configuration for MQTT
- Run Serial Studio
- Select FRAME PARSING → Parse via JSON Project File
- Select Project file →
lte.json
- Click MQTT in the top bar
- Set Host → 127.0.0.1
- Set Port → 1883
- Set Topic → lte
- Select Mode → Subscriber
- Set Keep Alive → 600
- Click Connect
After get first frame of data Serial Studio will automatic open dashboard with plots.
Method 3 - UDP Socket
Solution with UDP Socket looks much simpler than other.
Run a Python script lte_udp.py
to process data and send it to the UDP Socket
python lte_udp.py
Serial Studio Configuration for UDP Socket
- Run Serial Studio
- Select DEVICE SETUP → I/O Interface: Network Socket
- Select FRAME PARSING → Parse via JSON Project File
- Select Project file →
lte.json
- Select Socket type → UDP
- Set Remote address → 127.0.0.1
- Set Local port → 5005
- Click Connect in upper right corner
After get first frame of data Serial Studio will automatic open dashboard with plots.