Connect to Wi-Fi using Python on Raspberry Pi

I am using Python 2.7 and the wifi library ( https://wifi.readthedocs.org/en/latest/ ) on a raspberry Pi. I managed to install the wifi library using:

sudo pip install wifi 

on the terminal. The library works, but I can’t figure out how to connect to Wi-Fi with a password. The documentation on the website is a little hard to understand, especially if you're a Python noob like me. I used this:

>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')

and I got all the available Wi-Fi networks, as well as the one I want to connect to the called test1. Therefore, I am sure that the library is working. I followed the steps on the website, but was denied permission:

>>> scheme.save()

In addition, this command appeared before this:

>>> scheme = Scheme.for_cell('wlan0', 'home', cell)

- , ""? SSID? - Wi-Fi test1, - test1? Wi-Fi , Python?. .

+1
1

Wi-Fi, Python Pi. , wifi :

sudo wifi connect --ad-hoc SSID_Name

: passkey > . , enter Wi-Fi. Python script, . wifi , , Wi-Fi . , , :

sudo nano /etc/network/interfaces

, , .

+5

Source: https://habr.com/ru/post/1627584/


All Articles