Linux C_SDK_Normal Onboard serial port and 3-in-1 serial port usage tutorial
Last updated
Last updated
Applicable Model
Routine download
https://github.com/WITMOTION/WitStandardProtocol_JY901
Operation steps of onboard serial port
View serial port mapping
ls -l /dev/ttyserial*
If the following two situations occur: Step 2 configuration is required
case one:
case two:
Map ttyAMA0 to serial0
method one:
① Click on the raspberry logo in the upper left corner -> Preferences ->Raspberry Pi Configuration
② click “Interfaces”
③ After checking the Serial Port option, click “OK”
as follows:
④ Click “yes” to restart the Raspberry Pi
Method Two:
① Press and hold ctrl+Alt+T to open the terminal
② Command line input:
sudo raspi-config
④ Select <No>, press Enter
⑤ Select <Yes> and press Enter
⑥ After the following interface appears, select <Ok>, and then press the Esc key to exit the page
⑦ Reboot Raspberry Pi
reboot
Check whether the serial port is mapped successfully
ls -l /dev/serial*
As can be seen from the above figure, serial0 is mapped to ttyAMA0 after configuration, indicating that the configuration is successful.
hardware connection
Wiring problem (this example uses Raspberry Pi 3b+ as an example)
Find the pinout diagram of the Raspberry Pi model you are using
② Wiring
Raspberry Pi 3b+ JY901S (Virt smart sensor supporting Normal protocol)
5V-DC Power <--------------------------> VCC
GPIO14(TXD0) <--------------------------> RXD
GPIO15(RXD0) <--------------------------> TXD
Ground <--------------------------> GND
Enter the specified folder to compile and run the program
cd ~/linux_sdk cd ./normal gcc ./*.c ./a.out /dev/ttyAMA0
Check the running results
The prompt message and the number of sensor parameters returned
Shake the sensor, the parameters of the sensor will be sent back and displayed in real time, indicating that the debugging is successful!
Operation steps of 3-in-1 serial port
Wiring
Prepare a Wit-miotion sensor and 3-in-1 serial port that support the Normal protocol
JY901S 3-in-1
VCC <----------------------------------------> VCC
TX <----------------------------------------> RX
RX <----------------------------------------> TX
GND <----------------------------------------> GND
View the serial port file under the device file
ls -l /dev/ttyUSB*
Plug the 3-in-1 into the serial port of the Raspberry Pi, and enter the above command again: ls -l /dev/ttyUSB*
The extra serial port file is the serial port file we are looking for (ttyUSB0)
Enter the specified folder to compile and run the program
cd ~/linux_sdk cd ./normal gcc ./*.c ./a.out /dev/ttyUSB0
Check the running results
Prompt information and returned sensor parameter data
Shake the sensor, the parameters of the sensor will be sent back and displayed in real time, indicating that the debugging is successful!
More
For other operations, please refer to the sensor manual
The following interface appears, select Interface Options and press Enter
③Select I6 Serial Port and press Enter