🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    [Solved]Any way to know the name of the SSID and other info with wifisetup?

    Micropython
    4
    6
    11.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • f3rn4nd0dF
      f3rn4nd0d
      last edited by m5-docs

      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!

      1 Reply Last reply Reply Quote 0
      • S
        salty_good
        last edited by

        @f3rn4nd0d You can get connecting SSID name and PSK on Arduino.

        #include <WiFi.h>
        
        WiFi.SSID()
        WiFi.psk()
        
        f3rn4nd0dF 1 Reply Last reply Reply Quote 0
        • f3rn4nd0dF
          f3rn4nd0d @salty_good
          last edited by

          @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.

          ajb2k3A 1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3 @f3rn4nd0d
            last edited by

            @f3rn4nd0d I'm looking at something similar but using RSSI.
            For micropython I have been visiting the micropython forum.
            link text

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • lukasmaximusL
              lukasmaximus
              last edited by

              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)
              1 Reply Last reply Reply Quote 0
              • f3rn4nd0dF
                f3rn4nd0d
                last edited by f3rn4nd0d

                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)
                ...
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post