GPIO 唤醒深度睡眠的esp32-c3

经实验,led 必须接入c3 的gpio 20,21 脚,接入0-10脚led不亮。1脚接高电平,led亮,断开,led灭。特别注意,c3 刷入代码后,要按an键退出下载模式单片机才能正常运行。

开启程序的定时唤醒功能,led周期性隔5秒点亮一次。

代码

复制代码
#include <stdio.h>
#include "esp_sleep.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"

#define LED 21          //led 不能接入0-10脚
#define AJ  1
void app_main(void) {
    // 配置 LED GPIO 为输出模式   gpio 0 脚为1,led 亮
    gpio_config_t io_conf;
    io_conf.intr_type = GPIO_INTR_DISABLE;
    io_conf.mode = GPIO_MODE_OUTPUT;
    io_conf.pin_bit_mask = (1ULL << LED);
    io_conf.pull_down_en = 0;
    io_conf.pull_up_en = 0;
    gpio_config(&io_conf);

     
    //配置唤醒源
    gpio_deep_sleep_hold_dis();	    //在深度睡眠时禁用所有数字gpio pad保持功能。
    esp_deep_sleep_enable_gpio_wakeup((1ULL<<AJ), ESP_GPIO_WAKEUP_GPIO_HIGH); //high
    gpio_set_direction(GPIO_NUM_1, GPIO_MODE_INPUT);	//GPIO定向,设置为输入或输出
	 
 //   esp_sleep_enable_timer_wakeup(5 * 1000000);
	
   //开始睡眠
    esp_deep_sleep_start();
    // 深度睡眠后代码将不会继续执行
	
    gpio_set_level(LED,1);
}
相关推荐
单片机系统设计1 小时前
基于stm32的环境监测系统/智能家居/空气质量监测系统
stm32·单片机·嵌入式硬件·毕业设计·智能家居
不知所云,2 小时前
5. STM32 时钟系统分配
stm32·单片机·嵌入式硬件
电子科技圈3 小时前
芯科科技FG23L无线SoC现已全面供货,为Sub-GHz物联网应用提供最佳性价比
科技·嵌入式硬件·mcu·物联网·制造·智能硬件·交通物流
天天爱吃肉82184 小时前
【比亚迪璇玑架构深度解析:重新定义智能电动汽车的“整车智能”】
数据库·人工智能·嵌入式硬件·架构·汽车
糖糖单片机设计4 小时前
硬件开发_基于物联网的沼气池环境监测系统
stm32·单片机·嵌入式硬件·物联网·51单片机
沐欣工作室_lvyiyi6 小时前
基于单片机的全自动洗衣机控制系统(论文+源码)
stm32·单片机·嵌入式硬件·毕业设计
The️6 小时前
STM32-FreeRTOS操作系统-二值信号量与计数信号量
arm开发·stm32·单片机·嵌入式硬件·物联网
如愿小李6 小时前
STM32之水质浑浊度传感器模块
stm32·单片机·嵌入式硬件
GilgameshJSS8 小时前
【学习K230-例程21】GT6700-UDP-Client
网络·python·单片机·网络协议·学习·udp