Measure SIM signal strength with Raspberry Pi

Overview

It became necessary to measure the radio wave strength of the place where the radio wave reaches the limit with LTE SIM communication, and first I measured the radio wave strength of SIM using Raspberry Pi at home with a good radio wave environment, so I will summarize the results It was. IMG_8437.jpg

environment

The SIM prepared this time is SORACOM's plan-D that covers the DoCoMo area. The equipment was tested with the following configuration. ・ Raspberry Pi3 + LTE communication module (4GPI) ・ Raspberry Pi4 + USB modem (MS2372-607) The OS is Raspbian, but for Raspberry Pi 3, I used 4gpi-buster-lite-20200612.zip for 4GPI and updated it to the latest state.

Raspberry Pi4 + USB modem (MS2372-607) environment construction example

The example of using 4GPI is omitted, and an example of building a general USB modem environment is briefly explained. Plug in the USB modem and run the command lsusb to verify that Device 004 recognizes the modem.

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The USB modem (MS2372-607) is recognized by / dev / ttyUSB0. For reference, in the case of 4GPI, it will be / dev / tty4GPI.

$ ls -al /dev/ttyUSB*
crw-rw-rw- 1 root dialout 188, 0 Sep 22 00:19 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Sep 22 00:11 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Sep 22 00:11 /dev/ttyUSB2

SORACOM Air will be available at:

$ curl -O https://soracom-files.s3.amazonaws.com/setup_air.sh
$ sudo bash setup_air.sh

You can check the connection of network interface wwan0 as follows.

$ ifconfig wwan0
wwan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.62.145  netmask 255.255.0.0  broadcast 169.254.255.255
        ether 00:1e:10:1f:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 49  bytes 14994 (14.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Measurement of SIM signal strength

In order to measure the signal strength of SIM, it is necessary to send the corresponding AT command by serial communication with the modem or communication module and receive the result. The AT command that can acquire the signal strength is ** AT + CSQ **, and the signal strength is determined based on this output result.

Judgment of signal strength

The signal strength is the AT command ** AT + CSQ **, but the result is expressed as ** + CSQ: 19,99 **. ** 19 ** in the above result example is RSSI (Received Signal Strength Indicator), which is 0 to 31 or 99. (99 is unknown or undetectable.) In the above result example, ** 99 ** is BER (Bit Error Rate), and 99 seems to mean that a bit error occurred or was unknown or could not be detected. To convert this to a dBm value that represents the signal strength, calculate using the formula **-113 + (RSSI value * 2) **. The RSSI value, dBmc value, and signal strength are summarized in the table below, but if you want to know the rough signal strength, the RSSI value is sufficient.

RSSI dBm Connection status
0 -113 or less -
1 -111 -
2~9 -109~-95 Marginal
10~14 -93~-85 OK
15~19 -83~-75 Good
20~30 -73~-53 Excellent
31 -51 or greater -
99 - Not known or not detectable

Program to measure radio field strength

This time, I created a program to measure the signal strength with Python 2.7. Python serial communication requires pyserial.

$ pip install pyserial

I created the following program by referring to the information on the Web. ** / dev / ttyUSB0 ** is for a USB modem (MS2372-607) and ** / dev / tty4GPI ** for 4GPI.

LteSimLevel.py


#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import serial

modem = serial.Serial("/dev/ttyUSB0",baudrate=115200,timeout=1)

def sendAt(cmd):
   modem.write('AT+'+cmd+'\r')
   time.sleep(0.1)
   return modem.read(32798)

def calcDbm(csq):
   csq = csq.replace('OK','')
   csq = csq.replace('+CSQ: ','')
   csq = csq.replace('\n','')
   csq = csq.replace('\r','')
   dec = csq.split(',')
   if unicode(dec[0]).isdecimal():
     dbm = -113 + (int(dec[0]) * 2)
     return dbm
   else:
     return -113

def connStatus(dbm):
  if dbm >= -73:
    return "Excellent"
  elif dbm >= -83:
    return "Good"
  elif dbm >= -93:
    return "OK"
  elif dbm < -93:
    return "Alert:Marginal"

try:
   if modem.inWaiting()>0: modem1.flushInput()
   csq = sendAt('CSQ')
   print("AT command response")
   print(csq)
   print("SIM signal strength")
   dbm = calcDbm(csq)
   print(connStatus(dbm) + " (" + str(dbm) + "dbm)" )
finally:
   modem.close()

Radio field strength measurement results

In the case of the USB modem (MS2372-607), it was as follows.

$ python LteSimLevel.py
AT command response

+CSQ: 19,99

OK

SIM signal strength
Good (-75dbm)

In the case of 4GPI, it was as follows.

$ python LteSimLevel.py
AT command response

+CSQ: 27,99

OK

SIM signal strength
Excellent (-59dbm)

In the case of a USB modem (MS2372-607), the antenna is built into the USB dongle and the antenna gain is low, and it is estimated that 4GPI, which has a solid antenna on a dedicated board, has that much antenna gain. It is a convincing result. Now that we have confirmed the difference in radio field strength, it seems that we can measure the radio field strength in the place where the radio wave reaches the limit by LTE SIM communication.

Reference site

__ Using SORACOM Air on various devices __ https://dev.soracom.io/jp/start/device_setting/ __Read AT command data with pySerial __ https://stackoverrun.com/ja/q/6675281 __Reference information necessary for determining the installation location when using 3G / LTE __ https://armadillo.atmark-techno.com/howto/armadillo_3g-lte_installation-location AT Command AT+CSQ https://m2msupport.net/m2msupport/atcsq-signal-quality/ __ AT commands learned using SORACOM --3 Practical edition (AT + CSQ commands) __ https://bearmini.hatenablog.com/entry/at-command3 AT Commands https://wiki.teltonika-networks.com/view/AT_Commands MS2372-607 https://blog.soracom.com/ja-jp/2018/08/17/ms2372/ 4GPI https://mechatrax.com/products/4gpi/

Recommended Posts

Measure SIM signal strength with Raspberry Pi
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Measure CPU temperature of Raspberry Pi with Python
Mutter plants with Raspberry Pi
Measure temperature and humidity with Raspberry Pi3 and visualize with Ambient
Measure and compare temperature with Raspberry Pi and automatically generate graph
[Raspberry Pi] Stepping motor control with Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
Servo motor control with Raspberry Pi
Serial communication with Raspberry Pi + PySerial
OS setup with Raspberry Pi Imager
Try L Chika with raspberry pi
VPN server construction with Raspberry Pi
Try moving 3 servos with Raspberry Pi
Using a webcam with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
Hello World with Raspberry Pi + Minecraft Pi Edition
Build a Tensorflow environment with Raspberry Pi [2020]
Get BITCOIN LTP information with Raspberry PI
Try fishing for smelt with Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Improved motion sensor made with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
Make a wash-drying timer with a Raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Display the signal strength RSSI of a specific SSID (raspberry pi (linux))
Discord bot with python raspberry pi zero with [Notes]
Media programming with Raspberry Pi (preparation for audio)
I tried L-Chika with Raspberry Pi 4 (Python edition)
Raspberry Pi backup
Enjoy electronic work with GPIO on Raspberry Pi
MQTT RC car with Arduino and Raspberry Pi
Power on / off your PC with raspberry pi
Use Majoca Iris elongated LCD with Raspberry Pi
CSV output of pulse data with Raspberry Pi (CSV output)
Observe the Geminids meteor shower with Raspberry Pi 4
Get CPU information of Raspberry Pi with Python
Play with your Ubuntu desktop on your Raspberry Pi 4
Raspberry + am2302 Measure temperature and humidity with temperature and humidity sensor
Get temperature and humidity with DHT11 and Raspberry Pi
Stock investment analysis app made with Raspberry Pi
Logging Inkbird IBS-TH1 mini values with Raspberry Pi
Connect to MySQL with Python on Raspberry Pi
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Record temperature and humidity with systemd on Raspberry Pi
Machine learning with Raspberry Pi 4 and Coral USB Accelerator
Run LEDmatrix interactively with Raspberry Pi 3B + on Slackbot
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Easy IoT to start with Raspberry Pi and MESH
Display images taken with the Raspberry Pi camera module
Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
Try to visualize the room with Raspberry Pi, part 1
Try debugging Python on Raspberry Pi with Visual Studio.