EasyManua.ls Logo

DFRobot FIREBEETLE BOARD-ESP32 - Page 47

DFRobot FIREBEETLE BOARD-ESP32
49 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Welcome to DFRobot: www.DFRobot.com.cn 47 / 49
Code analysis
The example used ESP.deepSleep which has been encapsulated by the Arduino libraries. So there
is no need to allocate extra sleep mode. The antitype function is as below:
void deepSleep(uint32_t time_us)
The parameter been passed is uint32_t type of data, value of time setting. The unit of it is μs
(microsecond).
In the sample program, let FireBeetle Board-ESP32 sleep and restart in 5 seconds, you can see L
LED light of the FireBeetle Board-ESP32 flash in every 5 seconds.
Enter code (2)
Open Arduino IDE. You would better enter the code manually than open Course-> Item-9-2 to be
familiar with it.
Sample code:
void setup() {
// put your setup code here, to run once:
pinMode(D9,OUTPUT);
digitalWrite(D9,HIGH);
delay(1000);
digitalWrite(D9,LOW);
esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_25,LOW);
esp_deep_sleep_start();
}
void loop() {
// put your main code here, to run repeatedly:
}
Please click verify/compile to review and please upload it after the confirmation.
Once you click Upload, IDE will send codes to FireBeetle Board-ESP32.
Code analysis
Different from the way realized in Item-9-1, here the FireBeetle Board-ESP32 keep in sleep, you
should take external interrupt to awake the motherboard and set GPIO25 into awaking interface
of low lever interruption.
esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_25,LOW);