Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Gpy connected to wifi but no internet access

    Scheduled Pinned Locked Moved GPy
    bugsgpyinternet
    8 Posts 7 Posters 1.9k Views 8 Watching
    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.
    • J Offline
      josejulianrp
      last edited by josejulianrp

      I am using Gpy module in Pysense board, and I have run several scripts for wifi as AP , connect to wifi, light sensor ... and it works correctly.

      But when the device is connected to wifi, it doesn't have internte access, I have executed the next code for check it and for show the wlan connection status (after review another old topic in this page):

      import urllib

      try:
      urllib.request.urlopen('http://www.google.com')
      except:
      print('No internet connection! AAAHH!')
      else:
      print('Internet connection! YAAAY!')

      print("Check pycom page")
      import socket
      s = socket.socket()
      print(socket.getaddrinfo('time-a.nist.gov', 13))
      s.connect(socket.getaddrinfo('time-a.nist.gov', 13)[0][-1])
      s.read()

      The result of the script is:

      No internet connection! AAAHH!
      Check pycom page
      [(2, 1, 0, '', ('129.6.15.28', 13))]

      Could you help me with this?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @josejulianrp
        last edited by

        @josejulianrp You have to set up the Gpy as STA, not as AP, to get internet access from it through your normal router by WiFi.
        OR, you enable LTE, and use that to connect to the Internet, but also then the GPy would act as a Station.

        1 Reply Last reply Reply Quote 0
        • sebS Offline
          seb
          last edited by

          In the code you have shared the device has not been connected to a WiFi or LTE CAT-M1 network so therefore it cannot access the internet. Please see the example here: https://docs.pycom.io/chapter/tutorials/all/wlan.html#connecting-to-a-router

          1 Reply Last reply Reply Quote 0
          • J Offline
            josejulianrp
            last edited by

            Sorry, I didn't explained correctly, I tried AP and STA options for wifi, in both cases I can connect to Gpy with filezilla, but in STA mode, although my laptop has connection to internet, the Gpy not. This is the code that I used to connect to wifi and check internet access (it is connected to the wifi because I can connect by FTP and upload and download files):

            import machine
            import network
            from network import WLAN
            import time

            setup as a station

            wlan = network.WLAN(mode=network.WLAN.STA)
            wlan.connect(ssid='my ssid', auth=(WLAN.WPA2, 'the password of wlan'))
            while not wlan.isconnected():
            time.sleep_ms(50)
            print(wlan.ifconfig())

            import urllib

            try:
            urllib.request.urlopen('https://www.google.es')
            except:
            print('No internet connection! AAAHHHHHHH!')
            else:
            print('Internet connection! YAAAY!')

            print("Check pycom code")
            import socket
            s = socket.socket()
            print(socket.getaddrinfo('time-a.nist.gov', 13))
            s.connect(socket.getaddrinfo('time-a.nist.gov', 13)[0][-1])
            s.read()

            The result of this script is:

            ('192.168.43.119', '255.255.255.0', '192.168.43.1', '192.168.43.1')
            No internet connection! AAAHHHHHHH!
            Check pycom page
            [(2, 1, 0, '', ('129.6.15.28', 13))]

            MicroPython v1.8.6-849-055728a on 2018-02-13; GPy with ESP32
            Type "help()" for more information.

            As you can see, cannot access to google page. The last part of the code is one that I saw in one of your answer to other users and you can check the result: [(2, 1, 0, '', ('129.6.15.28', 13))]

            I have tried at 20 cm of my router if the reason would be the wif signal and using my mobile as AP and sharing internet connection, in both cases the result is no access to internet.

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              jmarcelino @josejulianrp
              last edited by jmarcelino

              @josejulianrp
              Have you installed urllib.request ? It doesn't come as part of the default firmware, you need to get it from

              https://github.com/micropython/micropython-lib/tree/master/urllib.urequest

              If you don't have it an exception will be thrown causing it to print your message.

              The second part of your code using sockets seems to be connecting just fine.

              1 Reply Last reply Reply Quote 1
              • M Offline
                Mohsen Paryavi
                last edited by

                Can Gpy work as ISP for its clients? (GPy gets internet from LTE and using its WiFi access point mode, shares the internet with its clients.)

                In my code, I was able to get internet from cellular and also made Gpy be AP, but clients do not have internet... Any solutions?

                P 1 Reply Last reply Reply Quote 0
                • G Offline
                  Gijs
                  last edited by

                  In theory, it should be possible to make the GPy into a transparant bridge, between WiFi and LTE, though in practice it's not very useful, as the datarate is very limited. A more useful scenario I could think of is using the Gpy to collect data from its clients over Wifi and then forward this to a server over LTE, though there is no clear distinction to which network interface a socket is bound.

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    Peter Cameron @Mohsen Paryavi
                    last edited by

                    @Mohsen-Paryavi did you have any luck getting this to work?
                    I'm interest in doing the same, using the Gpy as a LTE Cat-m1 hotspot. Allowing a phone to wifi-call beyond LTE coverage.

                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • 1 / 1
                    • First post
                      Last post

                    Pycom on Twitter

                    Pycom