英飞凌PSoC62 实现超低功耗温湿度计

描述

英飞凌PSoC62是一款Cortex-M0+与Cortex-M4的双内核MCU,其有着非常优秀的超低功耗性能。

温度计的器材

  1. 英飞凌PSoC62开发板 这是一款英飞凌与RT-Thread联合制作的一款开发板。
  2. 瑞萨的hs3003温湿度传感器
  3. 电子墨水屏

选型原因

以上三款都具休有超过功耗性能

程序代码

  1. 本次的代码是基于RT-Thread Studio创建的。
  2. 电子墨水屏是移植微雪的标准例程。这里不过多介绍。
  3. hs3003是利用rtt软件包的模块创建。
  4. 低耗实现的代码,MCU利用Cortex-M0+的标准进入深度睡眠模式。然后用RTC的ALARM中断来唤醒。设置的唤醒程序如下:
void set_rtc_alarm_date_time(void)
{
    cy_rslt_t result;

    /* Print the RTC alarm time by UART */
    //LOG_D("RTC alarm will be generated after 10 seconds
");
    /* Set the RTC alarm for the specified number of seconds in the future by editing the macro(USE_SECONDS_FOR_ALARM) */
    result = cyhal_rtc_set_alarm_by_seconds(&rtc_obj, USE_SECONDS_FOR_ALARM);
    if (result != CY_RSLT_SUCCESS)
    {
        rt_kprintf("RTC alarm err 
");
    }
}

5、主程序代码:

int main(void)
{
    cy_rslt_t result;
    float temp, humi;
    uint8_t show_str[20] = {0};
    EPD_GPIO_Init();       //EPD GPIO  initialization
    //Cy_SysDisableCM4();
    __enable_irq();
    rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
  //  rt_thread_mdelay(500);
    Paint_NewImage(BlackImage, 128, 296, 270, WHITE); //Set screen size and display orientation
    Paint_SelectImage(BlackImage);//Set the virtual canvas data storage location

    Paint_NewImage(BlackImage, EPD_WIDTH, EPD_HEIGHT, 270, WHITE); //Set screen size and display orientation
    Paint_SelectImage(BlackImage);//Set the virtual canvas data storage location
    EPD_DeepSleep();


    /* Initialize RTC */

    cyhal_rtc_enable_event(&rtc_obj, CYHAL_RTC_ALARM, RTC_INTERRUPT_PRIORITY, true);
    set_rtc_alarm_date_time();
    for (;;)
    {


      //  cyhal_system_delay_ms(LONG_GLITCH_DELAY_MS);
        /* Set MYPIN_0_NUM to Analog HI-Z for low power using HAL APIs. */


//        /* Go to deep sleep */

        cyhal_syspm_deepsleep();

        set_rtc_alarm_date_time();
 //       rt_kprintf("Wack from sleep!
");
        hs300x_read_data(&temp_humi_dev, &humi, &temp);
        EPD_HW_Init(); //Electronic paper initialization
        EPD_HW_Init_GUI(); //EPD init GUI
        Paint_Clear(WHITE);
        sprintf(show_str,"温度%02d.%02d℃",(int)temp, (int)(temp*100)%100);
        Paint_DrawString_CN(40,0,show_str, &Font24CN, WHITE, BLACK);
        sprintf(show_str,"湿度%02d.%02d%%",(int)humi, (int)(humi*100)%100);
        Paint_DrawString_CN(40,40,show_str, &Font24CN, WHITE, BLACK);
        EPD_Display(BlackImage); //display image
        EPD_DeepSleep();//EPD_DeepSleep,Sleep instruction is necessary, please do not delete!!!



    }
}

实验的效果

NB-IoT

经调试休眠模式下,整体的待机电流低到450uA:

NB-IoT

工作电流为19mA:

NB-IoT

总结

目前待机电流基本上达到电池供电的效果,后期再加上NB-IoT的数据传输模式。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分