-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnvs_example.html
284 lines (253 loc) · 17.4 KB
/
nvs_example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NVS Example - ESP32 - — ESPP main documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
<script src="_static/js/theme.js"></script>
<script type="text/javascript">
DOCUMENTATION_OPTIONS.PAGENAME = 'nvs_example';
DOCUMENTATION_OPTIONS.PROJECT_SLUG = 'esp-cpp';
DOCUMENTATION_OPTIONS.LATEST_BRANCH_NAME = 'master';
DOCUMENTATION_OPTIONS.VERSIONS_URL = 'https://dl.espressif.com/dl/esp-idf/idf_versions.js';
DOCUMENTATION_OPTIONS.LANGUAGES = ["en"];
DOCUMENTATION_OPTIONS.IDF_TARGET = 'esp32';
DOCUMENTATION_OPTIONS.HAS_IDF_TARGETS = ["esp32", "esp32s2", "esp32c3"]
DOCUMENTATION_OPTIONS.RELEASE = 'main';
</script>
<script type="text/javascript" src="https://dl.espressif.com/dl/esp-idf/idf_versions.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="PID APIs" href="pid.html" />
<link rel="prev" title="NVS APIs" href="nvs.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> ESPP
<img src="_static/espressif-logo.svg" class="logo" alt="Logo"/>
</a>
<div class="selectors">
<select id="target-select" style="width: 150px;" hidden>
<option value="" disabled selected>Choose target...</option>
</select>
</div>
<div class="selectors">
<select id="version-select" style="width: 150px;" hidden>
<option value="" disabled selected>Choose version...</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="adc/index.html">ADC APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="base_component.html">Base Compoenent</a></li>
<li class="toctree-l1"><a class="reference internal" href="base_peripheral.html">Base Peripheral</a></li>
<li class="toctree-l1"><a class="reference internal" href="battery/index.html">Battery APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="bldc/index.html">BLDC APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="ble/index.html">BLE APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="button.html">Button APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="controller.html">Controller APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli.html">Command Line Interface (CLI) APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="color.html">Color APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="csv.html">CSV APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="display/index.html">Display APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="encoder/index.html">Encoder APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="esp32_timer_cam.html">ESP32 TimerCam</a></li>
<li class="toctree-l1"><a class="reference internal" href="esp_box.html">ESP BOX</a></li>
<li class="toctree-l1"><a class="reference internal" href="event_manager.html">Event Manager APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="file_system.html">File System APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="filters/index.html">Filter APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="ftp/index.html">FTP APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="haptics/index.html">Haptics APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="hid/index.html">HID APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="i2c.html">I2C</a></li>
<li class="toctree-l1"><a class="reference internal" href="imu/index.html">IMU APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="interrupt.html">Interrupt APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="input/index.html">Input APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="io_expander/index.html">IO Expander APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="joystick.html">Joystick APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="led.html">LED APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="led_strip.html">LED Strip APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="logger.html">Logging APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="monitor.html">Monitoring APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="motorgo_mini.html">MotorGo Mini</a></li>
<li class="toctree-l1"><a class="reference internal" href="math/index.html">Math APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="matouch_rotary_display.html">MaTouch Rotary Display</a></li>
<li class="toctree-l1"><a class="reference internal" href="neopixel.html">Neopixel APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="network/index.html">Network APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="nfc/index.html">NFC APIs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="nvs.html">NVS APIs</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="nvs.html#nvs">NVS</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="nvs.html#nvshandle">NVSHandle</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">NVS Example</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#how-to-use-example">How to use example</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nvs-example-output">NVS Example Output</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nvshandle-example-output">NVSHandle Example Output</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="nvs.html#api-reference">API Reference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pid.html">PID APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="qtpy.html">QtPy ESP32 Pico and QtPy ESP32-S3</a></li>
<li class="toctree-l1"><a class="reference internal" href="qwiicnes.html">QwiicNES</a></li>
<li class="toctree-l1"><a class="reference internal" href="rmt.html">Remote Control Transceiver (RMT)</a></li>
<li class="toctree-l1"><a class="reference internal" href="rtc/index.html">RTC APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="rtsp.html">RTSP APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="runqueue.html">RunQueue APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="seeed_studio_round_display.html">Seeed Studio Round Display</a></li>
<li class="toctree-l1"><a class="reference internal" href="serialization.html">Serialization APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="state_machine.html">State Machine APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="t_deck.html">LilyGo T-Deck</a></li>
<li class="toctree-l1"><a class="reference internal" href="t_dongle_s3.html">LilyGo T-Dongle S3</a></li>
<li class="toctree-l1"><a class="reference internal" href="tabulate.html">Tabulate APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="task.html">Task APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="thermistor.html">Thermistor APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="timer.html">Timer APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="wifi/index.html">WiFi APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="wrover_kit.html">ESP32-WROVER-KIT</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">ESPP</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li><a href="nvs.html">NVS APIs</a> »</li>
<li>NVS Example</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/esp-cpp/espp/blob/582c61e0/docs/en/nvs_example.md" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="nvs-example">
<h1>NVS Example<a class="headerlink" href="#nvs-example" title="Permalink to this headline"></a></h1>
<p>This example shows the use of the <code class="docutils literal notranslate"><span class="pre">NVS</span></code> component to save a variable to the NVS and load
it after reset.</p>
<section id="how-to-use-example">
<h2>How to use example<a class="headerlink" href="#how-to-use-example" title="Permalink to this headline"></a></h2>
<p>The example outputs a log that counts up the number of times the system has been reset
since the NVS was last cleared.</p>
<section id="build-and-flash">
<h3>Build and Flash<a class="headerlink" href="#build-and-flash" title="Permalink to this headline"></a></h3>
<p>Build the project and flash it to the board, then run monitor tool to view serial output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">idf</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">p</span> <span class="n">PORT</span> <span class="n">flash</span> <span class="n">monitor</span>
</pre></div>
</div>
<p>(Replace PORT with the name of the serial port to use.)</p>
<p>(To exit the serial monitor, type <code class="docutils literal notranslate"><span class="pre">Ctrl-]</span></code>.)</p>
<p>See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.</p>
</section>
</section>
<section id="nvs-example-output">
<h2>NVS Example Output<a class="headerlink" href="#nvs-example-output" title="Permalink to this headline"></a></h2>
<p><img alt="CleanShot 2024-05-18 at 12 54 46" src="https://github.com/esp-cpp/espp/assets/213467/60b2db2f-8796-4ae3-9a8c-51f69fa21911" />
<img alt="CleanShot 2024-05-18 at 12 54 54" src="https://github.com/esp-cpp/espp/assets/213467/ddceddbf-0690-4590-93b6-66cf91ad1898" />
<img alt="CleanShot 2024-05-18 at 12 55 02" src="https://github.com/esp-cpp/espp/assets/213467/1181fc79-f7bd-4b1d-b351-e5ca24ee7c55" /></p>
</section>
<section id="nvshandle-example-output">
<h2>NVSHandle Example Output<a class="headerlink" href="#nvshandle-example-output" title="Permalink to this headline"></a></h2>
<p>First run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Opening Non-Volatile Storage (NVS) handle... Done
Reading restart counter from NVS ... [NVSHandle/E][0.061]: The value is not initialized in NVS, key = 'restart_counter'
The value is not initialized yet!
Updating restart counter in NVS ... Done
Committing updates in NVS ... Done
Restarting in 10 seconds...
Restarting in 9 seconds...
Restarting in 8 seconds...
Restarting in 7 seconds...
Restarting in 6 seconds...
Restarting in 5 seconds...
Restarting in 4 seconds...
Restarting in 3 seconds...
Restarting in 2 seconds...
Restarting in 1 seconds...
Restarting in 0 seconds...
Restarting now.
</pre></div>
</div>
<p>Subsequent runs:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Opening</span> <span class="n">Non</span><span class="o">-</span><span class="n">Volatile</span> <span class="n">Storage</span> <span class="p">(</span><span class="n">NVS</span><span class="p">)</span> <span class="n">handle</span><span class="o">...</span> <span class="n">Done</span>
<span class="n">Reading</span> <span class="n">restart</span> <span class="n">counter</span> <span class="kn">from</span><span class="w"> </span><span class="nn">NVS</span> <span class="o">...</span> <span class="n">Done</span>
<span class="n">Restart</span> <span class="n">counter</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">Updating</span> <span class="n">restart</span> <span class="n">counter</span> <span class="ow">in</span> <span class="n">NVS</span> <span class="o">...</span> <span class="n">Done</span>
<span class="n">Committing</span> <span class="n">updates</span> <span class="ow">in</span> <span class="n">NVS</span> <span class="o">...</span> <span class="n">Done</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">10</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">9</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">8</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">7</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">6</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">5</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">4</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">3</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">2</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">1</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="ow">in</span> <span class="mi">0</span> <span class="n">seconds</span><span class="o">...</span>
<span class="n">Restarting</span> <span class="n">now</span><span class="o">.</span>
</pre></div>
</div>
<p>Restart counter will increment on each run.</p>
<p>To reset the counter, erase the contents of flash memory using <code class="docutils literal notranslate"><span class="pre">idf.py</span> <span class="pre">erase-flash</span></code>, then upload the program again as described above.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="nvs.html" class="btn btn-neutral float-left" title="NVS APIs" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="pid.html" class="btn btn-neutral float-right" title="PID APIs" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2022 - 2025, William Emfinger.</p>
</div>
<ul class="footer">
<li>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/espressif/sphinx_idf_theme">theme</a> based on <a href="https://github.com/readthedocs/sphinx_rtd_theme">Read the Docs Sphinx Theme</a>.
</li>
</ul>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>