2433 views|3 replies

221

Posts

0

Resources
The OP
 

[Silicon Labs Development Kit Review] +Si7021 Temperature and Humidity Sensor Detection [Copy link]

 This post was last edited by yin_wu_qing on 2021-9-6 09:50

As mentioned in the previous post, the development board integrates the Si7021 temperature and humidity sensor, which uses the IIC interface to communicate with the MCU. Through the official data sheet, we can understand the packaging, characteristics, and detailed communication protocol of this sensor. Several important information points are shared as follows:

The circuit connection of Si7021 sensor on EFM32PG22 development board can refer to the circuit schematic diagram

Similarly, Si7021 and the ambient light sensor (VEML6035) and Hall effect sensor (Si7210) shared earlier are all connected to the IIC bus, SDA is connected to the PD02 pin, SCL is connected to the PD03 pin, and the enable pin is PC06. In "Simplicity Studio IDE", create an RTOS basic project. Here, the template from the previous issue is used. You only need to install the corresponding configuration interface.

After completing the construction of the above components, include the header file of the Si7021 sensor in the task processing source file

Now open the "sl_si70xx.h" file and you will find that the official has provided a reference example. The user only needs to put the reference example function in the task processing function to be called.

Print out the collected Data value using the floating point data type, then compile and download, open the serial port debugging assistant, and then gently place your finger on the Si7021 sensor. You can clearly see that the temperature and humidity values will increase accordingly; if you remove your finger, the temperature and humidity values will slowly return to the indoor temperature and humidity values. This shows that the Si7021 sensor on the development board is very sensitive and the collected data is very accurate.

#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"

#include "sl_i2cspm.h"
#include "em_cmu.h"
#include "sl_i2cspm_sensor_config.h"
#include "sl_veml6035.h"
#include "sl_si7210.h"
#include "sl_si70xx.h"

#ifndef TOOGLE_DELAY_MS
#define TOOGLE_DELAY_MS            25
#endif

#ifndef Envir_Hall_STACK_SIZE
#define Envir_Hall_STACK_SIZE      configMINIMAL_STACK_SIZE
#endif

#ifndef EXAMPLE_USE_STATIC_ALLOCATION
#define EXAMPLE_USE_STATIC_ALLOCATION      0
#endif

static void Envir_Hall_test_task(void *arg);


sl_i2cspm_t *sl_i2cspm_sensor = SL_I2CSPM_SENSOR_PERIPHERAL;

void Envir_Hall_test_init(void)
{
  TaskHandle_t xHandle = NULL;
  BaseType_t xReturned = pdFAIL;

#if (EXAMPLE_USE_STATIC_ALLOCATION == 1)

  static StaticTask_t xTaskBuffer;
  static StackType_t  xStack[Envir_Hall_STACK_SIZE];
#else

  xReturned = xTaskCreate(Envir_Hall_test_task,
                           "Envir_Hall_test task",
                           Envir_Hall_STACK_SIZE,
                           ( void * ) NULL,
                           tskIDLE_PRIORITY + 4,
                           &xHandle);
  EFM_ASSERT(xReturned == pdPASS);

#endif
}

static void Envir_Hall_test_task(void *arg)
{
  int32_t temp_data;   //温度值
  uint32_t rh_data;    //湿度值
  uint8_t fw_data;
  (void)&arg;

  sl_si70xx_init(sl_i2cspm_sensor,SI7021_ADDR);
  sl_si70xx_get_firmware_revision(sl_i2cspm_sensor,SI7021_ADDR,&fw_data);
  printf("si7021's FW Version:%d\r\n",fw_data);
  while(1)
    {
      sl_si70xx_measure_rh_and_temp(sl_i2cspm_sensor,SI7021_ADDR,&rh_data,&temp_data);
      printf("\n");
      printf("hum=%f   tem=%f\r\n",rh_data/1000.0,temp_data/1000.0);
    }
}

Latest reply

It seems that the operation is quite convenient!   Details Published on 2021-9-7 13:08

赞赏

1

查看全部赞赏

 
 

2w

Posts

74

Resources
2
 

Good looking forward to the sequel.

Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

加油!在电子行业默默贡献自己的力量!:)

 
 
 

1412

Posts

3

Resources
3
 

Thanks for sharing, looking forward to the follow-up

Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 
 

1942

Posts

2

Resources
4
 

It seems that the operation is quite convenient!

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list