Created
August 30, 2024 10:59
-
-
Save qbalsdon/942c304eef5988cad3723f25d710d209 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Useful links | |
# https://randomnerdtutorials.com/raspberry-pi-pico-w-http-requests-micropython/ | |
URL="..." | |
import json | |
import network | |
import requests | |
# contents of cred.json (on Pico file system, where main.py is) | |
# { | |
# "ssid": "WIFI NAME", | |
# "pass": "WIFI PASSWORD" | |
# } | |
# Wi-Fi credentials | |
wifi_info = open('cred.json') | |
credentials = json.loads(wifi_info.read()) | |
# Connect to network | |
wlan = network.WLAN(network.STA_IF) | |
wlan.active(True) | |
# Connect to your network | |
wlan.connect(credentials["ssid"], credentials["pass"]) | |
# Make GET request | |
response = requests.get(URL) | |
# Get response code | |
response_code = response.status_code | |
# Get response content | |
response_content = response.content | |
# Print results | |
print('Response code: ', response_code) | |
print('Response content:', response_content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment