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

    Using MQTT send data to server

    Scheduled Pinned Locked Moved MicroPython
    mqttlorafipy
    19 Posts 3 Posters 3.3k Views 3 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.
    • A Offline
      Archana Kadam
      last edited by

      Hello,
      How to connect node and gateway of Lora via mqtt(through mqtt we are connecting node and gateway) and how to send a collected data of node and gateway to server via/through mqtt. Please update as soon as possible.

      Thank you

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

        @archana-kadam
        The simplest solution is to have one LoPy as a node and another as a nano-gateway connected to a service such as The Things Network: https://www.thethingsnetwork.org

        Then you can retrieve your data over MQTT from there.

        The code for the LoPy node and nano-gateway is at:

        https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway

        1 Reply Last reply Reply Quote 0
        • A Offline
          Archana Kadam
          last edited by

          Hello
          We are connecting two nodes and one gateway we are successfully saved the data from gateway to server using our existing wifi(Home wifi) using mqtt.
          Now how we need to use existing wifi of fipy board and store data to server using mqtt.
          Please reply as soon as possible.
          Thank you

          A 1 Reply Last reply Reply Quote 0
          • A Offline
            Archana Kadam @Archana Kadam
            last edited by

            Hello team,
            Please reply soon as possible for above query.

            Thank you

            J H 2 Replies Last reply Reply Quote 0
            • J Offline
              jmarcelino @Archana Kadam
              last edited by

              Hi @archana-kadam

              To understand how to send MQTT data over WiFi please see our MQTT example:

              https://docs.pycom.io/chapter/tutorials/all/mqtt.html

              1 Reply Last reply Reply Quote 0
              • H Offline
                han @Archana Kadam
                last edited by

                @archana-kadam maybe you could try this
                developer.ibm.com/recipes/tutorials/connecting-pycom-devices-to-watson-iot-platform/

                A 1 Reply Last reply Reply Quote 0
                • A Offline
                  Archana Kadam @han
                  last edited by

                  @han
                  How to connect the fipy to the mobile hotspot.
                  Thank you

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Archana Kadam
                    last edited by

                    Hello team,
                    We successfully connected the fipy board to the server using existing WiFi, but we are enable to connect using mobile hotspot when the device is not connected to the PC. Please reply as soon as possible Your help will appreciable.
                    Thank you

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

                      @archana-kadam

                      Can you be more specific please, what is the mobile hotspot you’re using?

                      Usually you’d just call

                      wlan.connect('HOTSPOT_NAME', auth=(WLAN.WPA2, 'PASSWORD'), timeout=5000)
                      while not wlan.isconnected():
                              machine.idle()
                      

                      Replacing HOTSPOT_NAME by the name of the network (as seen on a WiFi network list) and PASSWORD with the appropriate one

                      A 1 Reply Last reply Reply Quote 1
                      • A Offline
                        Archana Kadam @jmarcelino
                        last edited by

                        @jmarcelino
                        More specific to our problem is, right now we have a router setup and have home
                        wifi network available, and we have configured fipy as station mode and connected to the home wifi network using as below
                        wlan.connect('wifi-ssid-name', auth=(WLAN.WPA2, 'wifi-password'), timeout=5000)
                        while not wlan.isconnected():
                        machine.idle()

                        With the above configuration we have successfully sent the data from fipy to server.

                        But the problem we are facing is where we do not have router setup, meaning no wifi available, then in that case we have enabled our mobile data internet and switched on the hotspot to connect the fipy to the mobile hotspot and send data to the server. We used the code as below

                        wlan.connect('HOTSPOT_NAME', auth=(WLAN.WPA2, 'HOTSPOT_PASSWORD'), timeout=5000)
                        while not wlan.isconnected():
                        machine.idle()

                        But we are not able to connect to mobile hotspot. We are using MQTT to send data to server.Please find our code in the attachment and suggest where we are going wrong and how to actually connect fipy to mobile hotspot.

                        Thank You0_1526022171378_gateway.py

                        J H 2 Replies Last reply Reply Quote 0
                        • J Offline
                          jmarcelino @Archana Kadam
                          last edited by

                          @archana-kadam
                          Connecting to the mobile hotspot should be the same as connecting to your home wifi.

                          Make sure you are setting the correct hotspot name and password. Also check the hotspot configuration, is set to use WPA2?

                          If it still doesn't work we'll need to investigate but for that, at a minimum, I need to know which hotspot you are using.

                          A 1 Reply Last reply Reply Quote 0
                          • A Offline
                            Archana Kadam @jmarcelino
                            last edited by

                            @jmarcelino
                            Our hotspot configuration is set to WPA2 PSK security we do not have option to set security to only to WPA2, with this arrangement we are not able to connect to the mobile hotspot.
                            Right now we are using our mobile sim card hotspot network (Vodafone). Let us know anything more information you need.

                            Thank you

                            A J 2 Replies Last reply Reply Quote 0
                            • H Offline
                              han @Archana Kadam
                              last edited by

                              Hi @archana-kadam ,
                              I had the same problem with my LoPy. I had to encounter two problems. The first one was that because I used deepsleep the hot spot deactived because there was no active connection between the LoPy and the hotspot in de sleep time. When i made the deepsleep time shorter the LoPy connects again but the hotspot stopped with creating a network because the traffic of the messages was to small and the weigth of the messages was to small to set the hot spot in function to keep creating a acceseble network.
                              The other problem with the hotspot was that I have to agree with some privacy terms and that is something a LoPy or FiPy doesnt do. Maybe he can do it but i do not know how to do that.

                              What is the reason that you doesnt use the Nb IoT or CAT M1 connection of the FiPy?

                              1 Reply Last reply Reply Quote 0
                              • A Offline
                                Archana Kadam @Archana Kadam
                                last edited by

                                @jmarcelino
                                Hello,

                                We have successfully connected the fipy to the mobile hotspot with keeping mobile hotspot security as 'None', and in all android mobiles we checked there are no option available as 'WPA2' under security. So how to solve this problem.

                                And another thing is we are using MQTT method to send data to server using mobile hotspot but getting below error. The code we used is attached please have a look.
                                Traceback (most recent call last):
                                File "<stdin>", line 21, in <module>
                                File "mqtt.py", line 56, in connect
                                OSError: -1

                                And also let us know how to check/verify whether the mobile mqtt port is enabled?0_1526031623991_mqtt-server.py

                                Thank you

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

                                  @archana-kadam
                                  Do you have a make/model of the hotspot?

                                  WPA2 PSK (pre-shared key) should be correct for the code I posted. Sometimes it's just called WPA2 for short.

                                  Have you connected to the hotspot from another machine using the same name and password?

                                  A 1 Reply Last reply Reply Quote 0
                                  • J Offline
                                    jmarcelino @Archana Kadam
                                    last edited by

                                    @archana-kadam said in Using MQTT send data to server:

                                    I don't understand how that code matches the error you posted. Don't you have a file called mqtt.py too? What is your main.py?

                                    A 1 Reply Last reply Reply Quote 0
                                    • A Offline
                                      Archana Kadam @jmarcelino
                                      last edited by

                                      @jmarcelino
                                      Yes we have connected to the hotspot with the other computer, laptop as well as with another mobile also. We are using our mobile data and mobile hotspot.

                                      Thank you

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

                                        @archana-kadam
                                        I'm afraid I can't help further without knowing the specific Brand name and model of the hotspot you are using. Even if the hotspot has Vodafone branding it should be some sticker with this information along with FCC ID.

                                        Alternatively posting a picture of the hotspot could help.

                                        As far as I know if the hotspot is set to WPA2 PSK it should connect with the instructions I posted so this would be a more specific issue with particular hotspots.

                                        1 Reply Last reply Reply Quote 0
                                        • A Offline
                                          Archana Kadam @jmarcelino
                                          last edited by

                                          @jmarcelino
                                          We have already added the file mqtt.py, and main.py is blank

                                          Thank you

                                          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