-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b96cbf7
commit 8767ad9
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
micropython/examples/pico_plus_2/breakouts/lte-astronauts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
List all the humans who are currently in space! | ||
This example was adapted from one written by Les Pounder for Tom's Hardware: https://www.tomshardware.com/how-to/connect-raspberry-pi-pico-w-to-the-internet | ||
""" | ||
|
||
import lte | ||
import time | ||
import requests | ||
|
||
MOBILE_APN = "iot.1nce.net" | ||
|
||
con = lte.LTE(MOBILE_APN) | ||
con.start_ppp() | ||
|
||
try: | ||
t_start = time.time() | ||
astronauts = requests.get("http://api.open-notify.org/astros.json").json() | ||
number = astronauts['number'] | ||
|
||
print(f'There are currently {number} humans in space:') | ||
for i in range(number): | ||
print(astronauts['people'][i]['name']) | ||
|
||
finally: | ||
t_end = time.time() | ||
|
||
print(f"Took: {t_end - t_start} seconds") | ||
|
||
print("Disconnecting...") | ||
con.stop_ppp() | ||
print("Done!") |
28 changes: 28 additions & 0 deletions
28
micropython/examples/pico_plus_2/breakouts/lte-catfacts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Get yourself a cat fact over 4G! | ||
""" | ||
|
||
import lte | ||
import time | ||
import requests | ||
|
||
MOBILE_APN = "iot.1nce.net" | ||
|
||
con = lte.LTE(MOBILE_APN) | ||
con.start_ppp() | ||
|
||
try: | ||
t_start = time.time() | ||
request = requests.get('http://catfact.ninja/fact').json() | ||
fact = request['fact'] | ||
print('Cat fact!') | ||
print(fact) | ||
|
||
finally: | ||
t_end = time.time() | ||
|
||
print(f"Took: {t_end - t_start} seconds") | ||
|
||
print("Disconnecting...") | ||
con.stop_ppp() | ||
print("Done!") |