[Solved]Any way to know the name of the SSID and other info with wifisetup?
-
Hello, as the title of this thread says, I need to perform specific actions depending of the SSID name. Any help with wifisetup? Thanks a lot!
-
@f3rn4nd0d You can get connecting SSID name and PSK on Arduino.
#include <WiFi.h> WiFi.SSID() WiFi.psk()
-
@salty_good thanks, but I'm developing a little client in python that will connect to several wifi networks. The idea is to publish a different message via MQTT depending of the wifi it has connected to. I need to do it in python, maybe I can import a different library that gives me more options than wifisetup.
F.
-
@f3rn4nd0d I'm looking at something similar but using RSSI.
For micropython I have been visiting the micropython forum.
link text -
Hi @f3rn4nd0d there is a wifi scanner script that comes with the uiflow firmware, heres the python code in that file, hope it helps.
from m5stack import * import network import utime as time lcd.clear() sta = network.WLAN(network.STA_IF) sta.active(True) while True: lcd.clear() lcd.setCursor(0, 0) lcd.print('wifi scan:') wifi_list = sta.scan() number = 1 for i in wifi_list: lcd.print(i[0].decode(), 20, number*13) number += 1 time.sleep(10)
-
Well, I've managed to do on a different way, thanks a lot for your help. Here is the code:
#import wifisetup #wifisetup.auto_connect() import network from m5stack import * from m5ui import * from m5_pin import * from m5mqtt import M5mqtt from time import strftime, ticks_ms, ticks_diff, sleep_ms import utime import _thread def connect(ssid,auth,timeout=6000): from network import WLAN, STA_IF, AP_IF global uplink uplink = WLAN(STA_IF) uplink.active(True) uplink.connect(ssid, auth) started= ticks_ms() while True: if uplink.isconnected(): return True else: if ticks_diff(ticks_ms(), started) < timeout: sleep_ms(100) continue else: return False wlan = network.WLAN(network.AP_IF) while True: if connect('Wifi1', 'password1'): red='Wifi1' break elif connect('Wifi2', 'password2'): red='Wifi2' break print('connected to: ',red) ...