版本协议

Public Domain

专业版
#第九届立创电赛#温湿度检测仪-7709272A

创建时间:4个月前

117 0

描述

<p><div> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"><em> 1、项目功能介绍</h3> <hr /> <p style="line-height: 1.8;">1.采用盛思锐传感器作为温湿度传感器模块,高精度、体积小,适合采集周围环境温湿度。</p> <p style="line-height: 1.8;">2.左上角有一个按键,按下可以使采集到的温度和湿度在数码管上分别闪烁两次。</p> <p style="line-height: 1.8;">3.具有长时间待机功能。</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"></em>2、项目属性</h3> <hr /> <p style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">本项目首次公开,非本人原创项目。项目未曾在别的比赛中获奖。</span></p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"><em> 3、开源协议</h3> </div> <div>克隆温湿度传感器训练营的开源项目。</div> <div> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"></em>4、硬件部分</h3> <hr /> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/a17a7d9140814baeb9aea8f0e9358eab.png" alt="原理图" width="1013" height="715" /></p> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/bcbe024b654c4d759e975db98df333b4.png" alt="PCB" width="1343" height="784" /></p> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/2eb91cf3329644ad855aac58c0fdbc44.png" alt="3D效果" width="1253" height="723" /></p> <h3 style="line-height: 1.8;"><em>5、软件部分</h3> <hr /> <div>主要代码如下:</div> <div>&nbsp;</div> <div>/</em> USER CODE BEGIN Header */</div> <div>/<strong></div> <div>&nbsp; <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>****</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div> <div>&nbsp; <em> @file&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: main.c</div> <div>&nbsp; </em> @brief&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : Main program body</div> <div>&nbsp; <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div> <div>&nbsp; <em> @attention</div> <div>&nbsp; </em></div> <div>&nbsp; <em> Copyright (c) 2024 STMicroelectronics.</div> <div>&nbsp; </em> All rights reserved.</div> <div>&nbsp; <em></div> <div>&nbsp; </em> This software is licensed under terms that can be found in the LICENSE file</div> <div>&nbsp; <em> in the root directory of this software component.</div> <div>&nbsp; </em> If no LICENSE file comes with this software, it is provided AS-IS.</div> <div>&nbsp; *</div> <div>&nbsp; <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div> <div>&nbsp; <em>/</div> <div>/</em> USER CODE END Header <em>/</div> <div>/</em> Includes ------------------------------------------------------------------<em>/</div> <div>#include "main.h"</div> <div>#include "adc.h"</div> <div>#include "i2c.h"</div> <div>#include "tim.h"</div> <div>#include "gpio.h"</div> <div>&nbsp;</div> <div>/</em> Private includes ----------------------------------------------------------<em>/</div> <div>/</em> USER CODE BEGIN Includes <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END Includes <em>/</div> <div>&nbsp;</div> <div>/</em> Private typedef -----------------------------------------------------------<em>/</div> <div>/</em> USER CODE BEGIN PTD <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END PTD <em>/</div> <div>&nbsp;</div> <div>/</em> Private define ------------------------------------------------------------<em>/</div> <div>/</em> USER CODE BEGIN PD <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END PD <em>/</div> <div>&nbsp;</div> <div>/</em> Private macro -------------------------------------------------------------<em>/</div> <div>/</em> USER CODE BEGIN PM <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END PM <em>/</div> <div>&nbsp;</div> <div>/</em> Private variables ---------------------------------------------------------<em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE BEGIN PV <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END PV <em>/</div> <div>&nbsp;</div> <div>/</em> Private function prototypes -----------------------------------------------<em>/</div> <div>void SystemClock_Config(void);</div> <div>/</em> USER CODE BEGIN PFP <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END PFP <em>/</div> <div>&nbsp;</div> <div>/</em> Private user code ---------------------------------------------------------<em>/</div> <div>/</em> USER CODE BEGIN 0 <em>/</div> <div>struct DEVICE_PARAMTER device_paramter = {0};</div> <div>/</em> USER CODE END 0 */</div> <div>&nbsp;</div> <div>/<strong></div> <div>&nbsp; <em> @brief&nbsp; The application entry point.</div> <div>&nbsp; </em> @retval int</div> <div>&nbsp; <em>/</div> <div>int main(void)</div> <div>{</div> <div>&nbsp; /</em> USER CODE BEGIN 1 <em>/</div> <div>float temperature = 0;</div> <div>float humidity = 0;</div> <div>&nbsp; /</em> USER CODE END 1 <em>/</div> <div>&nbsp;</div> <div>&nbsp; /</em> MCU Configuration--------------------------------------------------------<em>/</div> <div>&nbsp;</div> <div>&nbsp; /</em> Reset of all peripherals, Initializes the Flash interface and the Systick. <em>/</div> <div>&nbsp; HAL_Init();</div> <div>&nbsp;</div> <div>&nbsp; /</em> USER CODE BEGIN Init <em>/</div> <div>&nbsp;</div> <div>&nbsp; /</em> USER CODE END Init <em>/</div> <div>&nbsp;</div> <div>&nbsp; /</em> Configure the system clock <em>/</div> <div>&nbsp; SystemClock_Config();</div> <div>&nbsp;</div> <div>&nbsp; /</em> USER CODE BEGIN SysInit <em>/</div> <div>HAL_DeInit();</div> <div>&nbsp; /</em> USER CODE END SysInit <em>/</div> <div>&nbsp;</div> <div>&nbsp; /</em> Initialize all configured peripherals <em>/</div> <div>&nbsp; MX_GPIO_Init();</div> <div>&nbsp; MX_ADC1_Init();</div> <div>&nbsp; MX_I2C1_Init();</div> <div>&nbsp; MX_TIM14_Init();</div> <div>&nbsp; /</em> USER CODE BEGIN 2 <em>/</div> <div>HAL_Delay(100);</div> <div>&nbsp; SN74HC595_Send_Data(SN_DIG,0xFF); //&sup1;&Oslash;&plusmn;&Otilde;&Ecirc;&yacute;&Acirc;&euml;&sup1;&Uuml;&Iuml;&Ocirc;&Ecirc;&frac34;</div> <div>&nbsp; SN74HC595_Send_Data(SN_LED1,0x00);</div> <div>&nbsp; SN74HC595_Send_Data(SN_LED2,0x00);</div> <div>&nbsp;</div> <div>&nbsp; /</em> USER CODE END 2 <em>/</div> <div>HAL_SuspendTick();//&Ocirc;&Yacute;&Iacute;&pound;&micro;&Icirc;&acute;&eth;&para;&uml;&Ecirc;&plusmn;&AElig;&divide;&pound;&not;&middot;&Agrave;&Ouml;&sup1;&Iacute;&uml;&sup1;&yacute;&micro;&Icirc;&acute;&eth;&para;&uml;&Ecirc;&plusmn;&AElig;&divide;&Ouml;&ETH;&para;&Iuml;&raquo;&frac12;&ETH;&Ntilde;</div> <div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /</em> &Ouml;&acute;&ETH;&ETH;WFI&Ouml;&cedil;&Aacute;&icirc;, &frac12;&oslash;&Egrave;&euml;&Euml;&macr;&Atilde;&szlig;&Auml;&pound;&Ecirc;&frac12; <em>/</div> <div>&nbsp; /</em> Infinite loop <em>/</div> <div>&nbsp; /</em> USER CODE BEGIN WHILE <em>/</div> <div>&nbsp; while (1)</div> <div>&nbsp; {</div> <div>&nbsp; &nbsp; /</em> USER CODE END WHILE <em>/</div> <div>&nbsp;</div> <div>&nbsp; &nbsp; /</em> USER CODE BEGIN 3 <em>/</div> <div>if(device_paramter.KeyStatus == KEY_SHAKE_STATE)</div> <div>{</div> <div>HAL_Delay(10);</div> <div>if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET)</div> <div>{</div> <div>while(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET);</div> <div>&nbsp;</div> <div>SHT40_Read_RHData(&amp;temperature,&amp;humidity);//&para;&Aacute;&Egrave;&iexcl;&Icirc;&Acirc;&Ecirc;&ordf;&para;&Egrave;</div> <div>device_paramter.Temp = temperature </em> 10;//&middot;&Aring;&acute;&oacute;&Icirc;&Acirc;&Ecirc;&ordf;&para;&Egrave;</div> <div>device_paramter.Humi = humidity <em> 10;</div> <div>HAL_TIM_Base_Start_IT(&amp;htim14);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//&iquest;&ordf;&Ecirc;&frac14;&para;&uml;&Ecirc;&plusmn;&AElig;&divide;&pound;&not;&Iuml;&Ocirc;&Ecirc;&frac34;&Aacute;&frac12;&acute;&Icirc;&Ecirc;&yacute;&frac34;&Yacute;&nbsp;</div> <div>device_paramter.sleepStatus = 0;//&Ccedil;&aring;&sup3;&yacute;&ETH;&Yacute;&Atilde;&szlig;&plusmn;&ecirc;&Ouml;&frac34;</div> <div>device_paramter.KeyStatus = KEY_NO_PRESS;//&Ccedil;&aring;&sup3;&yacute;&deg;&acute;&Iuml;&Acirc;&plusmn;&ecirc;&Ouml;&frac34;</div> <div>}</div> <div>}</div> <div>else if(device_paramter.sleepStatus == 1)//&Iuml;&Ocirc;&Ecirc;&frac34;&frac12;&aacute;&Ecirc;&oslash;&pound;&not;&frac12;&oslash;&Egrave;&euml;&ETH;&Yacute;&Atilde;&szlig;</div> <div>{</div> <div>HAL_SuspendTick();//&Ocirc;&Yacute;&Iacute;&pound;&micro;&Icirc;&acute;&eth;&para;&uml;&Ecirc;&plusmn;&AElig;&divide;&pound;&not;&middot;&Agrave;&Ouml;&sup1;&Iacute;&uml;&sup1;&yacute;&micro;&Icirc;&acute;&eth;&para;&uml;&Ecirc;&plusmn;&AElig;&divide;&Ouml;&ETH;&para;&Iuml;&raquo;&frac12;&ETH;&Ntilde;</div> <div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /</em> &Ouml;&acute;&ETH;&ETH;WFI&Ouml;&cedil;&Aacute;&icirc;, &frac12;&oslash;&Egrave;&euml;&Euml;&macr;&Atilde;&szlig;&Auml;&pound;&Ecirc;&frac12; <em>/</div> <div>}</div> <div>&nbsp; }</div> <div>&nbsp; /</em> USER CODE END 3 */</div> <div>}</div> <div>&nbsp;</div> <div>/*<em></div> <div>&nbsp; </em> @brief System Clock Configuration</div> <div>&nbsp; <em> @retval None</div> <div>&nbsp; </em>/</div> <div>void SystemClock_Config(void)</div> <div>{</div> <div>&nbsp; RCC_OscInitTypeDef RCC_OscInitStruct = {0};</div> <div>&nbsp; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};</div> <div>&nbsp;</div> <div>&nbsp; /</strong> Configure the main internal regulator output voltage</div> <div>&nbsp; */</div> <div>&nbsp; HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</div> <div>&nbsp;</div> <div>&nbsp; /<strong> Initializes the RCC Oscillators according to the specified parameters</div> <div>&nbsp; <em> in the RCC_OscInitTypeDef structure.</div> <div>&nbsp; </em>/</div> <div>&nbsp; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;</div> <div>&nbsp; RCC_OscInitStruct.HSIState = RCC_HSI_ON;</div> <div>&nbsp; RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;</div> <div>&nbsp; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLN = 8;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;</div> <div>&nbsp; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;</div> <div>&nbsp; if (HAL_RCC_OscConfig(&amp;RCC_OscInitStruct) != HAL_OK)</div> <div>&nbsp; {</div> <div>&nbsp; &nbsp; Error_Handler();</div> <div>&nbsp; }</div> <div>&nbsp;</div> <div>&nbsp; /</strong> Initializes the CPU, AHB and APB buses clocks</div> <div>&nbsp; <em>/</div> <div>&nbsp; RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK</div> <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |RCC_CLOCKTYPE_PCLK1;</div> <div>&nbsp; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;</div> <div>&nbsp; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;</div> <div>&nbsp; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;</div> <div>&nbsp;</div> <div>&nbsp; if (HAL_RCC_ClockConfig(&amp;RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)</div> <div>&nbsp; {</div> <div>&nbsp; &nbsp; Error_Handler();</div> <div>&nbsp; }</div> <div>}</div> <div>&nbsp;</div> <div>/</em> USER CODE BEGIN 4 <em>/</div> <div>&nbsp;</div> <div>/</em> USER CODE END 4 */</div> <div>&nbsp;</div> <div>/*<em></div> <div>&nbsp; </em> @brief&nbsp; This function is executed in case of error occurrence.</div> <div>&nbsp; <em> @retval None</div> <div>&nbsp; </em>/</div> <div>void Error_Handler(void)</div> <div>{</div> <div>&nbsp; /<em> USER CODE BEGIN Error_Handler_Debug </em>/</div> <div>&nbsp; /<em> User can add his own implementation to report the HAL error return state </em>/</div> <div>&nbsp; __disable_irq();</div> <div>&nbsp; while (1)</div> <div>&nbsp; {</div> <div>&nbsp; }</div> <div>&nbsp; /<em> USER CODE END Error_Handler_Debug </em>/</div> <div>}</div> <div>&nbsp;</div> <div>#ifdef&nbsp; USE_FULL_ASSERT</div> <div>/*<em></div> <div>&nbsp; </em> @brief&nbsp; Reports the name of the source file and the source line number</div> <div>&nbsp; <em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where the assert_param error has occurred.</div> <div>&nbsp; </em> @param&nbsp; file: pointer to the source file name</div> <div>&nbsp; <em> @param&nbsp; line: assert_param error line source number</div> <div>&nbsp; </em> @retval None</div> <div>&nbsp; <em>/</div> <div>void assert_failed(uint8_t </em>file, uint32_t line)</div> <div>{</div> <div>&nbsp; /<em> USER CODE BEGIN 6 </em>/</div> <div>&nbsp; /<em> User can add his own implementation to report the file name and line number,</div> <div>&nbsp; &nbsp; &nbsp;ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) </em>/</div> <div>&nbsp; /<em> USER CODE END 6 </em>/</div> <div>}</div> <div>#endif /<em> USE_FULL_ASSERT </em>/</div> <p>&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"><em>6、BOM清单</h3> <hr /> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/59244f6e3fdd47c6a0975a2e315e56d3.png" alt="" width="1526" height="340" /></p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;"></em>7、大赛LOGO验证</h3> <hr /> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/c2cb1c91686b42239e4136195fa82ed1.png" alt="" width="716" height="572" /></p> <p style="line-height: 1.8;">&nbsp;</p> <h3 style="line-height: 1.8;">* 8、演示您的项目并录制成视频上传</h3> <hr /> <p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/5ab0743627fd4ef68b79f548de03c0dd.jpg" alt="" width="1279" height="1706" /></p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> <p style="line-height: 1.8;">&nbsp;</p> </div></p>

文档

BOM

暂无

附件

附件名 下载
温湿度检测仪.zip

成员

评论(0)

  • 表情
    emoji
    小嘉工作篇
    小嘉日常篇
  • 图片
成功
工程所有者当前已关闭评论
goToTop
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow