Merge pull request #16 from pimoroni/examples/rm2

add RM2 Breakout example
This commit is contained in:
Hel Gibbons 2024-10-23 10:09:45 +01:00 committed by GitHub
commit 7cc2cfa984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,26 @@
"""
Get a cat fact from t'internet!
You will need to add your wireless SSID and password to secrets.py (and save this file to your Pico)
"""
import network
import requests
from secrets import WIFI_SSID, WIFI_PASSWORD
from time import sleep
# Specify the pins that that wireless module is connected to
# The pins below are for a Pimoroni Pico Plus 2 with a RM2 breakout connected via SP/CE
network.wlan_set_pins(32, 35, 34, 33) # Power, Data IO, Clock, CS
# connect to wifi
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASSWORD)
while wlan.isconnected() is False:
print('Waiting for connection...')
sleep(1)
request = requests.get('http://catfact.ninja/fact').json()
fact = request['fact']
print('Cat fact!')
print(fact)

View File

@ -0,0 +1,2 @@
WIFI_SSID = 'ssid_goes_here'
WIFI_PASSWORD = 'password_goes_here'