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

    Serial communication using PySense

    Scheduled Pinned Locked Moved Expansion Board
    pysenseuartrpihelp
    7 Posts 3 Posters 728 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.
    • M Offline
      Mellow
      last edited by Mellow

      Hi,

      Currently i am trying to communicate between a LoPy4 on a PySense and a Raspberry Pi using UART.
      I know how i would achieve this in code but the part i am stuck at is selecting the pins.

      https://docs.pycom.io/.gitbook/assets/lopy4-pinout.png
      Judging from the Pinout PDF provided for the PySense i know i can use the external IO header.
      Would it be as easy as just choosing two pins for example P10 and P11 and connecting these to my rpi using some cables? Or is Flow control also required which would mean i would select two more pins?

      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • M Offline
        Mellow
        last edited by

        Allright currently i have P10 and P11 connected to the RX, TX and ground to the GPIO of the pi and changed the pins in my code to this aswell. But when i run it none of the test messages arrive.

        Is there anything i am missing?

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

          @mellow Just to ask a silly question? Did you cross TX and RX?
          And a test. If at the Pysense connect TX and RX, can you receive what you send?

          M 1 Reply Last reply Reply Quote 0
          • M Offline
            Mellow @robert-hh
            last edited by

            @robert-hh I just checked to be sure and can confirm they are swapped.
            Could you rephrase the second part of your question? i am not sure what u mean by that.

            This is the code i am running as far as i know i thinks this should work
            I connected the header pins 7 and 8 which correspond to P10 and P11 to my rpi along with GND

            import socket
            import machine
            import time
            
            
            uart1 = UART(1, 115200, pins=('P11','P10'), bits=8, parity=None, stop=1)
            uart1.init(baudrate=115200, bits=8, parity=None, stop=1)
            x = 0
            
            while x < 100:
                if uart1.any():
                    data = uart1.readall()
                    print(data)
                time.sleep(0.25)
                x += 1
            
            import serial
            
            with serial.Serial('/dev/serial0', 115200, timeout=10) as ser:
                ser.write(b'test')
            
            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @Mellow
              last edited by

              @mellow If you disconnect for a moment the rpi and just connect P10 and P11 on your Pysense. After init'ing the UART, if you then uart.write a short message, you shoudl be able to receive it with uart.read(). if that works, the you know the taha is getting out and in from the pysense. You could do a similar test on the rpi.

              M 1 Reply Last reply Reply Quote 0
              • M Offline
                Mellow @robert-hh
                last edited by

                @robert-hh I managed to get it to work! Thanks for the help!
                I tried some code i found on the forum so i think it had something to do with my code in the end.
                I'll try to update this thread with the working code once i finished working on it

                1 Reply Last reply Reply Quote 0
                • V Offline
                  Victor II Romero
                  last edited by

                  HI Mellow, I would be very interested to find how you did this.

                  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