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

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

    Lopy to Lopy communication issue

    Geplant Angeheftet Gesperrt Verschoben LoPy
    lopylora
    9 Beiträge 5 Kommentatoren 2.6k Aufrufe 5 Beobachtet
    Lade mehr Beiträge
    • Älteste zuerst
    • Neuste zuerst
    • Meiste Stimmen
    Antworten
    • In einem neuen Thema antworten
    Anmelden zum Antworten
    Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
    • IplookyI Offline
      Iplooky
      zuletzt editiert von Iplooky

      Hello,
      I want to make a basic transmision Lopy-Lopy. After two and a half hours of trying I have no ideea why it's not working.

      The codes are exactly the ones from here https://docs.pycom.io/chapter/tutorials/lopy/lopy-lopy.html (ok maybe with some additional led blinking just to be shure the code is fine)

      I've connected them one at a time, sync the code, put them in the configuration :
      Battery->LoPy1->antena - - - antena <-LoPy2<-usb<-PC
      And waited for the message. (that did not appear in the terminal)
      Are there any steps to do that I am missing ? Do I need to modify in LoPy1 at pymakr.conf the adress as 192.168.0.1 ? When I sync the codes need to be in separate folders ? When I send information, how does Lopy2 know that the message is good to recieve (there may be another 10 Lopy's in the area that send messages that I don't want to see)? Thank you !

      C 1 Antwort Letzte Antwort Antworten Zitieren 0
      • M Offline
        monersss
        zuletzt editiert von

        @Iplooky did you sync the code as a main.py file or change the main.py file to execute the file that includes the code?
        If not you need to do that on the lopy which you connect to a battery or connect lopys to 2 different computers and run the codes from atom.

        1 Antwort Letzte Antwort Antworten Zitieren 0
        • C Offline
          crumble @Iplooky
          zuletzt editiert von

          @iplooky

          1. test the code with s.setblocking(True)

          2. Identifying your messages is more or less easy. Listen and log all messages in your area. Find a unique string, which no one is sending and place it in front of all your messages. If a message starts with this string you have a high chance that this message is from one of your LoPys.
            If you send your messages uncrypted, someone may capture your messages and send you faulty data. So encrypt your data, if something relays on the data. Controlling your heater may be a bad idea. If you send the message "lplooky: It's hot, stop" much too often, someone may send it for you.

          Maybe you can join the TTN and use their message format.

          1 Antwort Letzte Antwort Antworten Zitieren 0
          • sebS Offline
            seb
            zuletzt editiert von

            Hi,

            When I recently attempted to use this example I forgot to update the firmware on one of the two LoPy boards I was using causing very few messages to get through. Can you double check that BOTH LoPy boards are fully updated?

            1 Antwort Letzte Antwort Antworten Zitieren 0
            • IplookyI Offline
              Iplooky
              zuletzt editiert von Iplooky

              Hello,
              I've double checked the firmware upgrade, I've synced the code again and I've made progress (but still things are wierd):

              So the basic code says that LoPy_PC sends 'Ping' and IF Lopy_Field recieves it then it will send 'Pong', that didn't work (LoPy_PC didn't recieve any messaje)
              After that I tried that LoPy_Field will send a message without the condition of recieving 'Ping' (so no condition at all). That worked, I mean LoPy_PC recieves that message. Another issue is that the message is recieved 6 of 10 times (it is normal to have that kind of imprecision? They are like half a meter distance one from the other).
              Also tried with data from the Pysense but "object with buffer protocol required".

              Do I need in "lora = LoRa(mode=LoRa.LORA)" to set a particular frequency or to add a bigger sf ? Thanks.

              J C 2 Antworten Letzte Antwort Antworten Zitieren 0
              • J Offline
                jmarcelino @Iplooky
                zuletzt editiert von

                @iplooky
                Bigger SF at that distance is not needed.

                Try another frequency, you may have too much interference on the one you’re using.

                Also try to separate both boards more, half a meter at the default transmit power is too close and probably over saturating the receiver

                1 Antwort Letzte Antwort Antworten Zitieren 0
                • C Offline
                  crumble @Iplooky
                  zuletzt editiert von

                  @iplooky said in Lopy to Lopy communication issue:

                  So the basic code says that LoPy_PC sends 'Ping' and IF Lopy_Field recieves it then it will send 'Pong', that didn't work (LoPy_PC didn't recieve any messaje)

                  There is no code, which receives the Pong, if you use the example code unchanged. Yes, it would be nice, if pycom uses a more beginner friendly example ;)

                  1 Antwort Letzte Antwort Antworten Zitieren 0
                  • sebS Offline
                    seb
                    zuletzt editiert von

                    When I was testing this example I modified the code slightly to make it easier to see what is happening. If you think this is better than the current example let me know and I can update the documentation to include it:

                    Pong.py

                    from network import LoRa
                    import socket
                    import time
                    
                    lora = LoRa(mode=LoRa.LORA, frequency=863000000)
                    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
                    s.setblocking(False)
                    
                    while True:
                        rec = s.recv(64)
                        if rec != b'':
                            in_msg = rec.decode()
                            reply = in_msg.replace("Ping", "Pong")
                            s.send(reply)
                            print("Got:{}, Replied:{}".format(in_msg, reply))
                        else:
                            print("NULL")
                        time.sleep(1)
                    

                    Ping.py

                    from network import LoRa
                    import socket
                    import time
                    
                    lora = LoRa(mode=LoRa.LORA, frequency=863000000)
                    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
                    s.setblocking(False)
                    
                    x=0
                    while True:
                        out = 'Ping %s' % x
                        s.send(out)
                        rec = s.recv(64)
                        if rec != b'':
                            in_msg = rec.decode()
                            print("Sent:{}, Got Back:{}".format(out, in_msg))
                        else:
                            print("Sent:{}, Got no reply".format(out))
                        time.sleep(1)
                        x=x+1
                    

                    I just tried the above code using two LoPy boards that are spaced about 30cm apart and everything seems to be working.

                    1 Antwort Letzte Antwort Antworten Zitieren 0
                    • IplookyI Offline
                      Iplooky
                      zuletzt editiert von

                      @seb I've tried you're code, it is better but in my opinion it's harder than the first one (I don't really know but the sintax " if rec=='Ping' "didn't work so I've tried yours :"if rec !=b' ' " that's just fine)

                      @jmarcelino at a distance of 15 meters I had accuracy of almost 40% ( from 100 messages sent from LoPyPC only 40 came back from the other LoPy )

                      1 Antwort Letzte Antwort Antworten Zitieren 0

                      Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.

                      Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.

                      Mit deinem Input könnte dieser Beitrag noch besser werden 💗

                      Registrieren Anmelden
                      • 1 / 1
                      • Erster Beitrag
                        Letzter Beitrag

                      Pycom on Twitter

                      Pycom