PI4B Sensor Kit

From Waveshare Wiki
Jump to: navigation, search
PI4B Sensor Kit
PI4B-Sensor-Kit-1.jpg
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

The ARPI600 is an adapter board compatible with Raspberry Pi, Arduino, and XBee. It's used to expand commonly used interface resources and is a crucial part of the Internet of Things (IoT). The Raspberry Pi 4 Model B sensor kit includes the ARPI600 along with 13 commonly used sensors and sample demos. These resources help you get started quickly.

Configure Raspberry Pi

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

Enable SPI interface

PS: If you are using a system with a Bullseye branch, you need to change "apt-get" to "apt", and the system of the Bullseye branch only supports Python3.
  • Open the terminal, and use the command to enter the configuration page.
sudo raspi-config
Choose Interfacing Options -> SPI -> Yes  to enable the SPI interface

RPI open spi.png
Reboot Raspberry Pi:

sudo reboot

Make sure that the SPI is not occupied by other devices, you can check in the middle of the /boot/config .txt.

  • Check /boot/config.txt, and you can see 'dtparam=spi=on' was written in.

Raspberry Pi Guides for 4.37 e-Paper.jpg

  • To make sure SPI is not occupied, it is recommended to close other drivers' coverage. You can use ls /dev/spi* to check whether SPI is occupied. If the terminal outputs /dev/spidev0.1 and /dev/spidev0.1, SPI is not occupied.

Raspberry Pi Guides for 4.37 e-Paper02.jpg

Enable UART interface

Open the Raspberry Pi terminal and enter the following command to enter the configuration interface

sudo raspi-config
Select Interfacing Options -> Serial, disable shell access, and enable the hardware serial port
L76X GPS Module rpi serial.png


Install Library

If you use bookworm system, only the lgpio library is available, bcm2835 and wiringPi libarary cannot be installed or used. Please note that the python library does not need to install, you can directly run the demo.

BCM2835

#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar zxvf bcm2835-1.71.tar.gz 
cd bcm2835-1.71/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more, you can refer to the official website at: http://www.airspayce.com/mikem/bcm2835/

WiringPi

#Open the Raspberry Pi terminal and run the following command
cd
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (earlier than that can be executed without), an upgrade may be required:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear, if it doesn't it means there was an installation error

# Bullseye branch system using the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
. /build
gpio -v
# Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error

lgpio

wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
sudo make install 
#for more details, you can refer to https://github.com/gpiozero/lg
  • python
sudo apt-get updata
sudo apt-get install ttf-wqy-zenhei
sudo apt-get install python-pip 
sudo pip install RPi.GPIO
sudo pip install spidev
sudo apt-get install python-smbus
sudo apt-get install python-serial
sudo pip install rpi_ws281x

Download Demo codes

sudo apt-get install p7zip
wget https://files.waveshare.com/upload/d/d6/ARPI600.tar.gz
7zr x ARPI600.tar.gz -r -o./ARPI600
sudo chmod 777 -R ARPI600
cd ARPI600/RaspberryPi/ARPI600_Code

Control Sensors by Serial Port

  • Configure Serial Port

1) Open a terminal and run the following commands:

sudo nano /boot/cmdline.txt

Change the line below:

wc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

to:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4
elevator=deadline rootwait

Save and exit (Ctrl+X, Y)
2) Run the following command:

sudo nano /etc/inittab

Modify the line below:

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

to:

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Save and exit (Ctrl+X, Y)
3) Reboot Raspberry Pi:

sudo reboot

After rebooting, the hardware serial of Raspberry Pi is enabled and the login shell function is disabled. If you want to access Raspberry Pi via serial port, you need to reset all the settings and reboot.

  • Print data via serial port

1) Users should configure the jumpers on board for enabling the serial port:

  • Connect CP_RX to P_TX
  • Connect CP_TX to P_RX

2)Run putty software on the host PC and configure:

  • Serial line: Select the COM port according to the Device Manager.
  • Speed: Set the baud rate to 9600.
  • Connection type: Choose Serial.

3) Copy the program/Xbee/send the folder to Raspberry Pi and go into send folder, run the following commands:

sudo make
sudo ./serialTest

The serial port will print data as below:
ARPI600 1.png

Set up a wireless network with 2 Xbee modules

Preparation

1) Two Xbee modules
2) Two ARPI600 modules
3) Two Raspberry Pi

  • We divide them to A group and B group (XBee-A,ARPI600-A,XBee-B,ARPI600-B)

Install X-CRU tool

1) Install software/X-CTU V5.2.8.6.exe in host PC:
ARPI600 2.png
2) Configure XBee mdoule

  • Baud: 9600
  • Data Bite: 8
  • Parity: NONE
  • Stop: 1

Test XBee in host PC

1) Connect XBee-A to ARPI600-A. Connect XBee-B to ARPI600-B.
ARPI600 3.png
2) Configure jumpers to enable the XBee:

  • Connect XB_RX to CP_RX
  • Connect CP_TX to XB_TX

3) Power on the Raspberry Pi
4) Click the Test/Query button to check if the XBee module is connected successfully:
ARPI600 4.png
5) The module is connected normally if you get the following result:
ARPI600 5.png

Configure XBee-A

1) Click the Modem Configuration Option, and click the Read button to read the parameter of XBee:
ARPI600 6.png
2) Select ZIBGEE ROUTER/END DEVICE AT from the Function Set box:
ARPI600 7.png
3) Configure the Networking parameter as below:

  • ID: 234
  • DH: 0
  • DL: 0

4) Click the Write button to save the settings of XBee-A.

Configure XBee-B

1) Click the Modem Configuration Option, and click the Read button to read the parameter of XBee.
2) Select ZIGBEE COORDINATOR AT from the Function Set box:
ARPI600 7.png
3) Configure the Networking parameter as below:

  • ID: 234
  • DH: 0
  • DL: ffff

4) Click the Write button to save the settings of XBee-B.
5) After setting, run two X-CTU windows in the host PC and select the corresponding COM port in the PC Setting option, then you can test the point-to-point communication between two XBee modules.
6) In the terminal of X-CTU (XBee-A), input the data, and the data will be transmitted to XBee-B and printed in the terminal of X-CTU software (Bee-B), Blue is the data transmitted and Red is the data Received.
ARPI600 8.png

Wireless Communicating Between XBee Modules

Set up and configure XBee modules like the above guides first. Then we can configure Raspberry Pi for wireless communication.
1) Configure jumers of ARPI600:

  • Connect XB_RX to P_TX
  • Connect XB_TX to P_RX

ARPI600 9.png
2) Testing:
Run the following commands:

cd /Xbee/getdata
sudo make
sudo ./serialTest

Data will be printed as below:
ARPI600 10.png
Go into the send folder and run the following commands:

sudo make
sudo ./serialTest

The receiver will print the data received:
ARPI600 11.png

RTC

1) Connect the RTC JMPjumpers
2) Run the LXTerminal and input:

i2cdetect -y 1

3) The i2c address of PCF8563 should be printed.
ARPI600 12.png
4) Run the following commands in the LXTerminal terminal:

modprobei2c-dev
echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r#(Read the RTC time)

The time of PCF8563 is printed in LXTerminal, it may be different with system time
5) Run the following commands in LXTerminal:

hwclock -w #(Write the system time to PCF8563)
hwclock -r #(Read the PCF8563 time)
hwclock -s #(Synchronize the system time and RTC)

AD(Onboard TLC1543)

Configure A0 Pin

1) Install libraries (ignore if you have done)
2) Set REF voltage:
ARPI600 13.png

  • Connect REF to 5V: the REF voltage of the AD chip is 5V (Default)
  • Connect REF to 3V3: the REF voltage of the AD chip is 3.3V.

You can only choose one setting when configuring the REF voltage.
3) Copy the program/AD_TLC1543 folder to Raspberry Pi and go into it. Run the following commands

sudo make
sudo ./tlc1543

4) The data sent from AD0 pin will be printed.
5) Connect the T_A0 pin to A0, then you can connect the A0 pin to any sensors for Analog signal reading:
ARPI600 14.png

Configure AD Pins

1) If you want to read the data of other AD pins, you can modify tlc1543.c file:
sudo nano tlc1543.c Find the line:
re=ADCSelChannel(0); Change 0 to other numbers of pin for testing other AD pins (for example re=ADCSelChannel(1);
Save and exit (Ctrl+X, Y).
2) Run the following commands to test:

sudo make
sudo ./tlc1543

Interface

Pinout

1) The Arduino-compatible interface onboard is related to the GPIO of Raspberry:

Arduino Compatible Interface Raspberry Pi IO
D0 P_RX
D1 P_TX
D2 P0
D3 P1
D4 P2
D5 P3
D6 P4
D7 P5
D8 P6
D9 P7
D10 CE0
D11 MOSI
D12 MISO
D13 SCK

2) You can configure the SPI interface by changing the setting of the 0ohm resistor as below:
ARPI600 15.png
The resistors are solders by default:

  • SCK is connected to D13.
  • MISO is connected to D12.
  • MOSI is connected to D11.

If you change the resistors as below:

  • D13 to P26.
  • D12 to IO_SD.
  • D11 to IO_SC.

The D11, D12, and D13 pins are connected to the GPIO of Raspberry Pi directly.
Note: Users can change these jumpers accordingly, but this operation requires soldering pads. Do not modify it without the guidance of our support team, otherwise, the warranty will be deemed waived.
3) The A0~A5 pins are configurable, you can configure them as GPIO pins or AD pins.
ARPI600 16.png
a) If A0~A5 pins are connected to 1, they are used as GPIOs:

Arduino interface Raspberry Pi IO
A0 CE1
A1 P5
A2 P6
A3 P7
A4 CE0
A5 MOSI

b)If the A0~A5 is connected to 3, they work as AD pins.
4) You can connect A4 to P_SCL and A5 to P_SD for connecting I2C devices. They are disconnected by default.
Note: Users can change these jumpers accordingly, but this operation requires soldering pads. Do not modify it without the guidance of our support team, otherwise, the warranty will be deemed waived.
ARPI600 17.png
5) The pins for sensors are extended in the ARPI600 board:
ARPI600 18.png

  • The pins (A6-A10) in A area are connected to TLC1543 chip for analog signals.
  • The pins in D are connected to the P0-P4 IO of Raspberry Pi for digital signal.

You can connect sensors to these pins.

ARPI600 Connect Sensors (Not Included)

The following examples require Raspberry Pi, you need to connect the ARPI600 board and related sensors to the Raspberry Pi.

  • Color Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the color sensor to ARPI600:

Color Sensor ARPI600
LED 3.3V
OUT P0
S3 P4
S2 P3
S1 P2
S0 P1
GND GND
VCC 3.3V

3) Copy the folder of Color_Sensor to Raspberry Pi and run it:

cd Color_Sensor
sudo ./Color_Sensor

4) The sensor will first take the white balance process for 2s and then output the color data.
5) You can press Ctrl+C to stop the codes.

  • Flame Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Flame Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the folder of Flame_Sensor to Raspberry Pi and run the following commands:

cd Flame_Sensor
sudo ./General_Sensor

4) The LED of the sensor lights on when it is close to the fire.
5) The output data are changing while the distance between the sensor and fire is changing.
6) You can press Ctrl+C to stop cpdes.
Note: This sensor isn't fireproof, you cannot put it in fire directly.

  • Metal Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Metal Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the folder of Metal_Sensor to Raspberry Pi, and run the following commands:

cd Metal_Sensor
sudo ./General_Sensor

4) The LED of the sensor lights on when the sensor touches live metal.
5) The data changes according to the touching between the sensor and live metal.
6) You can press Ctrl+C to stop the code.

  • Hall Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Hall Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the folder of Hall Sensor to Raspberry Pi and run the following commands:

cd Hall_Sensor
sudo ./General_Sensor

4) Close the sensor to the magnet, and the indicator turns on.
5) The data output changes according to the touching between the sensor and magnet.
6) You can press Ctrl+C to stop the code.

  • Infrared Reflective Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Infrared Reflective Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the Infrared_Reflective_Sensor folder to Raspberry Pi and run the following commands:

cd Infrared_Reflective_Sensor
sudo ./General_Sensor

4) The indicators turn on when the sensor detects obstacles.
5) The data output is changed according to the distance of the obstacle.
6) You can press Ctrl+C to stop the code.

  • Laser Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Laser Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the Laser_Sensor folder to Raspberry Pi and run the following commands:

cd Laser_Sensor
sudo ./General_Sensor

4) Put an object above the sensors, and the indicator of the sensor turns on.
5) You can press Ctrl+C to stop the code.

  • Moisture Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Moisture Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the Moisture_Sensor folder to Raspberry Pi and run the following commands:

cd Moisture_Sensor
sudo ./General_Sensor

4) Inset the sensor to soil watering, the data will change.
5) You can press Ctrl+C to stop codes.

  • Rotation Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Moisture Sensor ARPI600
SIA P0
SIB P1
SW P2
GND GND
VCC 3.3V

3) Copy the Rotation_Sensor folders to Raspberry Pi and run the following commands:

cd Rotation_Sensor
sudo ./Rotation_Sensor

4) Turn the sensor clockwise or anticlockwise, press the potentiometer, and the data output changes.

Turn right!
Turn left!
Turn down!

5) Connect the SIA, SIB, and SW pins to a logic analyzer (CH0, CH1, CH2).
Turn the potentiometer clockwise:
ARPI600 19.png
Turn the potentiometer anticlockwise:
ARPI600 20.png
Press the button in the encoder:
ARPI600 21.png
6) You can press Ctrl+C to stop codes.

  • Sound Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

Sound Sensor ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the Sound_Sensor folder to Raspberry Pi and run the following commands:

cd Sound_Sensor
sudo ./General_Sensor

4) The indicator of the sensor turns on when the sensor is close to sounds.
5) The data changes while the distance changes.
6) You can press Ctrl+C to stop the code.

  • Temperature-Humidity Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

PIN ARPI600
DOUT P0
GND GND
VCC 3.3V

3) Copy the Temperature-Humidity_Sensor folder to Raspberry Pi and run the following commands:

cd Temperature-Humidity_Sensor
sudo ./DHT11

4)Temperature and humidity data are printed.

Humidity=33 
Temperature=28

5) You can press Ctrl+C to stop the code.

  • MQ-5 Gas Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

PIN ARPI600
DOUT NC
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the MQ-5_Gas_Sensor folder to Raspberry Pi and run the following commands:

cd MQ-5_Gas_Sensor
sudo ./General_Sensor

4) The sensor requires about 1 minute to warm up.
5) Put the sensor into testing equipment with gases, and the indicator of the sensor turns on.
6) You can press Ctrl+C to stop the code.

  • Tilt Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

PIN ARPI600
DOUT T_A6
GND GND
VCC 3.3V

3) Copy the Tilt_Sensor folder to Raspberry Pi and run the following commands:

cd Tilt_Sensor
sudo ./General_Sensor

4) Shake the sensor to check the data and indicator.
5) You can press Ctrl+C to stop the code.

  • UV Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

PIN ARPI600
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the UV_Sensor folder to Raspberry Pi and run the following commands.

cd UV_Sensor
sudo ./General_Sensor

4) The data changes when detecting UV waves.
5) You can press Ctrl+C to stop the code.

  • Liquid Level Sensor

1) Connect the ARPI600 to Raspberry Pi.
2) Connect the sensor to ARPI600:

PIN ARPI600
AOUT T_A6
GND GND
VCC 3.3V

3) Copy the Liquid_Level_Sensor folder to Raspberry Pi and run the following commands:

cd Liquid_Level_Sensor
sudo ./General_Sensor

4) Put the sensor in water, and the data output changes.
5) You can press Ctrl+C to stop the code.

Resource

Document

Software

Demo

General Tutorial Series

FAQ

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)