Skip to content

Commit 649441d

Browse files
committed
updated content
1 parent 7e20f0a commit 649441d

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

docs/basics/06-wireless.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ I had to download a brand new image for the Pico W runtime from [the Raspberry P
3131

3232
After I downloaded the new image and ran a Reset on Thonny I got the following prompt:
3333

34-
```sh
34+
```sh title="reset shell prompt"
3535
MicroPython v1.19.1-88-g74e33e714 on 2022-06-30; Raspberry Pi Pico W with RP2040
3636
Type "help()" for more information.
3737
>>>
@@ -58,7 +58,7 @@ print('Connecting to WiFi Network Name:', secrets.SSID)
5858

5959
## Testing Your Connection
6060

61-
```python
61+
```python title="test-access-point-connection.py"
6262
import network
6363
import secrets
6464
from utime import sleep
@@ -112,34 +112,46 @@ This code also supports a timer that will display the number of milliseconds for
112112

113113
The following example was taken from [Tom's Hardware](https://www.tomshardware.com/how-to/connect-raspberry-pi-pico-w-to-the-internet)
114114

115-
```py
115+
```py title="test-http-get.py"
116116
import network
117117
import secrets
118-
import time
118+
from utime import sleep, ticks_ms, ticks_diff
119119
import urequests
120+
120121
wlan = network.WLAN(network.STA_IF)
121122
wlan.active(True)
122123
wlan.connect(secrets.SSID, secrets.PASSWORD)
123-
print(wlan.isconnected())
124+
125+
start = ticks_ms() # start a millisecond counter
126+
124127
astronauts = urequests.get("http://api.open-notify.org/astros.json").json()
128+
129+
delta = ticks_diff(ticks_ms(), start)
130+
125131
number = astronauts['number']
132+
print('There are', number, 'astronauts in space.')
126133
for i in range(number):
127-
print(astronauts['people'][i]['name'])
134+
print(i+1, astronauts['people'][i]['name'])
135+
136+
print("HTTP GET Time in milliseconds:", delta)
128137
```
129138

130139
Returns:
131140

132-
True
133-
Oleg Artemyev
134-
Denis Matveev
135-
Sergey Korsakov
136-
Kjell Lindgren
137-
Bob Hines
138-
Samantha Cristoforetti
139-
Jessica Watkins
140-
Cai Xuzhe
141-
Chen Dong
142-
Liu Yang
141+
```
142+
There are 10 astronauts in space.
143+
1 Oleg Artemyev
144+
2 Denis Matveev
145+
3 Sergey Korsakov
146+
4 Kjell Lindgren
147+
5 Bob Hines
148+
6 Samantha Cristoforetti
149+
7 Jessica Watkins
150+
8 Cai Xuzhe
151+
9 Chen Dong
152+
10 Liu Yang
153+
HTTP GET Time in milliseconds: 786
154+
```
143155

144156
## Getting a JSON Document with SHTTP GET
145157

0 commit comments

Comments
 (0)