
#第九届立创电赛#温湿度测量仪
简介
该项目使用STM32G030K6T6为主控,结合SHT40温湿度传感器模块,实现温湿度测量等功能,但数码管画反了,显示有点奇怪
简介:该项目使用STM32G030K6T6为主控,结合SHT40温湿度传感器模块,实现温湿度测量等功能,但数码管画反了,显示有点奇怪开源协议
:Public Domain
描述
* 1、项目功能介绍
该项目使用STM32G030K6T6为主控,结合SHT40温湿度传感器模块,实现温湿度测量等功能
*2、项目属性
第九届立创电赛,温湿度测量仪
*3.软件部分
显示温度湿度的代码i2c.c部分
void Get_TemperatureHumidity(float *Temperature,float *Humidity )
{
uint8_t writeData[1]={0xFD};
uint8_t readData[6]={0};
HAL_Delay (100);
HAL_I2C_Master_Transmit(&hi2c1,(uint16_t )SHT40_WRITE_ADDR,(uint8_t * )writeData ,1,HAL_MAX_DELAY );
HAL_Delay (10);
HAL_I2C_Master_Receive(&hi2c1,(uint16_t )SHT40_READ_ADDR,(uint8_t * )readData ,6,HAL_MAX_DELAY );
(*Temperature)=(1.0*175*(readData [0]*256+readData [1]))/65535.0-45;
(*Humidity)=(1.0*125*(readData [3]*256+readData [4]))/65535.0-6.0;
}
main.c部分
uint16_t num =0;
uint8_t writeData[1]={0xFD};
uint8_t readData[6]={0};
uint16_t Temp = 0, Humi = 0;
float Temperature =0;
float Humidity = 0;
Get_TemperatureHumidity( &Temperature,&Humidity);
Temp = (uint16_t)(Temperature*10);
Humi = (uint16_t)(Humidity*10);
num ++;
if(num <100)
{
ShowNum(1,1,Temp/100);
ShowNum(1,2,Temp/10%10);
ShowNum(1,3,Temp%10);
}
else if(num <200)
{
ShowNum(2,1,Humi /100);
ShowNum(2,2,Humi /10%10);
ShowNum(2,3,Humi %10);
}
else {
num = 0;
ShowNum(1,1,Temp/100);
ShowNum(1,2,Temp/10%10);
ShowNum(1,3,Temp%10);
}
* 4、演示您的项目并录制成视频上传
设计图

BOM


评论