1730 views|4 replies

1236

Posts

66

Resources
The OP
 

[NUCLEO-WBA52CG STM32 wireless product family new series] +2, hardware i2c driver temperature and humidity sensor SHT40 [Copy link]

This post was last edited by dql2016 on 2023-7-30 22:04

I have a Grove SHT40 sensor module, as shown in the figure below. I use it to learn how to use the STM32WBA52CG hardware I2C.

SHT40 is a digital temperature and humidity sensor with an accuracy of up to ±1.8% / max. ±3.5% RH. The main parameters are as follows:

humidity
Typical relative humidity accuracy 1.8 %RH
Operating relative humidity range 0 - 100 %RH
Response time (τ63%) 4 s
Calibration Certificate Factory Calibration
temperature
Typical temperature accuracy 0.2 °C
Operating temperature range -40 - 125 °C
Response time (τ63%) 2 s
Normal
Supply voltage 1.08 - 3.6 V
Average supply current 0.4 uA
interface IC
Dimensions (L x W x H) 1.5 x 1.5 x 0.5 mm
Packing size 2500, 10000 pcs (T&R)

Official information

https://sensirion.com/cn/products/product-catalog/SHT40/

The official driver reference download is provided

链接已隐藏,如需查看请登录或者注册

First, use Stm32cubemx to create a project based on the development board. The advantage of creating a project based on the development board is that the onboard peripherals such as LEDs and buttons are initialized and configured for you:

Open the serial port configuration to facilitate printing logs:

Turn on the hardware I2C. The parameter settings are very simple. You can just use the default ones:

After configuration, generate the project.

Next, refer to the schematic diagram to determine the location of the I2C1 pin:

Connect the lines:

Unzip the driver package downloaded from the official website of Sensirion, and then copy the corresponding files to the project directory of stm32:

Copy the reference driver and replace it:

Create a new group in keil and add these files:

Remove the initialization in the driver abstraction layer, because stm32cubemx has already generated the i2c driver:

The main function calls the test code:

Add printf printing support to the serial port driver:

Final result:

Attach the source package:

stm32wba_test.rar (5.11 MB, downloads: 21)

This post is from RF/Wirelessly

Latest reply

Awesome! Awesome! @@@@! ! ! !   Details Published on 2023-8-1 22:46
 

1236

Posts

66

Resources
2
 

There is a bug at present. After regenerating the Keil project with stm32cubemx, the grouping I added was deleted. . . I didn't have this problem when playing with other stm32 chips before.

This post is from RF/Wirelessly
 
 

6818

Posts

11

Resources
3
 
This post is really wonderful, thanks for sharing. This SHT40 must be very expensive!
This post is from RF/Wirelessly

Comments

A few dozen yuan, a bit expensive  Details Published on 2023-8-1 21:22
 
 
 

1236

Posts

66

Resources
4
 
lugl4313820 published on 2023-8-1 06:46 This post is really wonderful. Thanks for sharing. This SHT40 is expensive!

A few dozen yuan, a bit expensive


This post is from RF/Wirelessly
 
 
 

20

Posts

1

Resources
5
 

Awesome! Awesome! @@@@! ! ! !

This post is from RF/Wirelessly
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list