【资料图】
英飞凌PSoC62是一款Cortex-M0+与Cortex-M4的双内核MCU,其有着非常优秀的超低功耗性能。
温度计的器材
英飞凌PSoC62开发板 这是一款英飞凌与RT-Thread联合制作的一款开发板。瑞萨的hs3003温湿度传感器电子墨水屏选型原因
以上三款都具休有超过功耗性能
程序代码
本次的代码是基于RT-Thread Studio创建的。电子墨水屏是移植微雪的标准例程。这里不过多介绍。hs3003是利用rtt软件包的模块创建。低耗实现的代码,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\\r\\n"); /* 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 \\r\\n"); }}
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 AnalogHI-Z for low power using HAL APIs. */// /* Go to deep sleep */ cyhal_syspm_deepsleep(); set_rtc_alarm_date_time(); // rt_kprintf("Wack from sleep!\\r\\n"); 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!!! }}
实验的效果
经调试休眠模式下,整体的待机电流低到450uA:
工作电流为19mA:
总结
目前待机电流基本上达到电池供电的效果,后期再加上NB-IoT的数据传输模式。https://www.bilibili.com/video/BV1bP411X7vP/?pop_share=1