Template: TOF Laser Ranger Sensor B Guides

From Waveshare Wiki
Revision as of 07:51, 14 December 2021 by Waveshare-eng11 (talk | contribs) (Created page with "==Work with Raspberry Pi== {{RPI open uart}} {{RPI open i2c}} ===Install libraries=== Open a terminal and run the following commands to install libraries <pre> sudo apt-get in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Work with Raspberry Pi

Enable UART

Execute the following command to enter the Raspberry Pi configuration:

sudo raspi-config

Choose Interfacing Options -> Serial -> No -> Yes:
You need to disable the login shell and enable the srial port hardware:

L76X GPS Module rpi serial.png


Reboot Raspberry Pi:

sudo reboot

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

Reboot to take effect.

Enable I2C Interface

Open a terminal and run the following commands:

sudo raspi-config 
Choose Interfacing Options -> I2C -> Yes.

Reboot Raspberry Pi:

sudo reboot

RPI open i2c.png

Install libraries

Open a terminal and run the following commands to install libraries

sudo apt-get install update
sudo apt-get install python3-serial
sudo pip install smbus

Configure the Module

  • Connect the Sensor board to Windows PC and set the UART baud rate to 921600
  • Connect the sensor to Raspberry Pi
  • Download the example and unzip
cd 
wget https://www.waveshare.com/w/upload/0/01/TOF-Laser-Range-Sensor-B-Demo.zip
unzip TOF-Laser-Range-Sensor-B-Demo.zip
  • Run the Python codes.
cd ~/ToF Light sensor B/TOF-Laser-Range-Sensor-B-Demo/Raspberry/python
sudo python3 TOF_Laser_Range_Sensor_Demo.py
TOF Laser Range Sensor raspberry1.jpg

Working with Jetson Nano

Install libraries

Open a terminal and run the following commands to install libraries

sudo apt-get install update
sudo apt-get install python3-serial
sudo pip install smbus

Configure the Module

  • Connect the Sensor board to Windows PC and set the UART baud rate to 115200
  • Connect the Sensor to the UART pins of the Jetson Nano
  • Download the examples and run it
cd 
wget https://www.waveshare.com/w/upload/0/01/TOF-Laser-Range-Sensor-B-Demo.zip
unzip TOF-Laser-Range-Sensor-B-Demo.zip
cd TOF-Laser-Range-Sensor-B-Demo/Jetson nano/python
sudo python3 TOF_Laser_Range_Sensor_Demo.py
TOF Laser Range Sensor jetson Demo.png

Working with Arduino

  • Install Arduino IDE in your PC
  • Download the examples and unzip
  • Go into the directory of Arduino examples (..\TOF-Laser-Range-Sensor-B-Demo\Arduino\TOF_ranging_test)
  • Open the TOF_ranging_test.ino project
  • Connect the Sensor to PC and configure the UART baud rate to 115200
  • Connect the Sensor to Arduino board
TOF-Laser-Range-Sensor-Arduino-connected.jpg
  • Build and upload the examples to Arduino board
TOF-Arduino-Test.jpg