OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2331|回复: 1

请大神帮我看看,之前PM2.5可以显示 温度也可以显示,然后我想把温度和pm2.5一起显示,pm2.5为什么没数据?

[复制链接]

22

主题

271

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
405
金钱
405
注册时间
2019-3-21
在线时间
107 小时
发表于 2019-3-28 09:39:17 | 显示全部楼层 |阅读模式
10金钱
#include "led.h"
#include "usart.h"
#include "pms5003.h"
#include "MyUsart.h"
#include "timer.h"
#include "timer2.h"
#include "NTCtp.h"
#include "stdio.h"
#include "string.h"

extern uint8_t data_buffer[100];
extern uint8_t data_cnt;
extern uint8_t har;
extern uint8_t sum;
extern uint32_t Resultvolt;
extern uint32_t Resistance;
extern uint32_t electricity;
extern int Temp;
uint32_t tick1ms;
int PM2_5;
int main()
{
  static uint32_t  led_timer = 0;
  static uint32_t  NTC_timer = 0;
  static uint32_t  PMS5003_timer = 0;

  //SysTick_Config_Init();
  led_gpio_init();
  NTCtp_config();
  pms5003_config();
  while(1)
  {
    if (tick1ms - led_timer >= 500)
    {
      led_timer = tick1ms;
      //GPIO_ResetBits(GPIOB,GPIO_Pin_7);
      GPIOB->ODR ^= GPIO_Pin_7;
    }

    if (tick1ms - NTC_timer >= 500)
    {
      NTC_timer = tick1ms;
      look_up_table();

      printf("电压是%dmv\r\n",Resultvolt);   //NTC电压
      printf("电流是%dμA\r\n",electricity);   //电流
      printf("电阻是%dΩ\r\n",Resistance);   //NTC电阻 ;
      printf("温度是%d°C\r\n",Temp);
    }

    if (tick1ms - PMS5003_timer >= 500)
    {
      PMS5003_timer = tick1ms;
      while(data_cnt == 32)
      {
        PM2_5 = (int)data_buffer[12] * 256 + (int)data_buffer[13];  //PM2.5
        printf("PM2.5 is %d ug/m3\r\n", PM2_5);

        if(data_cnt >= 32)
        {
          data_cnt = 0;
        }

      }
    }
  }
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

21

主题

2205

帖子

0

精华

资深版主

Rank: 8Rank: 8

积分
5141
金钱
5141
注册时间
2014-8-26
在线时间
1317 小时
发表于 2019-3-28 16:47:31 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-23 22:56

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表