基于stm32的火焰和可燃气体监测系统的设计与实现
火焰传感器
可燃气体传感器
STM32F103C8T6
wifi模块
oled显示
按键模块
手机app
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "led.h"
#include "key.h"
#include "math.h"
#include "string.h"
#include "user_peripheral.h"
#include "UserPrintf.h"
#include "stm32f10x_adc.h"
#define Display_Debug(_x) do { user_printf _x; } while(0)
#define Display_Debug_Hex(_x) do { user_Dump_Hex _x; } while(0)
u8 yr,hy,yrb,hyb ;
unsigned short timeCount = 0;
u8 readf,yrbb,hybb;
unsigned char *dataPtr = NULL;
u8 kqrt,hymk,kqrtY=50,hymkY=50,kkk;
u16 timef=0,timeg=0;
int main(void)
{
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
uart_init(9600);
user_peripheral_init();
OLED_ShowString(0,0,"KR: |Y: ",16);
OLED_ShowString(0,2,"HY: |Y: ",16);
OLED_ShowString(0,4,"kr: ",16);
OLED_ShowString(0,6,"hy: ",16);
while(1)
{
kqrt=100-Get_Adc_Average(ADC_Channel_0,10)/41;
hymk=100-Get_Adc_Average(ADC_Channel_1,10)/41;
OLED_ShowNum(8*3,0,kqrt,3,16);OLED_ShowNum(8*9,0,kqrtY,3,16);
OLED_ShowNum(8*3,2,hymk,3,16);OLED_ShowNum(8*9,2,hymkY,3,16);
if(++timeCount >= 30)
{
OneNet_SendData();
timeCount = 0;
ESP8266_Clear();
}
kkk=KEY_Scan(0);
if(kkk==1)
{
kqrtY++;
if(kqrtY>99)
kqrtY=0;
}
if(kkk==2)
{
if(kqrtY>0)
kqrtY--;
else
kqrtY=100;
}
if(kkk==3)
{
hymkY++;
if(hymkY>99)
hymkY=0;
}
if(kkk==4)
{
if(hymkY>0)
hymkY--;
else
hymkY=100;
}
if(kqrt>kqrtY)
{
yr=1;
OLED_ShowString(30,4,"yes",16);
}
else
{
yr=0;
OLED_ShowString(30,4,"no ",16);
}
if(hymk>hymkY)
{
hy=1; OLED_ShowString(30,6,"yes",16);
}
else
{
hy=0; OLED_ShowString(30,6,"no ",16);
}
delay_ms(10);
dataPtr = ESP8266_GetIPD(0);
if(dataPtr != NULL)
OneNet_RevPro(dataPtr);
}
}
|