1
00:00:01,320 --> 00:00:08,670
In a previous lecture, they learned how to control the C.P.U clock frequency of your E.S.P 32, and

2
00:00:08,670 --> 00:00:14,580
that is a way to reduce the power consumption of your microcontroller, which is particularly useful

3
00:00:14,580 --> 00:00:17,710
when you are powering a gadget from a battery.

4
00:00:18,210 --> 00:00:24,420
In this lecture, I'm going to show you an additional method of reducing power consumption, and that

5
00:00:24,420 --> 00:00:30,940
is by putting your attitude to sleep when it's not needed to do any useful work.

6
00:00:31,230 --> 00:00:39,120
So while the of two is sleeping, of course, its power consumption is much reduced according to the

7
00:00:39,120 --> 00:00:40,480
documentation.

8
00:00:40,500 --> 00:00:41,730
So we'll look at it here.

9
00:00:42,000 --> 00:00:47,970
And I'm looking now at the quick reference for the ESB 32 in the Micro Python or Jaedicke accommodation.

10
00:00:47,970 --> 00:00:50,100
You go down to deep sleep mode.

11
00:00:50,520 --> 00:00:56,630
You see that there is a way here to place the microcontroller to deep sleep.

12
00:00:57,000 --> 00:00:59,040
It can never do that indefinitely.

13
00:00:59,040 --> 00:01:04,950
So if you don't provide a parameter here, then the microcontroller is going to be sleeping until you

14
00:01:04,950 --> 00:01:05,580
reset it.

15
00:01:06,150 --> 00:01:12,300
Or you can give it an amount of time in milliseconds and it's going to be in deep sleep in this case

16
00:01:12,540 --> 00:01:19,350
for that amount of milliseconds and then reset itself if it's coming back from deep sleep and resume

17
00:01:19,350 --> 00:01:20,230
its operation.

18
00:01:20,820 --> 00:01:25,100
So there is also another type of sleep that is possible.

19
00:01:25,110 --> 00:01:33,120
So if you have a look at again, looking at macro python org under the machine module, you'll see that

20
00:01:33,120 --> 00:01:35,090
there are power related functions.

21
00:01:35,550 --> 00:01:41,920
And apart from deep sleep, there's also light sleep option, which I have tested with the ease with

22
00:01:41,950 --> 00:01:46,430
the data and it seems to be working properly with light sleep.

23
00:01:47,130 --> 00:01:50,070
The MCU is not turned off.

24
00:01:50,660 --> 00:01:56,730
Simply several of its subsystems are powered off, but other parts are still operating.

25
00:01:56,910 --> 00:02:00,470
In particular, the RAM is not wiped out.

26
00:02:00,480 --> 00:02:06,470
So that means that after a soft reset, your program can continue operating.

27
00:02:06,480 --> 00:02:10,100
So that's the biggest difference between light sleep and deep sleep.

28
00:02:10,590 --> 00:02:15,770
There's information, of course, here about the difference between these two sleep modes, and this

29
00:02:15,780 --> 00:02:23,310
further information is specific to the ESB through to here, good to the IF documentation website,

30
00:02:23,490 --> 00:02:29,760
and that is be free to look for the sleep mode so you can search for it or can follow the link that

31
00:02:29,760 --> 00:02:35,820
I have provided here in the head of this, which is this link right here.

32
00:02:36,450 --> 00:02:43,770
And that will give you detailed information about which parts of the market controller continue to operate

33
00:02:43,770 --> 00:02:49,110
or which ones are powered down when you enter one type of sleep or the other.

34
00:02:50,060 --> 00:02:59,270
OK, now I want to do a demonstration of these two sleep modes first on the shell, and then I am going

35
00:02:59,270 --> 00:03:09,260
to copy my test program into the beta profile so that I can power my is be two from my power supply

36
00:03:09,260 --> 00:03:15,800
and use my alma mater to measure the actual power consumption in these two different sleep modes.

37
00:03:16,490 --> 00:03:21,560
So first, what I do have already connected my eyes with the idea of the shopfront here.

38
00:03:22,010 --> 00:03:24,560
I will import machine.

39
00:03:25,900 --> 00:03:33,580
So I can access the notes and the first type of sleep that I'm going to test this landslip, so I'm

40
00:03:33,580 --> 00:03:38,950
going to copy this comment here and pasted in the schill and enter.

41
00:03:40,290 --> 00:03:48,240
And as you can see, the security went to sleep for about a second, and that's why we've got a delay

42
00:03:48,240 --> 00:03:51,870
in the prompt appearing again and then it came out of sleep.

43
00:03:52,260 --> 00:03:53,730
Now, the interesting thing is this.

44
00:03:54,370 --> 00:03:56,910
I remember that I've imported the machine.

45
00:03:57,120 --> 00:04:06,900
I'm going to use this comment here now to check on the type of sleep that the security just woke up

46
00:04:06,900 --> 00:04:07,290
from.

47
00:04:08,160 --> 00:04:09,240
And that is No.

48
00:04:09,240 --> 00:04:10,110
Four, right.

49
00:04:10,170 --> 00:04:11,630
So let's check this out.

50
00:04:11,640 --> 00:04:13,410
What is sleep number four?

51
00:04:13,930 --> 00:04:17,430
Go into machine functions and the constant here.

52
00:04:17,700 --> 00:04:25,680
You'll see these are the reset quarters and this is zero one, two, three, four, which means that

53
00:04:26,010 --> 00:04:31,080
especially to reset course was not before it was soft reset.

54
00:04:31,380 --> 00:04:39,210
So in other words, when you put your E.S.P three, two, two into the light sleep, then after that

55
00:04:39,210 --> 00:04:47,790
comes back from a sleep, in this case 1000 milliseconds, then light sleeper will cause a soft reset

56
00:04:47,790 --> 00:04:51,870
to itself so that it can then resume its operation.

57
00:04:52,980 --> 00:04:58,110
If, on the other hand, I'll go for a deep sleep, which can go for deep sleep, Klickitat.

58
00:05:00,370 --> 00:05:01,480
Paste that across.

59
00:05:02,380 --> 00:05:08,650
I just wanted to point to that, that I was able to do actually work so work to get the reset course

60
00:05:09,010 --> 00:05:15,190
because the ram was not wiped out and the machine module was still imported.

61
00:05:15,550 --> 00:05:18,280
Now, look at what happens with a deep sleep.

62
00:05:18,280 --> 00:05:22,530
So deep sleep for 10000 milliseconds, about 10 seconds.

63
00:05:22,540 --> 00:05:29,830
So the longer the prompt is gone, I especially do is deeply sleeping now.

64
00:05:33,120 --> 00:05:41,610
And 10 seconds later, you see that we've got a deep sleep reset, which is similar to just pressing

65
00:05:41,610 --> 00:05:46,710
on the reset button manually, if I try to call for a.

66
00:05:47,990 --> 00:05:54,560
Try to check the reset course like this, you see that the machine launched is not defined.

67
00:05:54,640 --> 00:05:56,900
I have to first imported.

68
00:05:58,290 --> 00:06:03,490
Because the rain was wiped out, essentially, the program will start operating from scratch if it was

69
00:06:03,510 --> 00:06:05,270
actually deploy program.

70
00:06:05,730 --> 00:06:12,270
So important machine now to take the risk, of course, you see, it's no full to actually be surprised.

71
00:06:12,270 --> 00:06:13,290
That should have been.

72
00:06:16,110 --> 00:06:20,010
Probably deep sleep research zero one, two, three should be three.

73
00:06:20,630 --> 00:06:22,250
So I'm going to do this one more time.

74
00:06:25,090 --> 00:06:26,440
Go for sleep, deep sleep.

75
00:06:26,770 --> 00:06:28,680
Can you make that one second this time?

76
00:06:31,070 --> 00:06:42,740
OK, recent import the machine module and check it recept course for interesting, I'm going to do a

77
00:06:43,340 --> 00:06:46,100
hard reset and just by pressing the reset button.

78
00:06:47,890 --> 00:06:51,090
Can see this type is power on the reset.

79
00:06:52,250 --> 00:07:00,500
And of course, I try this the machine isn't Defitelio to import machine first and then check the course

80
00:07:00,770 --> 00:07:04,200
and this one is going to be number one, right?

81
00:07:04,820 --> 00:07:06,470
Dimethyltryptamine, forgiveness.

82
00:07:06,520 --> 00:07:08,710
No one is a hard reset.

83
00:07:09,320 --> 00:07:14,690
So that's how you can check on what was it that caused the reset.

84
00:07:15,260 --> 00:07:21,900
I'm not sure why the report here for the reset course.

85
00:07:22,250 --> 00:07:30,740
It remains to be for after I have done a deep sleep, but I've got to think about that.

86
00:07:31,470 --> 00:07:35,630
I've done a bit of testing that earlier and it seemed to be working properly.

87
00:07:35,630 --> 00:07:43,490
But just keep that in mind that the report coming back from the reset cause function may not differentiate

88
00:07:43,490 --> 00:07:46,450
between light sleep and deep sleep.
