Template: SIM8200X Working with Raspberry Pi
The use of Raspberry Pi OS
First-time Configuration
Please don't type the wrong letter, it's better to copy and paste.
sudo apt-get install p7zip-full wget https://files.waveshare.com/upload/8/89/SIM8200_for_RPI.7z 7z x SIM8200_for_RPI.7z -r -o./SIM8200_for_RPI sudo chmod 777 -R SIM8200_for_RPI cd SIM8200_for_RPI sudo ./install.sh
Please do not delete or modify the "option" directory, "qmi_wwan_simcom" directory, "default.script", "install.sh" files, otherwise it will affect the loading of the driver.
If there is an error, please confirm whether the system is "2020-08-20-raspios-buster-armhf", and take a screenshot of the error message so that engineers can help you analyze and solve the problem.
Run "ifconfig -a" to see that "WWAN0" has been generated.
Test AT Command
sudo apt-get install minicom sudo minicom -D /dev/ttyUSB2
NIDS Dial-up
cd Goonline make sudo ./simcom-cm
After running codes, DNS information is shown in the figure below:
After connecting two SIM820X to the Raspberry Pi through USB, two network cards—wwan0 and wwan1 can be recognized. The two network cards can be dialed at the same time through the following commands: (The network speed cannot be superimposed)
sudo ./simcom-cm -i wwan0 sudo ./simcom-cm -i wwan1
- Note: If the IP cannot be obtained or the networking is not successful, use the following commands to obtain the IP and set the DNS networking:
sudo dhclient -v wwan0 sudo route add -net 0.0.0.0 wwan0
Auto-run
If you want to set the codes auto-run after booting, you can modify rc.local file:
sudo nano /etc/rc.local
Add the line to file as below:
sudo /home/pi/SIM8200-M2_5G_HAT_code/Goonline/simcom-cm &
Note that you have to add "&" to the end of the command, make sure that the command can be run in the background, or the Pi may not boot normally.
Live streaming with ffmpeg
If you are using the 2020-08-20-raspios-buster-armhf image, then you don't need to install anything as the system already comes with ffmpeg.
Going straight to the topic, assuming you already have a camera and it's properly connected to the Raspberry Pi, then proceed with the tutorial.
- The camera must be enabled by running the raspi-config command before using it:
sudo raspi-config Select Enable Camera, select YES
- If it is a camera using the CSI interface, the system cannot find the device node of /dev/video0. A line for bcm2835-v4l2 needs to be added to the /etc/modules file:
sudo nano /etc/modules
add:
bcm2835-v4l2
Then after the system starts, the system will load the module name in this file and restart the system:
sudo reboot ls /dev/video*
The video0 device node is found below.
Note: If after performing the first steps, please confirm that the operation and instructions are correct.
Suppose you are using Douyu Live now, register your account and enable the host function, open Douyu Live Host Center, and find the live broadcast settings.
Open video plug flow setting:
The rtmp address and live code will be obtained, and the Raspberry Pi will execute the command:
ffmpeg -f video4linux2 -s 640x480 -r 25 -i /dev/video0 -c:v h264_omx -f flv "rtmp address/live code"
For example: open a terminal first, runs the 5G network:
cd Goonline sudo ./simcom-cm
and then open another terminal, run the following command:
ffmpeg -f video4linux2 -s 640x480 -r 25 -i /dev/video0 -c:v h264_omx -f flv "rtmp://sendtc3.douyu.com/live/9188303rTNGmU7CS?wsSecret=ef762877aae120262eaf23c3f60a28bf&wsTime=5f59dbf0&wsSeek=off&wm=0&tw=0&roirecognition=0"
rtmp://sendtc3.douyu.com/live is the address, and the next section is the live code. Enter the room number at this time, you can observe the live broadcast, the delay is about 1-2S.