Difference between revisions of "Template:RPi demo"

From Waveshare Wiki
Jump to: navigation, search
 
(13 intermediate revisions by 3 users not shown)
Line 19: Line 19:
 
| FLIGHTMODE || P7 (corresponding to P4 of BCM), enter flight mode when pulled high
 
| FLIGHTMODE || P7 (corresponding to P4 of BCM), enter flight mode when pulled high
 
|}
 
|}
 +
<font color="#FF0000">* FLIGHTMODE is wired to pull up and will enter into flight mode.</font>
  
 
=== Raspberry Pi initialization settings ===
 
=== Raspberry Pi initialization settings ===
In order to ensure that the SIM7600X 4G HAT can work normally after being connected to the Raspberry Pi, it is necessary to initialize the level output of some pins of the Raspberry Pi. The specific operations are as follows:
+
To ensure that the SIM7600X 4G HAT can work normally after being connected to the Raspberry Pi, it is necessary to initialize the level output of some pins of the Raspberry Pi. The specific operations are as follows:
*Download [https://{{SERVERNAME}}/w/upload/2/29/SIM7600X-4G-HAT-Demo.7z sample program], after decompression, rename the c folder under the Raspberry folder to SIM7600X, Then copy the entire SIM7600X folder to the Raspberry Pi /home/pi directory,
+
*Download [https://files.waveshare.com/upload/2/29/SIM7600X-4G-HAT-Demo.7z sample demo], after decompression, rename the c folder under the Raspberry folder to SIM7600X, Then copy the entire SIM7600X folder to the Raspberry Pi /home/pi directory.
*The command line enters the /home/pi/SIM7600X directory and executes the command
+
*The command line enters the /home/pi/SIM7600X directory and executes the command.
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
   chmod 777 sim7600_4G_hat_init
 
   chmod 777 sim7600_4G_hat_init
 
</syntaxhighlight>
 
</syntaxhighlight>
*Set the boot initialization script, run the command:
+
*Set the boot initialization script, and run the command:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
   sudo nano /etc/rc.local
 
   sudo nano /etc/rc.local
Line 36: Line 37:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
[[File:sim7600CE-28.png]]
 
[[File:sim7600CE-28.png]]
 +
 
===Raspberry Pi serial port configuration===
 
===Raspberry Pi serial port configuration===
 
Since the Raspberry Pi serial port is used for terminal debugging by default, if you need to use the serial port, you need to modify the Raspberry Pi settings. Execute the following command to enter the Raspberry Pi configuration:<br/>
 
Since the Raspberry Pi serial port is used for terminal debugging by default, if you need to use the serial port, you need to modify the Raspberry Pi settings. Execute the following command to enter the Raspberry Pi configuration:<br/>
Line 41: Line 43:
 
  sudo raspi-config
 
  sudo raspi-config
 
</syntaxhighlight>
 
</syntaxhighlight>
Select Interfacing Options ->Serial ->no -> yes to disable serial debugging<br/>
+
Select Interfacing Options ->Serial ->no -> yes to disable serial debugging.<br/>
 
[[File:interface18.png]]<br/>
 
[[File:interface18.png]]<br/>
Open the /boot/config.txt file, find the following configuration statement to enable the serial port, if not, add it at the end of the file:<br/>
+
Open the /boot/config.txt file, and find the following configuration statement to enable the serial port, if not, add it at the end of the file:<br/>
 
  enable_uart=1
 
  enable_uart=1
Restart to take effect
+
Restart to take effect.
 +
 
 
===Raspberry Pi minicom serial port debugging===
 
===Raspberry Pi minicom serial port debugging===
1. Insert the module into the Raspberry Pi<br />
+
1. Insert the module into the Raspberry Pi.<br />
2. Install minicom, minicom is a serial debugging tool for linux platform:<br />
+
2. Install minicom, minicom is a serial debugging tool for the Linux platform:<br />
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
   sudo apt-get install minicom
 
   sudo apt-get install minicom
 
</syntaxhighlight>
 
</syntaxhighlight>
 
3. Execute minicom -D /dev/ttyS0 (ttyS0 is the serial port of Raspberry Pi 3B/3B+/4B). <br />
 
3. Execute minicom -D /dev/ttyS0 (ttyS0 is the serial port of Raspberry Pi 3B/3B+/4B). <br />
Default baud rate is 115200<br />
+
The default baud rate is 115200.<br />
 
Raspberry Pi 2B/zero, the user serial device number is ttyAMA0, and the Raspberry Pi 3B/3B+/4B serial device number is ttyS0. <br />
 
Raspberry Pi 2B/zero, the user serial device number is ttyAMA0, and the Raspberry Pi 3B/3B+/4B serial device number is ttyS0. <br />
4. Take the AT synchronization test as an example, send relevant commands, as shown in the following figure: <br />[[File:sim7600CE-20.png]]<br />
+
4. Take the AT synchronization test as an example, and send relevant commands, as shown in the following figure: <br />[[File:sim7600CE-20.png]]<br />
<font color="red">* minicom can enter setting mode by pressing Ctrl+A, then Z, and select X to exit. </font>
+
<font color="red">* minicom can enter setting mode by pressing Ctrl+A, then Z, and select X to exit. </font><br>
=== Sample Program ===
+
5. Raspberry Pi 5 configures the ttyS0 serial port:
1. Insert the module into the Raspberry Pi<br/>
+
*Edit config.txt file:
2. Download the sample program to the /home/pi/ path;
+
  sudo nano /boot/config.txt
 +
*Add the following and the statement at the end.
 +
  dtoverlay=disable-bt
 +
*You can see ttyS0 after restarting.
 +
 
 +
=== Sample Demo ===
 +
1. Insert the module into the Raspberry Pi.<br/>
 +
2. Download the sample demo to the /home/pi/ path:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
wget https://www.waveshare.net/w/upload/2/29/SIM7600X-4G-HAT-Demo.7z
+
wget https://files.waveshare.com/upload/2/29/SIM7600X-4G-HAT-Demo.7z
 
sudo apt-get install p7zip-full
 
sudo apt-get install p7zip-full
 
7z x SIM7600X-4G-HAT-Demo.7z -r -o/home/pi
 
7z x SIM7600X-4G-HAT-Demo.7z -r -o/home/pi
 
sudo chmod 777 -R /home/pi/SIM7600X-4G-HAT-Demo
 
sudo chmod 777 -R /home/pi/SIM7600X-4G-HAT-Demo
 
</syntaxhighlight>
 
</syntaxhighlight>
3. Go to the bcm2835 directory, compile and install it
+
3. Go to the bcm2835 directory, compile, and install it.
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
  chmod +x configure && ./configure && sudo make && sudo make install
 
  chmod +x configure && ./configure && sudo make && sudo make install
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Note: If there is a problem with the compilation, please refer to the instructions in the FAQ. <br />
 
Note: If there is a problem with the compilation, please refer to the instructions in the FAQ. <br />
4. Go to the corresponding instance directory, compile and run the program. The relevant instructions are as follows (take the PhoneCall program as an example):
+
4. Go to the corresponding instance directory, compile, and run the demo. The relevant instructions are as follows (take the PhoneCall demo as an example):
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
sudo make clean //Clear the original executable file
 
sudo make clean //Clear the original executable file
 
sudo make //recompile
 
sudo make //recompile
sudo ./PhoneCall //Run the program
+
sudo ./PhoneCall //Run the demo
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Use a combination of the above commands:<br />
 
Use a combination of the above commands:<br />
Line 81: Line 91:
 
  sudo make clean && sudo make && sudo ./PhoneCall
 
  sudo make clean && sudo make && sudo ./PhoneCall
 
</syntaxhighlight>
 
</syntaxhighlight>
==== '''PHONECALL call demo''' ====
+
==== '''PHONECALL Call Demo''' ====
 
[[File:pnonecall.png|1000px]]
 
[[File:pnonecall.png|1000px]]
  
==== '''SMS text message sending and receiving demo''' ====
+
==== '''SMS Text Message Sending and Receiving Demo''' ====
 
[[File:SMS.png|1000px]]
 
[[File:SMS.png|1000px]]
  
Line 90: Line 100:
 
[[File:GPSPOSTION3.png|1000px]]
 
[[File:GPSPOSTION3.png|1000px]]
  
===='''TCP network communication demo'''====
+
===='''TCP Network Communication Demo'''====
 
[[File:tcp-network-3.png|1000px]]
 
[[File:tcp-network-3.png|1000px]]
  
==== '''FTP download and upload demos''' ====
+
==== '''FTP Download and Upload Demos''' ====
 
[[File:FTP-DOWNLOAD3.png|1000px]]
 
[[File:FTP-DOWNLOAD3.png|1000px]]

Latest revision as of 06:14, 18 March 2024

Hardware Connection

pin connection diagram with Raspberry Pi

SIM7600X 4G HAT has onboard Raspberry Pi GPIO interface, which can be directly inserted into various versions of Raspberry Pi; the following table shows the connection between Raspberry Pi pins and module pins (Raspberry Pi 3rd Generation B+):

SIM7600X 4G HAT Raspberry Pi
5V 5V
GND GND
RXD TXD (corresponding to 14 of BCM)
TXD RXD (corresponding to 15 of BCM)
PWR P22 (corresponding to P6 of BCM)
FLIGHTMODE P7 (corresponding to P4 of BCM), enter flight mode when pulled high

* FLIGHTMODE is wired to pull up and will enter into flight mode.

Raspberry Pi initialization settings

To ensure that the SIM7600X 4G HAT can work normally after being connected to the Raspberry Pi, it is necessary to initialize the level output of some pins of the Raspberry Pi. The specific operations are as follows:

  • Download sample demo, after decompression, rename the c folder under the Raspberry folder to SIM7600X, Then copy the entire SIM7600X folder to the Raspberry Pi /home/pi directory.
  • The command line enters the /home/pi/SIM7600X directory and executes the command.
chmod 777 sim7600_4G_hat_init
  • Set the boot initialization script, and run the command:
sudo nano /etc/rc.local
  • Add before exit 0 (as shown below):
sh /home/pi/SIM7600X/sim7600_4G_hat_init

Sim7600CE-28.png

Raspberry Pi serial port configuration

Since the Raspberry Pi serial port is used for terminal debugging by default, if you need to use the serial port, you need to modify the Raspberry Pi settings. Execute the following command to enter the Raspberry Pi configuration:

sudo raspi-config

Select Interfacing Options ->Serial ->no -> yes to disable serial debugging.
Interface18.png
Open the /boot/config.txt file, and find the following configuration statement to enable the serial port, if not, add it at the end of the file:

enable_uart=1

Restart to take effect.

Raspberry Pi minicom serial port debugging

1. Insert the module into the Raspberry Pi.
2. Install minicom, minicom is a serial debugging tool for the Linux platform:

sudo apt-get install minicom

3. Execute minicom -D /dev/ttyS0 (ttyS0 is the serial port of Raspberry Pi 3B/3B+/4B).
The default baud rate is 115200.
Raspberry Pi 2B/zero, the user serial device number is ttyAMA0, and the Raspberry Pi 3B/3B+/4B serial device number is ttyS0.
4. Take the AT synchronization test as an example, and send relevant commands, as shown in the following figure:
Sim7600CE-20.png
* minicom can enter setting mode by pressing Ctrl+A, then Z, and select X to exit.
5. Raspberry Pi 5 configures the ttyS0 serial port:

  • Edit config.txt file:
 sudo nano /boot/config.txt
  • Add the following and the statement at the end.
 dtoverlay=disable-bt
  • You can see ttyS0 after restarting.

Sample Demo

1. Insert the module into the Raspberry Pi.
2. Download the sample demo to the /home/pi/ path:

wget https://files.waveshare.com/upload/2/29/SIM7600X-4G-HAT-Demo.7z
sudo apt-get install p7zip-full
7z x SIM7600X-4G-HAT-Demo.7z -r -o/home/pi
sudo chmod 777 -R /home/pi/SIM7600X-4G-HAT-Demo

3. Go to the bcm2835 directory, compile, and install it.

chmod +x configure && ./configure && sudo make && sudo make install

Note: If there is a problem with the compilation, please refer to the instructions in the FAQ.
4. Go to the corresponding instance directory, compile, and run the demo. The relevant instructions are as follows (take the PhoneCall demo as an example):

sudo make clean //Clear the original executable file
sudo make //recompile
sudo ./PhoneCall //Run the demo

Use a combination of the above commands:

sudo make clean && sudo make && sudo ./PhoneCall

PHONECALL Call Demo

Pnonecall.png

SMS Text Message Sending and Receiving Demo

SMS.png

GPS Positioning Demo

GPSPOSTION3.png

TCP Network Communication Demo

Tcp-network-3.png

FTP Download and Upload Demos

FTP-DOWNLOAD3.png