描述
<p><div>
<p style="line-height: 1.8;"> </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;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </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;"> </p>
<p style="line-height: 1.8;"> </p>
<h3 style="line-height: 1.8;"><em> 3、开源协议</h3>
</div>
<div>克隆温湿度传感器训练营的开源项目。</div>
<div>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </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> </div>
<div>/</em> USER CODE BEGIN Header */</div>
<div>/<strong></div>
<div> <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> <em> @file : main.c</div>
<div> </em> @brief : Main program body</div>
<div> <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> <em> @attention</div>
<div> </em></div>
<div> <em> Copyright (c) 2024 STMicroelectronics.</div>
<div> </em> All rights reserved.</div>
<div> <em></div>
<div> </em> This software is licensed under terms that can be found in the LICENSE file</div>
<div> <em> in the root directory of this software component.</div>
<div> </em> If no LICENSE file comes with this software, it is provided AS-IS.</div>
<div> *</div>
<div> <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> <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> </div>
<div>/</em> Private includes ----------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN Includes <em>/</div>
<div> </div>
<div>/</em> USER CODE END Includes <em>/</div>
<div> </div>
<div>/</em> Private typedef -----------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PTD <em>/</div>
<div> </div>
<div>/</em> USER CODE END PTD <em>/</div>
<div> </div>
<div>/</em> Private define ------------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PD <em>/</div>
<div> </div>
<div>/</em> USER CODE END PD <em>/</div>
<div> </div>
<div>/</em> Private macro -------------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PM <em>/</div>
<div> </div>
<div>/</em> USER CODE END PM <em>/</div>
<div> </div>
<div>/</em> Private variables ---------------------------------------------------------<em>/</div>
<div> </div>
<div>/</em> USER CODE BEGIN PV <em>/</div>
<div> </div>
<div>/</em> USER CODE END PV <em>/</div>
<div> </div>
<div>/</em> Private function prototypes -----------------------------------------------<em>/</div>
<div>void SystemClock_Config(void);</div>
<div>/</em> USER CODE BEGIN PFP <em>/</div>
<div> </div>
<div>/</em> USER CODE END PFP <em>/</div>
<div> </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> </div>
<div>/<strong></div>
<div> <em> @brief The application entry point.</div>
<div> </em> @retval int</div>
<div> <em>/</div>
<div>int main(void)</div>
<div>{</div>
<div> /</em> USER CODE BEGIN 1 <em>/</div>
<div>float temperature = 0;</div>
<div>float humidity = 0;</div>
<div> /</em> USER CODE END 1 <em>/</div>
<div> </div>
<div> /</em> MCU Configuration--------------------------------------------------------<em>/</div>
<div> </div>
<div> /</em> Reset of all peripherals, Initializes the Flash interface and the Systick. <em>/</div>
<div> HAL_Init();</div>
<div> </div>
<div> /</em> USER CODE BEGIN Init <em>/</div>
<div> </div>
<div> /</em> USER CODE END Init <em>/</div>
<div> </div>
<div> /</em> Configure the system clock <em>/</div>
<div> SystemClock_Config();</div>
<div> </div>
<div> /</em> USER CODE BEGIN SysInit <em>/</div>
<div>HAL_DeInit();</div>
<div> /</em> USER CODE END SysInit <em>/</div>
<div> </div>
<div> /</em> Initialize all configured peripherals <em>/</div>
<div> MX_GPIO_Init();</div>
<div> MX_ADC1_Init();</div>
<div> MX_I2C1_Init();</div>
<div> MX_TIM14_Init();</div>
<div> /</em> USER CODE BEGIN 2 <em>/</div>
<div>HAL_Delay(100);</div>
<div> SN74HC595_Send_Data(SN_DIG,0xFF); //¹Ø±ÕÊýÂë¹ÜÏÔʾ</div>
<div> SN74HC595_Send_Data(SN_LED1,0x00);</div>
<div> SN74HC595_Send_Data(SN_LED2,0x00);</div>
<div> </div>
<div> /</em> USER CODE END 2 <em>/</div>
<div>HAL_SuspendTick();//ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ</div>
<div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /</em> Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ <em>/</div>
<div> /</em> Infinite loop <em>/</div>
<div> /</em> USER CODE BEGIN WHILE <em>/</div>
<div> while (1)</div>
<div> {</div>
<div> /</em> USER CODE END WHILE <em>/</div>
<div> </div>
<div> /</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> </div>
<div>SHT40_Read_RHData(&temperature,&humidity);//¶ÁÈ¡ÎÂʪ¶È</div>
<div>device_paramter.Temp = temperature </em> 10;//·Å´óÎÂʪ¶È</div>
<div>device_paramter.Humi = humidity <em> 10;</div>
<div>HAL_TIM_Base_Start_IT(&htim14); //¿ªÊ¼¶¨Ê±Æ÷£¬ÏÔʾÁ½´ÎÊý¾Ý </div>
<div>device_paramter.sleepStatus = 0;//Çå³ýÐÝÃß±êÖ¾</div>
<div>device_paramter.KeyStatus = KEY_NO_PRESS;//Çå³ý°´Ï±êÖ¾</div>
<div>}</div>
<div>}</div>
<div>else if(device_paramter.sleepStatus == 1)//ÏÔʾ½áÊø£¬½øÈëÐÝÃß</div>
<div>{</div>
<div>HAL_SuspendTick();//ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ</div>
<div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /</em> Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ <em>/</div>
<div>}</div>
<div> }</div>
<div> /</em> USER CODE END 3 */</div>
<div>}</div>
<div> </div>
<div>/*<em></div>
<div> </em> @brief System Clock Configuration</div>
<div> <em> @retval None</div>
<div> </em>/</div>
<div>void SystemClock_Config(void)</div>
<div>{</div>
<div> RCC_OscInitTypeDef RCC_OscInitStruct = {0};</div>
<div> RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};</div>
<div> </div>
<div> /</strong> Configure the main internal regulator output voltage</div>
<div> */</div>
<div> HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</div>
<div> </div>
<div> /<strong> Initializes the RCC Oscillators according to the specified parameters</div>
<div> <em> in the RCC_OscInitTypeDef structure.</div>
<div> </em>/</div>
<div> RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;</div>
<div> RCC_OscInitStruct.HSIState = RCC_HSI_ON;</div>
<div> RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;</div>
<div> RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;</div>
<div> RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;</div>
<div> RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;</div>
<div> RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;</div>
<div> RCC_OscInitStruct.PLL.PLLN = 8;</div>
<div> RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;</div>
<div> RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;</div>
<div> if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)</div>
<div> {</div>
<div> Error_Handler();</div>
<div> }</div>
<div> </div>
<div> /</strong> Initializes the CPU, AHB and APB buses clocks</div>
<div> <em>/</div>
<div> RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK</div>
<div> |RCC_CLOCKTYPE_PCLK1;</div>
<div> RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;</div>
<div> RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;</div>
<div> RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;</div>
<div> </div>
<div> if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)</div>
<div> {</div>
<div> Error_Handler();</div>
<div> }</div>
<div>}</div>
<div> </div>
<div>/</em> USER CODE BEGIN 4 <em>/</div>
<div> </div>
<div>/</em> USER CODE END 4 */</div>
<div> </div>
<div>/*<em></div>
<div> </em> @brief This function is executed in case of error occurrence.</div>
<div> <em> @retval None</div>
<div> </em>/</div>
<div>void Error_Handler(void)</div>
<div>{</div>
<div> /<em> USER CODE BEGIN Error_Handler_Debug </em>/</div>
<div> /<em> User can add his own implementation to report the HAL error return state </em>/</div>
<div> __disable_irq();</div>
<div> while (1)</div>
<div> {</div>
<div> }</div>
<div> /<em> USER CODE END Error_Handler_Debug </em>/</div>
<div>}</div>
<div> </div>
<div>#ifdef USE_FULL_ASSERT</div>
<div>/*<em></div>
<div> </em> @brief Reports the name of the source file and the source line number</div>
<div> <em> where the assert_param error has occurred.</div>
<div> </em> @param file: pointer to the source file name</div>
<div> <em> @param line: assert_param error line source number</div>
<div> </em> @retval None</div>
<div> <em>/</div>
<div>void assert_failed(uint8_t </em>file, uint32_t line)</div>
<div>{</div>
<div> /<em> USER CODE BEGIN 6 </em>/</div>
<div> /<em> User can add his own implementation to report the file name and line number,</div>
<div> ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) </em>/</div>
<div> /<em> USER CODE END 6 </em>/</div>
<div>}</div>
<div>#endif /<em> USE_FULL_ASSERT </em>/</div>
<p> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </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;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </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;"> </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;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </p>
</div></p>
评论(0)