Skip to content

Commit 4aa642d

Browse files
committed
document 01-IOT
Add build/flash/provision and behavior information to the readme for app 01-IOT. Signed-off-by: Mike Szczys <[email protected]>
1 parent b0ceb69 commit 4aa642d

File tree

2 files changed

+135
-201
lines changed

2 files changed

+135
-201
lines changed

01_IOT/README.rst

Lines changed: 135 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1,226 +1,160 @@
1-
.. _wifi_station_sample:
2-
3-
Wi-Fi: Station
1+
Section 1: IoT
42
##############
53

6-
.. contents::
7-
:local:
8-
:depth: 2
9-
10-
The Station sample demonstrates how to connect the Wi-Fi® station to a specified access point using Dynamic Host Configuration Protocol (DHCP).
11-
12-
Requirements
13-
************
4+
The IoT sample demonstrates an IoT device that connects to WiFi and Golioth,
5+
then sends data, logs, and reacts to remote-procedure calls. Using this sample
6+
code you will learn about:
147

15-
The sample supports the following development kit:
8+
* Building and flashing applications in Zephyr
9+
* Adding persistent credentials using the serial shell
10+
* Get to know the Golioth web console:
11+
* Time-series and stateful data reported to the cloud
12+
* Adjusting device settings using the cloud-side Settings service
13+
* Receiving remote logging information from the device
14+
* Using remote procedure call (RPC) to return current WiFi connection info
1615

17-
.. table-from-sample-yaml::
16+
Hardware: Nordic nRF7002-DK
17+
***************************
1818

19-
Overview
20-
********
19+
This demonstrates how to interact with the `Golioth Cloud`_ using `Zephyr`_ on the
20+
`Nordic nRF7002 Development Kit`_.
2121

22-
This sample can perform Wi-Fi operations such as connect and disconnect in the 2.4GHz and 5GHz bands depending on the capabilities of an access point.
2322

24-
Using this sample, the development kit can connect to the specified access point in :abbr:`STA (Station)` mode.
23+
Build Instructions
24+
******************
2525

26-
User interface
27-
**************
28-
The sample adds LED support to map with connection and disconnection events.
26+
Prerequisites
27+
=============
2928

30-
LED 1:
31-
Starts blinking when the sample is connected to the access point.
29+
Follow the README in the root of this repository to install a
30+
virtual environment and use `west init`/`west update` to clone all dependencies.
31+
Remember to restart your virtual environment when beginning a new terminal
32+
session.
3233

33-
Stops blinking when the sample is disconnected from the access point.
3434

35-
Quad Serial Peripheral Interface (QSPI) encryption
36-
**************************************************
35+
Build project
36+
=============
3737

38-
This sample demonstrates QSPI encryption API usage.
39-
The key can be set by the :kconfig:option:`CONFIG_NRF700X_QSPI_ENCRYPTION_KEY` Kconfig option.
38+
From the root directory of this repository, build using the following command:
4039

41-
If encryption of the QSPI traffic is required for the production devices, then matching keys must be programmed in both the nRF7002 OTP and non-volatile storage associated with the host.
42-
The key from non-volatile storage must be set as the encryption key using the APIs.
40+
.. code-block:: bash
4341
44-
Power management
45-
****************
42+
$ (.venv) west build -b nrf7002dk_nrf5340_cpuapp 01_IOT
4643
47-
This sample also enables Zephyr's power management policy by default, which puts the nRF5340 :term:`System on Chip (SoC)` into low-power mode whenever it is idle.
48-
See :ref:`zephyr:pm-guide` in the Zephyr documentation for more information on power management.
44+
Flash project
45+
=============
4946

50-
IP addressing
51-
*************
52-
The sample uses DHCP to obtain an IP address for the Wi-Fi interface. It starts with a default static IP address to handle networks without DHCP servers, or if the DHCP server is not available.
53-
Successful DHCP handshake will override the default static IP configuration.
47+
Plug the nRF7002-DK into the USB port on the short edge of the board. (Do not
48+
use the USB port labelled `nRF USB`.) Run the following command:
5449

55-
The following static configuration is by default and can be changed in the ``prj.conf`` file:
50+
.. code-block:: bash
5651
57-
.. code-block:: console
52+
$ (.venv) west flash
5853
59-
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.98"
60-
CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
61-
CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"
54+
Add credentials
55+
===============
6256

63-
Building and running
64-
********************
65-
66-
.. |sample path| replace:: :file:`samples/wifi/sta`
67-
68-
.. include:: /includes/build_and_run_ns.txt
69-
70-
Currently, the following board(s) are supported:
71-
72-
* nRF7002 DK
73-
74-
You must configure the following Wi-Fi credentials in ``prj.conf``:
75-
76-
* Network name (SSID)
77-
* Key management
78-
* Password
79-
80-
.. note::
81-
You can also use ``menuconfig`` to enable ``Key management`` option.
82-
83-
See :ref:`zephyr:menuconfig` in the Zephyr documentation for instructions on how to run ``menuconfig``.
84-
85-
To build for the nRF7002 DK, use the ``nrf7002dk_nrf5340_cpuapp`` build target.
86-
The following is an example of the CLI command:
87-
88-
.. code-block:: console
89-
90-
west build -b nrf7002dk_nrf5340_cpuapp
91-
92-
Testing
93-
=======
94-
95-
|test_sample|
96-
97-
#. |connect_kit|
98-
#. |connect_terminal|
99-
100-
The sample shows the following output:
101-
102-
.. code-block:: console
103-
104-
[00:00:02.016,235] <inf> sta: Connection requested
105-
[00:00:02.316,314] <inf> sta: ==================
106-
[00:00:02.316,314] <inf> sta: State: SCANNING
107-
[00:00:02.616,424] <inf> sta: ==================
108-
[00:00:02.616,424] <inf> sta: State: SCANNING
109-
[00:00:02.916,534] <inf> sta: ==================
110-
[00:00:02.916,534] <inf> sta: State: SCANNING
111-
[00:00:03.216,613] <inf> sta: ==================
112-
[00:00:03.216,613] <inf> sta: State: SCANNING
113-
[00:00:03.516,723] <inf> sta: ==================
114-
[00:00:03.516,723] <inf> sta: State: SCANNING
115-
[00:00:03.816,802] <inf> sta: ==================
116-
[00:00:03.816,802] <inf> sta: State: SCANNING
117-
[00:00:04.116,882] <inf> sta: ==================
118-
[00:00:04.116,882] <inf> sta: State: SCANNING
119-
[00:00:04.416,961] <inf> sta: ==================
120-
[00:00:04.416,961] <inf> sta: State: SCANNING
121-
[00:00:04.717,071] <inf> sta: ==================
122-
[00:00:04.717,071] <inf> sta: State: SCANNING
123-
[00:00:05.017,150] <inf> sta: ==================
124-
[00:00:05.017,150] <inf> sta: State: SCANNING
125-
[00:00:05.317,230] <inf> sta: ==================
126-
[00:00:05.317,230] <inf> sta: State: SCANNING
127-
[00:00:05.617,309] <inf> sta: ==================
128-
[00:00:05.617,309] <inf> sta: State: SCANNING
129-
[00:00:05.917,419] <inf> sta: ==================
130-
[00:00:05.917,419] <inf> sta: State: SCANNING
131-
[00:00:06.217,529] <inf> sta: ==================
132-
[00:00:06.217,529] <inf> sta: State: SCANNING
133-
[00:00:06.517,639] <inf> sta: ==================
134-
[00:00:06.517,639] <inf> sta: State: SCANNING
135-
[00:00:06.817,749] <inf> sta: ==================
136-
[00:00:06.817,749] <inf> sta: State: SCANNING
137-
[00:00:07.117,858] <inf> sta: ==================
138-
[00:00:07.117,858] <inf> sta: State: SCANNING
139-
[00:00:07.336,730] <inf> wpa_supp: wlan0: SME: Trying to authenticate with aa:bb:cc:dd:ee:ff (SSID='<MySSID>' freq=5785 MHz)
140-
[00:00:07.353,027] <inf> wifi_nrf: wifi_nrf_wpa_supp_authenticate:Authentication request sent successfully
57+
Two serial ports will enumerate on your system. Use a serial terminal program to
58+
connect to the higher numbered serial port using 115200 8N1 as the settings. Use
59+
the following syntax to store your WiFi and Golioth credentials on the device:
14160

142-
[00:00:07.417,938] <inf> sta: ==================
143-
[00:00:07.417,938] <inf> sta: State: AUTHENTICATING
144-
[00:00:07.606,628] <inf> wpa_supp: wlan0: Trying to associate with aa:bb:cc:dd:ee:ff (SSID='<MySSID>' freq=5785 MHz)
145-
[00:00:07.609,680] <inf> wifi_nrf: wifi_nrf_wpa_supp_associate: Association request sent successfully
61+
.. code-block:: bash
14662
147-
[00:00:07.621,978] <inf> wpa_supp: wpa_drv_zep_get_ssid: SSID size: 5
63+
uart:~$ settings set wifi/ssid <my-wifi-ap-ssid>
64+
uart:~$ settings set wifi/psk <my-wifi-ap-password>
65+
uart:~$ settings set golioth/psk-id <my-psk-id@my-project>
66+
uart:~$ settings set golioth/psk <my-psk>
67+
uart:~$ kernel reboot cold
14868
149-
[00:00:07.622,070] <inf> wpa_supp: wlan0: Associated with aa:bb:cc:dd:ee:ff
150-
[00:00:07.622,192] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to aa:bb:cc:dd:ee:ff completed [id=0 id_str=]
151-
[00:00:07.622,192] <inf> sta: Connected
152-
[00:00:07.623,779] <inf> wpa_supp: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
153-
[00:00:07.648,406] <inf> net_dhcpv4: Received: 192.168.119.6
154-
[00:00:07.648,468] <inf> net_config: IPv4 address: 192.168.119.6
155-
[00:00:07.648,498] <inf> net_config: Lease time: 3599 seconds
156-
[00:00:07.648,498] <inf> net_config: Subnet: 255.255.255.0
157-
[00:00:07.648,529] <inf> net_config: Router: 192.168.119.147
158-
[00:00:07.648,559] <inf> sta: DHCP IP address: 192.168.119.6
159-
[00:00:07.720,153] <inf> sta: ==================
160-
[00:00:07.720,153] <inf> sta: State: COMPLETED
161-
[00:00:07.720,153] <inf> sta: Interface Mode: STATION
162-
[00:00:07.720,184] <inf> sta: Link Mode: WIFI 6 (802.11ax/HE)
163-
[00:00:07.720,184] <inf> sta: SSID: <MySSID>
164-
[00:00:07.720,214] <inf> sta: BSSID: aa:bb:cc:dd:ee:ff
165-
[00:00:07.720,214] <inf> sta: Band: 5GHz
166-
[00:00:07.720,214] <inf> sta: Channel: 157
167-
[00:00:07.720,245] <inf> sta: Security: OPEN
168-
[00:00:07.720,245] <inf> sta: MFP: UNKNOWN
169-
[00:00:07.720,245] <inf> sta: RSSI: -57
170-
[00:00:07.720,245] <inf> sta: Static IP address:
69+
Application Behavior
70+
********************
17171

172-
Power management testing
173-
************************
174-
175-
This sample can be used to measure current consumption of both the nRF5340 SoC and nRF7002 device independently by using two separate Power Profiler Kit II's (PPK2's).
176-
The nRF5340 SoC is connected to the first PPK2 and the nRF7002 DK is connected to the second PPK2.
177-
178-
Hardware modifications
179-
======================
180-
181-
To measure the current consumption of the nRF5340 SoC in the nRF7002 DK, complete the following steps:
182-
183-
* Remove jumper on **P22** (VDD jumper).
184-
* Cut solder bridge **SB16**.
185-
* Make a short on solder bridge **SB17**.
186-
* Connect **GND** on PPK2 kit to **GND** on the nRF7002 DK.
187-
188-
You can use **P4** pin **7** mentioned as **GND** for ground.
189-
Note that this connection requires a berg pin connector.
190-
191-
* Connect the **Vout** on PPK2 to **P22** pin **1** on the nRF7002 DK.
192-
193-
To measure the current consumption of the nRF7002 device in the nRF7002 DK, complete the following steps:
194-
195-
* Remove jumper on **P23** (VBAT jumper).
196-
* Connect **GND** on PPK2 kit to **GND** on the nRF7002 DK.
197-
198-
You can use **P21** pin **1** mentioned as **-** (**MINUS**) for ground.
199-
200-
* Connect the **Vout** on PPK2 to **P23** pin **1** on the nRF7002 DK.
201-
202-
The following diagram illustrates a typical configuration for measuring current on the nRF7002 DK for both the nRF5340 SoC and the nRF7002 device:
203-
204-
.. figure:: ../../../doc/nrf/images/nrf7002_nrf5340_current_measurements.svg
205-
:alt: Typical configuration for measuring current on the nRF7002 DK for both the nRF5340 SoC and the nRF7002 device.
206-
207-
Typical configuration for measuring current on the nRF7002 DK for both the nRF5340 SoC and the nRF7002 device.
208-
209-
PPK2 usage and measurement
210-
==========================
211-
212-
To measure the current consumption of the nRF5340 SoC and the nRF7002 device, complete the following steps:
213-
214-
* Configure PPK2 connected to the nRF5340 SoC as a source meter with 1.8 volts.
215-
* Configure PPK2 connected to the nRF7002 device as a source meter with 3.6 volts.
216-
217-
See :ref:`app_power_opt` for more information on power management testing and usage of the PPK2.
218-
219-
The average current consumption in an idle case can be around ~1-2 mA in the nRF5340 SoC and ~20 µA in the nRF7002 device.
220-
221-
Dependencies
222-
************
223-
224-
This sample uses the following `sdk-nrfxlib`_ library:
72+
When the app begins running it will connect to WiFi, then connect to Golioth and
73+
begin streaming simulated temperature sensor data:
74+
75+
.. code-block::
76+
77+
*** Booting Zephyr OS build fcaa60a99fa9 ***
78+
[00:00:00.466,949] <inf> golioth_system: Initializing
79+
[00:00:00.470,764] <inf> fs_nvs: 6 Sectors of 4096 bytes
80+
[00:00:00.470,764] <inf> fs_nvs: alloc wra: 0, f78
81+
[00:00:00.470,794] <inf> fs_nvs: data wra: 0, cc
82+
[00:00:00.471,282] <inf> net_config: Initializing network
83+
[00:00:00.471,282] <inf> net_config: Waiting interface 1 (0x200018d8) to be up...
84+
[00:00:00.472,106] <inf> net_config: IPv4 address: 192.168.1.99
85+
[00:00:00.472,167] <inf> net_config: Running dhcpv4 client...
86+
[00:00:00.474,731] <dbg> golioth_iot: main: Start Golioth IoT
87+
[00:00:00.474,761] <inf> golioth_iot: Starting nrf7002dk_nrf5340_cpuapp with CPU frequency: 64 MHz
88+
[00:00:00.474,975] <inf> wpa_supp: z_wpas_start: 385 Starting wpa_supplicant thread with debug level: 3
89+
90+
[00:00:00.475,189] <inf> wpa_supp: Successfully initialized wpa_supplicant
91+
[00:00:01.474,884] <inf> golioth_iot: Static IP address (overridable): 192.168.1.99/255.255.255.0 -> 192.168.1.1
92+
[00:00:03.078,918] <inf> golioth_iot: Connection requested
93+
[00:00:06.664,428] <inf> wpa_supp: wlan0: SME: Trying to authenticate with c6:ff:d4:a8:fa:10 (SSID='YourWiFiSSID' freq=2437 MHz)
94+
[00:00:06.667,877] <inf> wifi_nrf: wifi_nrf_wpa_supp_authenticate:Authentication request sent successfully
95+
96+
[00:00:06.923,370] <inf> wpa_supp: wlan0: Trying to associate with c6:ff:d4:a8:fa:10 (SSID='YourWiFiSSID' freq=2437 MHz)
97+
[00:00:06.932,128] <inf> wifi_nrf: wifi_nrf_wpa_supp_associate: Association request sent successfully
98+
99+
[00:00:06.948,394] <inf> wpa_supp: wlan0: Associated with c6:ff:d4:a8:fa:10
100+
[00:00:06.948,547] <inf> wpa_supp: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
101+
[00:00:06.972,045] <inf> wpa_supp: wlan0: WPA: Key negotiation completed with c6:ff:d4:a8:fa:10 [PTK=CCMP GTK=CCMP]
102+
[00:00:06.972,290] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to c6:ff:d4:a8:fa:10 completed [id=0 id_str=]
103+
[00:00:06.979,614] <inf> golioth_iot: Connected
104+
[00:00:06.981,872] <inf> golioth_system: Starting connect
105+
[00:00:06.984,283] <err> golioth: Fail to get address (coap.golioth.io 5684) -11
106+
[00:00:06.984,313] <err> golioth_system: Failed to connect: -11
107+
[00:00:06.984,313] <wrn> golioth_system: Failed to connect: -11
108+
[00:00:07.001,159] <inf> net_dhcpv4: Received: 192.168.1.127
109+
[00:00:07.001,281] <inf> net_config: IPv4 address: 192.168.1.127
110+
[00:00:07.001,281] <inf> net_config: Lease time: 43200 seconds
111+
[00:00:07.001,312] <inf> net_config: Subnet: 255.255.255.0
112+
[00:00:07.001,373] <inf> net_config: Router: 192.168.1.1
113+
[00:00:07.002,197] <inf> golioth_iot: DHCP IP address: 192.168.1.127
114+
[00:00:11.984,436] <inf> golioth_system: Starting connect
115+
[00:00:12.360,626] <inf> golioth_iot: Sending hello! 0
116+
[00:00:12.362,884] <inf> golioth_system: Client connected!
117+
[00:00:12.362,213] <inf> golioth_iot: Streaming Temperature to Golioth: 28.060000
118+
[00:00:17.362,457] <inf> golioth_iot: Sending hello! 1
119+
[00:00:17.363,677] <inf> golioth_iot: Streaming Temperature to Golioth: 27.440000
120+
121+
Button and LEDs
122+
===============
123+
124+
One LED will always be blinking. Pressing the user buttons will change which LED
125+
is currently blinking
126+
127+
Time-Series and Stateful Data
128+
=============================
129+
130+
Simulated temperature readings will be sent periodically to Golioth. Each of
131+
these readings is recorded with a timestamp when it was received.
132+
133+
When the user buttons are pressed to change which LED is blinking, the name of
134+
the currently blinking LED (`LED` or `LED2`) will be recorded on the Golioth
135+
LightDB State service.
136+
137+
Sensor Reading and LED Blinking Frequency
138+
=========================================
139+
140+
The Golioth Settings Service determines the frequency at which simulated
141+
temperature readings are sent and the frequency at which the LED blinks. The
142+
following keys are used for these settings:
143+
144+
* Sensor frequency (seconds): `LOOP_DELAY_S`
145+
* Blink frequency (milliseconds): `BLINK_DELAY_MS`
146+
147+
Reporting WiFi Connection Information
148+
=====================================
149+
150+
A remote procedure call can be used to return information about the WiFi network
151+
to which the device is currently connected:
152+
153+
* `get_wifi_info`
154+
155+
.. image:: img/rpc_wifi-info.jpg
156+
157+
.. _Golioth Cloud: https://golioth.io/
158+
.. _Zephyr: https://www.zephyrproject.org/
159+
.. _Nordic nRF7002 Development Kit: https://www.nordicsemi.com/Products/Development-hardware/nRF7002-DK
225160

226-
* :ref:`nrfxlib:nrf_security`

01_IOT/img/rpc_wifi-info.jpg

82.8 KB
Loading

0 commit comments

Comments
 (0)