WAVESHARE Sense HAT (B) Onboard Multi Powerful Sensors User Guide

May 15, 2024
WAVESHARE

WAVESHARE-logo

WAVESHARE Sense HAT (B) Onboard Multi Powerful Sensors

WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-product-
image

Specifications

  • Working Voltage: 3.3V
  • Interface: I2C
  • Dimension: 65mm x 56.5mm
  • Accelerometer: Built-in
  • Gyroscope: Built-in
  • Magnetometer: Built-in
  • Barometer: Built-in
  • Temperature & Humidity Sensor: Built-in
  • Color Sensor ADC: Available

Product Usage Instructions

Hardware Connection
Connect the Sense HAT (B) to your Raspberry Pi using the appropriate pins as shown in the hardware connection diagram.

Open I2C Interface
To enable the I2C interface, access the Raspberry Pi terminal and execute the following commands:

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

Install Library Functions
Install necessary libraries for the Sense HAT (B) using the following commands:

  • BCM2835 Library: wget [ http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz](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

  • WiringPi Library: sudo apt-get install wiringpi

  • Python Libraries: sudo apt-get install python-pip sudo pip install RPi.GPIO spidev sudo apt-get install python-smbus

Download Demo
Download the demo files for Sense HAT (B) using the following commands:

sudo apt-get install p7zip-full wget [ https://www.waveshare.com/w/upload/6/6c/Sense- HAT-B-Demo.7z](https://www.waveshare.com/w/upload/6/6c/Sense-HAT-B-Demo.7z) 7z x Sense-HAT-B-Demo.7z -O./Sense-HAT-B-Demo cd Sense-HAT-B-Demo

I2C Device Addresses

  • ADS1015: Device address – 0x48
  • ICM-20948: Device address – 0x68
  • LPS22HB: Device address – 0x5C
  • SHTC3: Device address – 0x70

Frequently Asked Questions (FAQ)

  • Q: Can I use Sense HAT (B) with other Raspberry Pi models?
    A: Yes, the Sense HAT (B) is compatible with various Raspberry Pi models but may require different hardware connections.

  • Q: What programming languages can I use to interact with Sense HAT (B)?
    A: You can use Python to interface with the sensors and utilize the capabilities of Sense HAT (B).

Introduction

It is a sensor expansion board specially designed for Raspberry Pi. It has on- board gyroscope, accelerometer, magnetometer, barometer, temperature and humidity sensor, etc. I2C interface communication supports more external sensors. If you want to DIY the Raspberry Pi into a robot that can detect motion posture and orientation, or if you want the Raspberry Pi to collect sensor data such as temperature, humidity and atmospheric pressure in the surrounding environment.

Feature

  • Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards.
  • Onboard ICM20948 (3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer), detects movement, orientation, and magnetic.
  • Onboard SHTC3 digital temperature and humidity sensor, allows monitoring of the environment.
  • Onboard LPS22HB barometric pressure sensor, allows monitoring of the environment.
  • Onboard TCS34725 color sensor, identifies the color of a nearby object.
  • Onboard ADS1015 ADC, 4-ch 12-bit precision, AD expansion to support more external sensors.
  • Brings I2C control pins, for connecting other host boards like STM32.
  • Comes with development resources and manual (examples for Raspberry Pi/STM32).

Specification

Sense HAT (B) Specification

WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig-
\(2\)

Product PK

WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig-
\(3\) WAVESHARE-Sense-HAT-B-Onboard-
Multi-Powerful-Sensors-fig- \(4\)

User Guides for Raspberry Pi

  • Hardware connection
    The pins used to connect to the Raspberry Pi are shown on the right:

  • Hardware connection diagram:
    Connect to Raspberry Pi Zero (pin header is not required)WAVESHARE-Sense-
HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(6\)

  • Connect to Raspberry Pi 4 (requires a pin header )WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(7\)

Open I2C Interface
Open the Raspberry Pi terminal and enter the following command to enter the configuration interface.WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-
Sensors-fig- \(8\) WAVESHARE-Sense-HAT-B
-Onboard-Multi-Powerful-Sensors-fig- \(9\)

Install Library Functions

BCM2835

wiring Pi

  • Open Raspberry Pi terminal and execute

  • sudo apt-get install wiringpi

  • For Raspberry Pi systems after May 2019 (earlier than before, it is not necessary t

  • o execute), 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 does not appear, the installation

  • is wrong.

  • Bullseye Branch systems use the following commands:

  • git clone https://github.com/WiringPi/WiringPi

  • cd WiringPi

  • ./build

  • gpio -v

  • Run gpio -v and version 2.70 will appear. If it does not appear, the installation

  • is wrong.

Python

  • sudo apt-get update
  • python2

  • sudo apt-get install python-pip
  • sudo pip install RPi.GPIO
  • sudo pip install spidev
  • sudo apt-get install python-smbus
  • python3

  • sudo apt-get install python-pip3
  • sudo pip3 install RPi.GPIO
  • sudo pip3 install spidev
  • sudo apt-get install python3-smbus

Download Demo

I2C device address

  • ADS1015: AD conversion demo (STM32, BCM2835, WringPi and Python four demos) Device ad
    dress: 0x48

  • ICM-20948: 9-axis sensor demo (STM32, BCM2835, WringPi and Python four demos) Device
    address: 0x68

  • LPS22HB: Air pressure sensor demo (STM32, BCM2835, WringPi, and Python four demos) De
    vice address: 0x5C

  • SHTC3: Temperature and humidity sensor demo (STM32, BCM2835, WringPi, and Python four
    demos) Device address: 0x70

  • TCS34725: Color recognition sensor demo (STM32, BCM2835, WringPi and Python four demo
    s) Device address: 0x29

Note: The I2C addresses of all the sensors of this module are different, and the user can use all the sensors on the board at the same time.

ICM20948 Examples—9-axis Sensor Demo

bcm2835

  • Open the terminal of Linux, compile codes, and run the example by command:
    • cd ICM-20948/Raspberry\ Pi/bcm2835/
    • sudo make clean
    • sudo make
    • sudo ./ICM20948_DEMOWAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(10\)
  • Press Ctrl+C to end the demo.

WiringPi

  • Open the terminal of Linux, run the example by command:
    • cd ICM-20948/Raspberry\ Pi/wiringPi/
    • sudo make clean
    • sudo make
    • sudo ./ICM20948_DEMO
  • Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(11\)
  • Press Ctrl+C to end the demo.

Python
Open the terminal of Linux, compile codes, and run the example by command:

  • cd ICM-20948/Raspberry\ Pi/python/
  • sudo python3 ICM20948.py

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(12\) Press Ctrl+C to end the demo.

VisionFive2 Demo

  • Enter the Linux terminal and run the following commands in the terminal:
  • cd ICM-20948/VisionFive2
  • python3 ICM20948.py
  • Press Ctrl+C to end the demo.

STM32 Example
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.

The connection is as follows:

Sense HAT (B) STM32
VCC (Note: jumper cap should jump to the corresponding position) +5V/+3.3V
GND GND
SDA PB9
SCL PB8

Compile and download the demo:WAVESHARE-Sense-HAT-B-Onboard-Multi-
Powerful-Sensors-fig- \(13\) Open the serial port assistant and set the baud rate to 115200.

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(14\)

Parameter Calibration And Calculation

Calculate Acceleration
The unit of acceleration measured by the demo is LSB (least significant bit), and the unit is often converted to gravitational acceleration (g) in actual use. The sample demo of the module sets AFS_SEL=0 by default, and the corresponding range is 16384 LSB/g (±2g), so the actual acceleration measured is:
a=Acceleration/16384 ,Unit: g
Please refer to ICM-20948-v1.3.pdf P12.

Calculate Gyroscope Angular Velocity
The unit of angular velocity measured by the program is LSB (least significant bit). In practice, the unit is often converted to angular velocity (°/sec). The sample program of the module sets FS_SEL=2 by default, and the corresponding range is 32.8 LSB/(°/s) (±1000°/s), so the actual angular velocity measured is: w=Gyroscope/32.8 ,Unit:%
Please refer to ICM-20948-v1.3.pdf P11.

LPS22HBTR Example—Air Pressure Sensor Demo

Note: The temperature detection of the air pressure sensor is only used for compensation. For accurate temperature detection, please observe the value of the SHTC3 temperature and humidity sensor.

bcm2835 Demo
Open the terminal of Linux, compile codes, and run the example by command:

  • cd LPS22HBTR/Raspberry\ Pi/bcm2835/
  • sudo make clean
  • sudo make
  • sudo ./LPS22HB

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig-
\(15\) Press Ctrl+C to end the demo.

Wiring Pi demo
Open the terminal of Linux, compile codes, and run the example by command:

  • cd LPS22HBTR/Raspberry\ Pi/wiringPi/
  • sudo make clean
  • sudo make
  • sudo ./LPS22HB

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(16\)

Press Ctrl+C to end the demo.

python
Open the terminal of Linux, compile codes, and run the example by command:

  • cd LPS22HBTR/Raspberry\ Pi/python/
  • sudo python3 LPS22HB.py

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(17\)

Press Ctrl+C to end the demo.

VisionFive2 Demo

  • Enter the Linux terminal and run the following commands in the terminal:
    • cd LPS22HB/VisionFive2
    • python3 LPS22HB.py
  • Press Ctrl+C to end the terminal.

STM32
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.

The connection is as follows:

Sense HAT (B) STM32
VCC (Note: jumper cap should jump to the corresponding position) +5V/+3.3V
GND GND
SDA PB9
SCL PB8

Compile and download the program:WAVESHARE-Sense-HAT-B-Onboard-Multi-
Powerful-Sensors-fig- \(18\) Open the serial port assistant and set the baud rate to 115200.

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(19\)

SHTC3 Example—Temperature and Humidity Sensor Demo

Note: The heating of the Raspberry Pi will affect the actual measured temperature. The board has an I2C interface. If you need an accurate ambient temperature, you can separate the Raspberry Pi from the module for a distance and connect it with a cable to test it.

BCM2835 demo
Open the terminal of Linux, compile codes, and run the example by command:

  • cd SHTC3/Raspberry\ Pi/bcm2835/
  • sudo make clean
  • sudo make
  • sudo ./SHTC3

Expected result: WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(20\)

Press Ctrl+C to end the demo.

wiring Pi

Open the terminal of Linux, compile codes, and run the example by command:

  • cd SHTC3/Raspberry\ Pi/wiringPi/
  • sudo make clean
  • sudo make
  • sudo ./SHTC3

Expected result:

Press Ctrl+C to end the demo.

python
Open the terminal of Linux, compile codes, and run the example by command:

  • cd SHTC3/Raspberry\ Pi/python/
  • sudo python3 SHTC3.py

Expected result: WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(22\)

Press Ctrl+C to end the demo.

VisionFive Demo
Enter the Linux terminal and execute the following command in the terminal:

  • cd SHTC3/VisionFive2
  • python3 SHTC3.py
  • Press Ctrl+C to end the demo.

STM32
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.

  • The connection is as follows:

  • Compile and download the program:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(23\)

  • Expected result:
    The sensor is ok with no errors, LED2 is on:WAVESHARE-Sense-HAT-B-Onboard-
Multi-Powerful-Sensors-fig- \(24\)

  • When the air humidity is lower than 80%, LED3 does not light up. LED3 lights up when the air humidity is greater than or equal to 80%.WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(25\)

TCS34725 Example—Color Recognition Sensor Demo

bcm2835
Open the terminal of Linux, compile codes, and run the example by command:

  • cd TCS34725/Raspberry\ Pi/bcm2835/
  • sudo make clean
  • sudo make
  • sudo ./main

Expected result: WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(26\)

Press Ctrl+C to end the demo.

wiring Pi
Open the terminal of Linux, compile codes, and run the example by command:

  • cd TCS34725/Raspberry\ Pi/wiringPi/
  • sudo make clean
  • sudo make
  • sudo ./main

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(27\)

Press Ctrl+C to end the demo.

Python
Open the terminal of Linux, compile codes, and run the example by command:

  • cd TCS34725/RaspberryPi/python3/
  • sudo python3 main.py

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(28\)

Press Ctrl+C to end the demo.

VisionFive2 Demo
Enter the Linux terminal, and execute the following commands in the terminal:

  • Install pygame library:
    apt-get install pygame

  • Run the demo:

    • cd TCS34725/VisionFive2
    • python3 main.py
    • Press Ctrl+C to end the demo.

STM32
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.

The connection is as follows:

Sense HAT (B) STM32
VCC (Note: jumper cap should jump to the corresponding position) +5V/+3.3V
GND GND
SDA PB9
SCL PB8

Compile and download the demo:WAVESHARE-Sense-HAT-B-Onboard-Multi-
Powerful-Sensors-fig- \(29\) Open the SSCOM and set the baud rate to 115200.

Expected outcome:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(30\)

ADS1015 Example—AD Conversion

bcm2835
Open the terminal of Linux, compile codes, and run the example by command:

  • cd ADS1015/Raspberry\ Pi/bcm2835/
  • sudo make clean
  • sudo make
  • sudo ./AD

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(32\)

Press Ctrl+C to end the demo.

Wiring Pi
Open the terminal of Linux, compile codes, and run the example by command:

  • cd ADS1015/Raspberry\ Pi/wiringPi/
  • sudo make clean
  • sudo make
  • sudo ./AD

Expected result:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(33\)

Press Ctrl+C to end the demo.

Python
Open the terminal of Linux, compile codes, and run the example by command:

  • cd ADS1015/Raspberry\ Pi/python/
  • sudo python3 AD.py

Expected result: WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-
fig- \(34\)

Press Ctrl+C to end the demo.

VisionFive2 Demo
Enter the Linux terminal and execute the following commands in the terminal:

  • cd ADS1015/VisionFive2
  • python3 AD.py
  • Press Ctrl+C to end the demo.

STM32
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.

  • The connection is as follows:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(35\)
  • Compile and download the program:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(36\)
  • Open the serial port assistant and set the baud rate to 115200.WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(37\)

Resources

  • Document
    Schematic

  • Demo code
    Code

  • Datasheet

    • ADS1015
    • ICM-20948
    • LPS22HBTR
    • LSF0204
    • SHTC3
    • TCS34725

FAQ

  • Question:
    Why the Raspberry Pi demo failed to initialize? (The following takes TC34725 color recognition sensor as an example)
    Answer:WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig-
\(38\)

    • For the BCM2835 and wiringPi demo such prompts appear,WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(39\)
    • If Python demo occurs the above problem, this is a device data I2C data transfer error. Most of them are hardware connection errors, please check whether the hardware connection is correct, check whether there is any problem with the hardware connection, run i2cdetect -y 1 If the IIC address is displayed, it means that the hardware connection is no problem. If the hardware connection is correct, it may be caused by incorrect use of Raspberry Pi control (see below for details), just restart the Raspberry Pi.WAVESHARE-Sense-HAT-B-Onboard-Multi-Powerful-Sensors-fig- \(40\)
  • Question : What will happen if using the Raspberry Pi controls incorrectly?
    Answer : If running the wiringPi demo is normal, then running python or BCM2835 may cause the screen to fail to refresh normally, because the bcm2835 library is a library function of the Raspberry Pi cpu chip, and the bottom layer is to directly operate the registers, while the bottom layer of the wiringPi library and python are through reading and writing device file of the linux system to operate the device, which may cause the GPIO port to be abnormal. In this case, restarting the Raspberry Pi can solve the problem perfectly.

  • Question: What should I do if the serial port output of the STM32 demo has no data or the data output is garbled?
    Answer: Confirm whether the baud rate is set to 115200. For the STM32 routine, please confirm that the computer is correctly connected to the development board USART2 (PA2, PA3), PA2 is TXD, and the correct COM port is selected. Control Panel -> Hardware -> Device Manager.WAVESHARE-Sense-HAT-B
-Onboard-Multi-Powerful-Sensors-fig- \(41\)

  • Question: The serial port output data of the STM32 demo is all 0 or the initialization fails? As shown.
    Answer: Confirm that there is no problem with the device connection, if there is no problem, please press the reset button.WAVESHARE-Sense-HAT-B
-Onboard-Multi-Powerful-Sensors-fig- \(42\)

Support
If you require technical support, please go to the page and open a ticket.

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

WAVESHARE User Manuals

Related Manuals