Hi im wondering if theres a way of putting the Pico-LoRa-SX1262 Pico-W into Access point mode ?
rather than going through my home network i would like to be able to connect straight to it from my phone
Connect to the Pico-W using a serial terminal or Thonny (Python IDE) and enter the following code:
import network
# Initialize the WLAN object in access point mode
ap = network.WLAN(network.AP_IF)
ap.active(True)
# Set up the network details (SSID and password)
ap.config(essid='Pico_AP', password='yourpassword')
ap.config(authmode=3) # WPA2
# Print out the IP address
print('Access Point IP:', ap.ifconfig()[0])
If you want to control or retrieve data from the Pico-W, you can set up a simple web server on it. Here’s an example to serve a basic webpage:
import socket
# Set up a socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
print('Listening on', addr)
while True:
cl, addr = s.accept()
print('Client connected from', addr)
cl_file = cl.makefile('rwb', 0)
while True:
line = cl_file.readline()
if not line or line == b'\r\n':
break
response = """\
HTTP/1.1 200 OK
<html><body><h1>Hello from Pico-W!</h1></body></html>
"""
cl.send(response)
cl.close()
2 Likes
Thankyou very much
1 Like
Thanks @lia262073 for the example