Difference between revisions of "Sense HAT (B)"

From Waveshare Wiki
Jump to: navigation, search
 
(77 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Infobox item
+
<div class="wiki-pages jet-green-color">
|img=[[File:Sense-HAT-B-1.jpg|300px|alt=Sebse HAT B|link=https://www.waveshare.com/sense-hat-b.htm |Sebse HAT B]]
+
{{Infobox item|colorscheme=green
 +
|img=[[File:Sense-HAT-B-1.jpg|300px|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/sense-hat-b.htm}} |Sebse HAT B]]
 
|caption=Sense HAT (B) for Raspberry Pi, Onboard Multi Powerful Sensors, Supports External Sensors
 
|caption=Sense HAT (B) for Raspberry Pi, Onboard Multi Powerful Sensors, Supports External Sensors
 
|category=[[:Category:Expansions|Expansions]], [[:Category:Raspberry Pi|Raspberry Pi]]
 
|category=[[:Category:Expansions|Expansions]], [[:Category:Raspberry Pi|Raspberry Pi]]
 
|brand=Waveshare
 
|brand=Waveshare
|{{#urlget:amazon|default}}=display
+
|{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display
 
|website_cn=[http://www.waveshare.net/shop/Sense-HAT-B.htm 官网]
 
|website_cn=[http://www.waveshare.net/shop/Sense-HAT-B.htm 官网]
 
|website_en=[https://www.waveshare.com/sense-hat-b.htm Website]
 
|website_en=[https://www.waveshare.com/sense-hat-b.htm Website]
Line 12: Line 13:
 
{{Product List|Mini PC/Raspberry Pi/Expansions}}
 
{{Product List|Mini PC/Raspberry Pi/Expansions}}
 
}}
 
}}
== Introduction ==
+
=Introduction=
Sense HAT (B) for Raspberry Pi, Onboard Multi Powerful Sensors, Supports External Sensors. Can be plugged to Raspberry Pi directly.
+
It is a sensor expansion board specially designed for Raspberry Pi. It has an onboard 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.
 
+
{{Amazon|{{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}=display
{{Amazon|{{#urlget:amazon|default}}=display
 
 
|More = [https://www.waveshare.com/sense-hat-b.htm More]}}
 
|More = [https://www.waveshare.com/sense-hat-b.htm More]}}
 
===Feature===
 
===Feature===
*Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards
+
*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 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 the environment
+
*Onboard SHTC3 digital temperature and humidity sensor, allows monitoring of the environment.
*Onboard LPS22HB barometric pressure sensor, allows monitoring the environment
+
*Onboard LPS22HB barometric pressure sensor, allows monitoring of the environment.
*Onboard TCS34725 color sensor, identifies the color of nearby object
+
*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
+
*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
+
*Brings I2C control pins, for connecting other host boards like STM32.
*Comes with development resources and manual (examples for Raspberry Pi/STM32)
+
*Comes with online development resources and manual (examples for Raspberry Pi/STM32).
 +
 
 
===Specification===
 
===Specification===
 
{|border="1px" width="500px"
 
{|border="1px" width="500px"
|+style="color:blue"|'''Specification of Sense HAT (B)'''
+
|+style="color:blue"|'''Sense HAT (B) Specification'''
 
|-align="center"
 
|-align="center"
 
|style="background:#646b73; color:white"|'''Working voltage'''
 
|style="background:#646b73; color:white"|'''Working voltage'''
Line 77: Line 78:
 
|}
 
|}
  
==User Guides==
+
===Product PK===
===Download examples===
+
[[File:Sensor00.png]]
Download demo code from [[#Demo codes]]. Unzip it and get the codes as below:
 
:[[File:sense-hat-b-user-manual-1.png|700px]]
 
*ADS1015: ADC examples (STM32, BCM2835(Pi), WiringPi(Pi) and Python(Pi) four examples)&nbsp;Device address:0x48
 
*ICM-20948: 9 axis sensor examples (STM32, BCM2835(Pi), WiringPi(Pi) and Python(Pi) four examples)&nbsp;Device address:0x68
 
*LPS22HB: Barometric pressure sensor examples (STM32, BCM2835(Pi), WiringPi(Pi) and Python(Pi) four examples)&nbsp;Device address:0x5C
 
*SHTC3: Temprature & Humidity sensor examples (STM32, BCM2835(Pi, WiringPi(Pi) and Python(Pi) four examples)&nbsp;Device address:0x70
 
*TC34725: Color sensor example (STM32, BCM2835(Pi), WiringPi(Pi) and Python(Pi) four examples&nbsp;&nbsp;&nbsp;Device address:0x29
 
  
===Raspberry Pi examples===
+
{{Sense hat RPI}}
You should copy raspberrypi example to Raspberry Pi firstly. There are more than one examples, you can rename the folder and put them to one raspberrypi folder for easy using.
+
{{Sense HAT ICM20948}}
 +
==STM32==
 +
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.<br />
 +
The connection is as follows:<br />
 +
[[File:senhat.png]]<br />
 +
Compile and download the program:<br />
 +
[[File:load.png]]<br />
 +
Expected result:<br />
 +
The sensor is ok with no errors, LED2 is on:<br />
  
You need to copy the examples to /boot of Raspberry Pi and then copy them to /home/pi
+
[[File:led2.png]]<br />
 +
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%.<br />
 +
[[File:led3.png]]<br />
  
;Libraries installation
+
{{Sense Hat b TCS34725}}
Before you run examples, you should install related libraries.
 
*BCM2835 library:
 
<source lang="c">
 
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
 
sudo tar zxvf bcm2835-1.60.tar.gz
 
cd bcm2835-1.xx
 
sudo ./configure
 
make
 
sudo make check
 
sudo make install
 
</source>
 
:Note: You can also go to http://www.airspayce.com/mikem/bcm2835/index.html for newest libraries.
 
*wiringPi libraries
 
<source lang="c">
 
sudo apt-get install git
 
sudo git clone git://git.drogon.net/wiringPi
 
cd wiringPi
 
sudo ./build
 
</source>
 
*Python libraries
 
<source lang="c">
 
sudo apt-get install python-pip
 
sudo pip install RPi.GPIO
 
sudo pip install spidev
 
sudo apt-get install python-imaging
 
sudo apt-get install python-smbus
 
</source>
 
;Enable I2C interface
 
:Before running examples, you also need to enable I2C.
 
:Open terminal, run command '''sudo raspi-config''' to enter configuration menu
 
:Choose Interfacing Options -> I2C -> Yes
 
;Hardware connection
 
To connect the Sense HAT (B) to Raspberry Pi, you can directly add it on the 40PIN GPIO or wire it pin by pin.
 
{|border="1" style="width:500px; text-align:center"
 
|-style="background:#2D2D2D; color:white"
 
|rowspan="2"|'''Sense HAT (B)'''
 
|colspan="2"|'''Raspberry Pi'''
 
|-style="background:#EDEDED;"
 
|Board||BCM2835
 
|-
 
|VCC||3.3V||3.3V
 
|-
 
|GND||GND||GND
 
|-
 
|SDA||3||P2
 
|-
 
|SCL||5||P3
 
|}
 
; 1. ICM20948 examples
 
*bcm2835 example
 
Open terminal of Raspbian, Compile codes and run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/ICM-20948/wiringPi/bcm2835
 
sudo make
 
sudo ./ICM20948_D
 
</source>
 
*WiringPi example
 
Open terminal of Raspbian, run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/ICM-20948/Raspberry Pi/wiringPi
 
sudo make
 
sudo ./ICM20948_D
 
</source>
 
*python example
 
Open terminal of Raspbian, Compile codes and run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/LPS22HB/Raspberry Pi/python
 
sudo python ICM20948.py
 
</source>
 
*Expected result:
 
:[[File:sense-hat-b-user-manual-2.png]]
 
To stop example, you can press Ctrl + C
 
  
;2.LPS22HBTR example
+
=ADS1015 Example—AD Conversion=
<font color="#FF0000">Note: the temperature detection of air pressure sensor is only used as compensation. For accurate temperature detection, please observe the value of shtc3 temperature and humidity sensor.</font>
+
==bcm2835==
*bcm2835 example
+
Open the terminal of Linux, compile codes, and run the example by command:<br />
Open terminal of Raspbian, Compile codes and run example by command:
+
cd ADS1015/Raspberry\ Pi/bcm2835/
<source lang="c">
+
sudo make clean
cd ~/Sense HAT (B)/LPS22HB/wiringPi/bcm2835
+
sudo make
sudo make
+
sudo ./AD
sudo ./LPS22HB
+
Expected result:<br />
</source>
+
[[File:ADS.png]]<br />
*WiringPi example
+
Press Ctrl+C to end the demo.<br />
Open terminal of Raspbian, run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/LPS22HB/Raspberry Pi/wiringPi
 
sudo make
 
sudo ./LPS22HB
 
</source>
 
*python example
 
Open terminal of Raspbian, Compile codes and run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/LPS22HB/Raspberry Pi/python
 
sudo python LPS22HB.py
 
</source>
 
*Expected result:
 
:[[File:sense-hat-b-user-manual-4.png]]
 
To stop example, you can press Ctrl + C
 
  
;3.SHTC3 example
+
==Wiring Pi==
<font color="#FF0000">Note: the raspberry PI's own heat will affect the actual measured temperature. The board has an I2C interface. If accurate ambient temperature is needed, the raspberry PI can be connected to the module at a distance and then tested by wire.</font>
+
Open the terminal of Linux, compile codes, and run the example by command:<br />
*bcm2835 example
+
cd ADS1015/Raspberry\ Pi/wiringPi/
Open terminal of Raspbian, Compile codes and run example by command:
+
sudo make clean
<source lang="c">
+
sudo make
cd ~/Sense HAT (B)/SHTC3/wiringPi/bcm2835
+
sudo ./AD
 +
Expected result:<br />
 +
[[File:ADS2.png]]<br />
 +
Press Ctrl+C to end the demo.
 +
==lgpio Demo==
 +
Enter the Linux terminal and input the following commands:
 +
<pre>
 +
cd ADS1015/Raspberry\ Pi/lgpio/
 +
sudo make clean
 
sudo make
 
sudo make
sudo ./SHTC3
+
sudo ./AD
</source>
+
</pre>
*WiringPi example
+
Expected result:<br />
Open terminal of Raspbian, run example by command:
+
[[File:ADS2.png]]<br />
<source lang="c">
+
Press Ctrl+C to end the demo.
cd ~/Sense HAT (B)/SHTC3/Raspberry Pi/wiringPi
 
sudo make
 
sudo ./SHTC3
 
</source>
 
*Expected result:
 
:[[File:sense-hat-b-user-manual-5.png]]
 
To stop example, you can press Ctrl + C
 
  
;4. TC34725 example
+
==Python==
*bcm2835 example
+
Open the terminal of Linux, compile codes, and run the example by command:<br />
Open terminal of Raspbian, Compile codes and run example by command:
+
cd ADS1015/Raspberry\ Pi/python/
<source lang="c">
+
sudo python3 AD.py
cd ~/Sense HAT (B)/TC34725/wiringPi/bcm2835
+
Expected result:<br />
sudo make
+
[[File:ADS3.png]]<br />
sudo ./TC34725
+
Press Ctrl+C to end the demo.<br />
</source>
 
*WiringPi example
 
Open terminal of Raspbian, run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/TC34725/Raspberry Pi/wiringPi
 
sudo make
 
sudo ./TC34725
 
</source>
 
*python example
 
Open terminal of Raspbian, Compile codes and run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/TC34725/Raspberry Pi/python
 
sudo python TC34725.py
 
</source>
 
*Expected result:
 
:[[File:sense-hat-b-user-manual-6.png]]
 
To stop example, you can press Ctrl + C
 
  
;5. ADS1015 example
+
==VisionFive2 Demo==
*bcm2835 example
+
Enter the Linux terminal and execute the following commands in the terminal:
Open terminal of Raspbian, Compile codes and run example by command:
+
<pre>
<source lang="c">
+
cd ADS1015/VisionFive2
cd ~/Sense HAT (B)/ADS1015/wiringPi/bcm2835
+
python3 AD.py
sudo make
+
</pre>
sudo ./ADS1015
+
Press Ctrl+C to end the demo.
</source>
+
==STM32==
*WiringPi example
+
This demo is based on the XNUCLEO-F103RB development board and outputs data through serial port 2.
Open terminal of Raspbian, run example by command:
+
The connection is as follows:<br />
<source lang="c">
+
[[File:senhat.png]]<br />
cd ~/Sense HAT (B)/ADS1015/Raspberry Pi/wiringPi
+
Compile and download the program:<br />
sudo make
+
[[File:load.png]]<br />
sudo ./ADS1015
+
Open the serial port assistant and set the baud rate to 115200.
</source>
+
[[FILE:STCOM33.PNG]]
*python example
 
Open terminal of Raspbian, Compile codes and run example by command:
 
<source lang="c">
 
cd ~/Sense HAT (B)/ADS1015/Raspberry Pi/python
 
sudo python ADS1015.py
 
</source>
 
*Expected result:
 
:[[File:sense-hat-b-user-manual-10.png]]
 
To stop example, you can press Ctrl + C
 
  
===STM32 examples===
+
=Resources=
 +
==Document==
 +
*[https://files.waveshare.com/upload/4/43/Sense-HAT-B-Schematic.pdf Schematic]
 +
==Demo code==
 +
*[https://files.waveshare.com/upload/6/6c/Sense-HAT-B-Demo.7z Code]
 +
==Datasheet==
 +
*[https://files.waveshare.com/upload/e/e1/Ads1015.pdf ADS1015]
 +
*[https://files.waveshare.com/upload/5/57/ICM-20948-v1.3.pdf ICM-20948]
 +
*[https://files.waveshare.com/upload/2/20/Lps22hb.pdf LPS22HBTR]
 +
*[https://files.waveshare.com/upload/c/cc/Lsf0204d.pdf LSF0204]
 +
*[https://files.waveshare.com/upload/3/33/SHTC3_Datasheet.pdf SHTC3]
 +
*[https://files.waveshare.com/upload/1/13/TCS34725.pdf TCS34725]
  
The STM32 examples are written based on STM32F103RBT6, it will print measuring result to UART 1.
+
=FAQ=
;Hardware connection
+
{|style="margin-top: 10px; /*border-right: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
{|border="1" style="text-align:center; width:400px"
+
|
 +
{|class="roundy" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Question:'''
 
|-
 
|-
|'''Sense HAT (B)'''|| '''STM32'''
+
|Why the Raspberry Pi demo failed to initialize? (The following takes the TC34725 color recognition sensor as an example)
|-
+
|}
|VCC|| 5V/3.3V
+
|}
|-
+
<br />
|GND||GND
+
{|style="margin-top: 10px; /*border-left: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
|-
+
|
|SDA||PB11
+
{|class="roundy mw-collapsible {{#if: {{{collapsed|}}}|mw-collapsed|}}" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Answer:'''
 
|-
 
|-
|SCL||PB10
+
|[[File:an1.png]]
|}
 
; 1. ICM20948 examples
 
1. Open the project
 
  
2. Compiling and download the project
+
For the BCM2835 and wiringPi demo such prompts appear,
  
3. Open serial SSCOM software, result are printed as below
+
[[File:an2.png]]
  
:[[File:sense-hat-b-user-manual-3.png]]
+
If a Python demo occurs the above problem, 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, and 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.
; 2. LPS22HBTR examples
 
  
1. Open the project
+
[[File:an3.png]]
 +
|}
 +
|}
 +
{|style="margin-top: 10px; /*border-right: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Question:'''
 +
|-
 +
|What will happen if using the Raspberry Pi controls incorrectly?
 +
|}
 +
|}
 +
<br />
 +
{|style="margin-top: 10px; /*border-left: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy mw-collapsible {{#if: {{{collapsed|}}}|mw-collapsed|}}" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''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.
 +
|}
 +
|}
  
2. Compiling and download the project
+
{|style="margin-top: 10px; /*border-right: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Question:'''
 +
|-
 +
|What should I do if the serial port output of the STM32 demo has no data or the data output is garbled?
 +
|}
 +
|}
 +
<br />
 +
{|style="margin-top: 10px; /*border-left: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy mw-collapsible {{#if: {{{collapsed|}}}|mw-collapsed|}}" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''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.
  
3. Open serial SSCOM software, result are printed as below
+
[[File:an4.png]]
 +
|}
 +
|}
 +
{|style="margin-top: 10px; /*border-right: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Question:'''
 +
|-
 +
|The serial port output data of the STM32 demo is all 0 or does the initialization fails? As shown.
 +
|}
 +
|}
 +
<br />
 +
{|style="margin-top: 10px; /*border-left: 20px solid transparent;*/ border-top: 20px solid {{{color|#EEE}}};"
 +
|
 +
{|class="roundy mw-collapsible {{#if: {{{collapsed|}}}|mw-collapsed|}}" style="margin-top: -30px; margin-left: -5px; margin-right: -5px; background: {{{color|#EEE}}};"
 +
|'''Answer:'''
 +
|-
 +
|Confirm that there is no problem with the device connection, if there is no problem, please press the reset button.
  
:[[File:sense-hat-b-user-manual-4.png]]
+
[[File:an5.png]]
 
+
|}
; 3. SHTC3 examples
+
|}
 
+
=Support=
1. Open the project
+
{{Servicebox1}}
 
 
2. Compiling and download the project
 
 
 
3. LED 2 lights on if sensor work normally and LED lights on when humidity is larger than 80%
 
 
 
:[[File:sense-hat-b-user-manual-8.png|500px]]
 
 
 
:[[File:sense-hat-b-user-manual-9.png|500px]]
 
 
 
; 4. TC34725 examples
 
 
 
1. Open the project
 
 
 
2. Compiling and download the project
 
 
 
3. Open serial SSCOM software, result are printed as below
 
 
 
:[[File:sense-hat-b-user-manual-7.png]]
 
 
 
; 5. ADS1015 examples
 
 
 
1. Open the project
 
 
 
2. Compiling and download the project
 
 
 
3. Open serial SSCOM software, result are printed as below
 
 
 
:[[File:sense-hat-b-user-manual-11.png]]
 
 
 
== Resources ==
 
*[[:File:Sense-HAT-B-Schematic.pdf|Schematic]]
 
===Demo code===
 
*[https://www.waveshare.com/w/upload/6/6c/Sense-HAT-B-Demo.7z Code]
 
===Datasheet===
 
*[[:File:ads1015.pdf|ADS1015]]
 
*[[:File:ICM-20948-v1.3.pdf|ICM-20948]]
 
*[[:File:lps22hb.pdf|LPS22HBTR]]
 
*[[:File:lsf0204d.pdf|LSF0204]]
 
*[[:File:SHTC3_Datasheet.pdf|SHTC3]]
 
*[[:File:TCS34725.pdf|TCS34725]]
 
 
 
==Support==
 
{{Service00}}
 

Latest revision as of 03:57, 2 January 2024

Sense HAT (B)
Sebse HAT B

Sense HAT (B) for Raspberry Pi, Onboard Multi Powerful Sensors, Supports External Sensors
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Introduction

It is a sensor expansion board specially designed for Raspberry Pi. It has an onboard 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.

More

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 online development resources and manual (examples for Raspberry Pi/STM32).

Specification

Sense HAT (B) Specification
Working voltage 3.3V
Interface I2C
Dimension 65mm x 30.5mm
Accelerometer Resolution: 16-bit
Ranging:±2/±4/±8/±16g
Gyoscope Resolution: 16-bits
Ranging:±250/±500/±1000/±2000°/sec
Magnetometer Resolution: 16-bits
Ranging:±4900µT
Barometer Resolution:24-bits (Pressure), 16-bits(Temperature)
Accuracy (ordinary temperature): ±0.025hPa
Speed: 1 Hz - 75 Hz
Temperature & Humidity Accuracy (humidity):±2% rH
Ranging(humidity): 0% ~ 100% rH
Accuracy(temperature): ±0.2°C
Ranging(temperature): -30 ~ 100°C
Color sensor Resolution: 4-channels RGBC, 16-bits per channel
ADC Resolution: 12-bits

Product PK

Sensor00.png

User Guides for Raspberry Pi

Hardware connection

The pins used to connect to the Raspberry Pi are shown on the right:
Pin connection diagram to Raspberry Pi

Hardware connection diagram:
Connect to Raspberry Pi Zero (pin header is not required)
Sense-HAT-B-9.jpg

Connect to Raspberry Pi 4 (requires a pin header )
Sense-HAT-B-7.jpg

Open I2C Interface

  • Open the Raspberry Pi terminal and enter the following command to enter the configuration interface.
sudo raspi-config 
Choose Interfacing Options -> I2C -> yes start i2C kernel driver

Sensor001.png
and then reboot Raspberry Pi.

sudo reboot

Install Library

If you use the bookworm system, you can only use lgpio library, bcm2835 and wiringPi can't be installed and used.

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

#Open the Raspberry Pi terminal and run the following command
wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
sudo make install

# You can refer to the official website for more: https://github.com/gpiozero/lg

Python

sudo apt update
sudo apt install python3-pip 
sudo apt install python3-spidev
sudo apt install python3-smbus

Download Demo

sudo apt-get install p7zip-full
wget https://files.waveshare.com/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 address

ADS1015: AD conversion demo (STM32, BCM2835, WringPi and Python four demos) Device address: 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) Device 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 demos) 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.

VisionFive2 Preparation

Install Library

apt-get install pip
pip install VisionFive.gpio
apt-get install python3-numpy
apt-get install python3-pil
apt-get install python3-smbus

Download Demo

apt-get install p7zip-full
wget https://files.waveshare.com/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

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_DEMO

Icm2048.png
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:
Result2.png
Press Ctrl+C to end the demo.

lgpio Demo

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

cd ICM-20948/Raspberry\ Pi/lgpio/
sudo make clean
sudo make
sudo ./ICM20948_DEMO

Expected results:
Result3.png
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:
Result3.png
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:
Load.png
Open the serial port assistant and set the baud rate to 115200.
Expected result:
Stm333.3.png

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.png

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.png

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:
Lps.png
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:
Lps2.png
Press Ctrl+C to end the demo.

lgpio Demo

Enter the Linux terminal and input the following commands:

cd LPS22HBTR/Raspberry\ Pi/lgpio/
sudo make clean
sudo make
sudo ./LPS22HB

Expected results:
Lps2.png
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:
Lps3.png
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:

Load.png
Open the serial port assistant and set the baud rate to 115200.
Expected result:
Com.png

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:
Temp1.png
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:
Shtc2.png

Press Ctrl+C to end the demo.

lgpio Demo

Enter the Linux terminal and input the following commands:

cd SHTC3/Raspberry\ Pi/lgpio/
sudo make clean
sudo make
sudo ./SHTC3

Shtc2.png

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:
Shtc3.png
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:
Senhat.png
Compile and download the program:
Load.png
Expected result:
The sensor is ok with no errors, LED2 is on:

Led2.png
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%.
Led3.png

TCS34725 Example—Color Recognition Sensor Demo

Raspberry Pi 5 currently cannot recognize the TCS34725; reason: TCS34725 is not responding.

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:
Tcs1.png
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:
Tcs2.png
Press Ctrl+C to end the demo.

lgpio Demo

Enter the Linux terminal and input the following commands:

cd TCS34725/Raspberry\ Pi/lgpio/
sudo make clean
sudo make
sudo ./main

Expected result:
Tcs2.png
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:
Tcs3.png
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:
Load.png
Open the SSCOM and set the baud rate to 115200.
Expected outcome:
Rgb33.png
How to convert this data to color? The following introduces a tool, copy it to the browser and open it.

https://www.sioe.cn/yingyong/yanse-rgb-16/

Or download:

https://files.waveshare.com/upload/0/05/Hexacolor3.7z

Rgb.png
Hexa.png

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:
ADS.png
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:
ADS2.png
Press Ctrl+C to end the demo.

lgpio Demo

Enter the Linux terminal and input the following commands:

cd ADS1015/Raspberry\ Pi/lgpio/
sudo make clean
sudo make
sudo ./AD

Expected result:
ADS2.png
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:
ADS3.png
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:
Senhat.png
Compile and download the program:
Load.png
Open the serial port assistant and set the baud rate to 115200. STCOM33.PNG

Resources

Document

Demo code

Datasheet

FAQ

Question:
Why the Raspberry Pi demo failed to initialize? (The following takes the TC34725 color recognition sensor as an example)


Answer:
An1.png

For the BCM2835 and wiringPi demo such prompts appear,

An2.png

If a Python demo occurs the above problem, 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, and 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.

An3.png

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.

An4.png

Question:
The serial port output data of the STM32 demo is all 0 or does 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.

An5.png

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 AM GMT+8 (Monday to Friday)