Video implementing a ul p ko process of wake up from deep sleep in the ESP 32. In this video, we will learn in depth on implementing the UL Pico process of wakeup in the Arduino ID by understanding the function of the main core code and the header code. We will continue with the example code we showed in the earlier video. Open the UL p underscore ATC dot INF file in the Arduino it you can see that the project has automatically loaded all the other files related to the main code. First, let me explain what this whole mini project does. The you will Pico processor reads voltage values with an ADC and averages the results.
If this value is below a certain low threshold, the LED will be off. If it's between the two threshold values the LED is on if it's about the higher threshold value Then it will make up the main course, and it will then print the ADC values on the serial monitor. Coming back to the code. Let's just quickly go through the main core code. Just like the previous deep sleep implementations, all the magic happens in the setup function. All main codes with LP implementation must have the following header files for it to work.
They are one, ESP underscore sleep dot h, two ESP 32 forward slash ul p dot h and three you will be underscore main dot hedge in this code. We have also added the RTC underscore IO dot hedge an ADC dot hedge. These are included to access and use the ADC in RTC GPIO pins. Remember that during deep sleep, we can only use the RTC GPIO pins and not the GPIO pins of the main board. Each up program is embedded inside the main core program like a binary chunk. As far as the main code is concerned, the you will pay program is just another binary buffer, which needs to be loaded to the artists in memory for the up core processor to access and execute does to keep track of the start and end address of the USB program binary, we use the following two instructions.
Next, we define and assign the GPIO pins which we want to use for this project. Inside the setup loop right after the boot, the ESP 32 main code has to confirm whether the USB coprocessor caused the wakeup or not. This is done by using the following function. The conditional statement checks the reason for wake up and if it was not working up, but you will pay then it will initialize that you will pay program by using the internet underscore ULP underscore program function. But if the wakeup is caused by the you will pay coprocessor it means that the you will be coprocessor has detected the ADC value to be more than the higher threshold. In this condition, we need to print the ADC values on the serial monitor.
The following instructions will show the count of measurements by you LP, the low and high threshold value and the value which went above the threshold that caused the main core to wake up in the first place. Next, we need to start that up program before the main cost go to sleep so that the coprocessor can keep on taking measurements. Next, by using this single line of instruction, we enable the up wakeup as well as check for errors on implementing the up wakeup. At the end of the setup loop. We start at the deep sleep. Conceptually, this is the end of the code The loop function is empty.
Now let's discuss about the function definitions of the init underscore evil p underscore program function. And the start underscore user underscore program function in the init underscore up underscore program function. First we have loaded that you will be binary code to the artists in memory that you will be underscore load underscore binary function accepts three input parameters. The first parameter is the RTC memory address to which the up binary should be uploaded. The second parameter is the starting ad resolve that you will be binary stored in the main memory and the final parameter is the size of the UEFI binary code. After the error check is done.
These instructions configure the GPIO pins 27 and 13 as RTC GPIO output. Now we will configure the ADC channel by configuring the GPIO pin mux and setting the activation of a particular channel on ADC one later, the ADC bit width is set an ADC for you LP is enabled. Next, we set the lower threshold as one volt and higher threshold as to volts. We also said that you will be wakeup period as 100 milliseconds. The start underscore ul p underscore program function uses a function named u LP underscore run. To run the UL PE binary program loaded into the artist in memory.
It accepts only a single parameter that is the entry point of the program expressed in 32 bit words. The explanation of the main core code is done. Now let's look at the URL p underscore main dot h header code. This consists of the Arduino dot h library and all The variables, which can be shared between the up code and the main sketch for transferring the ADC measurements to the main core once it's woken up summary In this video we have covered the following topics, explanation of the ADC voltage measurement project, understanding the main core code and the header code in new LP core processor programming. In the next video, we take an in depth look at assembly level code for the up core processor in the ESP 32.