STM32单片机DS18B20+ESP8266芯片复制
芯片复制STM32单片机DS18
- #include "stm32f10x.h"
- #include "bsp_SysTick.h"
- #include "bsp_usart1.h"
- #include "bsp_usart3.h"
- 芯片复制#include "TIM3.h"
- 芯片复制#include "temper.h"
- 芯片复制#include "power.h"
- #include "infra_red.h"
- #include "stm32f10x_it.h"
- //C库
- #include <string.h>
- //WIFI
- #include "esp8266.h"
- #include "onenet.h"
- unsigned char order = 0;
- __IO float temper= 0;
- unsigned char pwm = 0;
- /***************************************************************************************************************************************/
- /*-------------------------------------------------------------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------主函数--------------------------------------------------------------*/
- /*-------------------------------------------------------------------------------------------------------------------------------------*/
- /***************************************************************************************************************************************/
- int main(void)
- {
-
-
- unsigned short timeCount = 0; //发送间隔变量
- unsigned char *dataPtr = NULL;
- char power = 0;
- u8 t=0;
- /******************各模块功能初始化********************/
- //设置中断组为2
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- SysTick_Init();
- POWER_GPIO_Config();
- USART_Config();
- TIM3_Init();
- RED_GPIO_Config();
- USART3_Config();
- DS18B20_GPIO_Config();
- ESP8266_Init();
- /**********************************************************************************************************************************************/
- /**********************************************************************************************************************************************/
- /**********************************************************************************************************************************************/
- SysTick_Delay_Ms(500);
- while(OneNet_DevLink()) //接入OneNET
- SysTick_Delay_Ms(500);
- while(1)
- {
- if(t%10==0) //每100ms读取一次
- {
- temper = DS18B20_Get_Temp();
- }
- if(t%100==0) //每1s串口1发送一次
- {
- printf("温度:%.2f\r\n",temper);
- }
- /******************************************************************************/
- switch (order)
- {
- /******************************************************************************/
- //正常运行模式 order 0
- case 0:
- if(RED == 1)
- {
- power = 1;
- }else
- {
- power = 0;
- POWER_OFF
- pwm = 0;
- }
- if(power)
- {
- if(temper>35)
- {
- POWER_ON
- pwm = 100;
- }else if(temper>25&temper<35)
- {
- POWER_ON
- pwm = ((((int)(temper*100))-2500)/10);
- }else
- {
- POWER_OFF
- pwm = 0;
- }
- TIM_SetCompare2(TIM3,pwm); //设置占空比改变电机转速
- }
- break;
B20+ESP8266

芯片解密