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

    Weird secondary UART read behaviour

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 2.0k 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.
    • S Offline
      SmileyChris
      last edited by SmileyChris

      I'm testing via usb tty and setting up uart = UART(1, pins=('G23', 'G24')) for use with a gps sensor (edit: or soil sensor).

      When I try to read from this second uart channel in a loop, it seems to buffer the last result until a UART(0) tx.
      I.e.: uart.read() continues to return None until after I hit any key in telnet at which time it reads the buffered result.

      What could be causing this?

      1 Reply Last reply Reply Quote 0
      • B Offline
        Batilan
        last edited by

        Just for your information: I am seeing a similar thing happening on an ESP8266 (12E) on a Wemos D1 mini board.
        It might be totally unrelated, but the symptoms seem to be the same.

        I am trying to read GPS data from a SoftwareSerial using code like

        SoftwareSerial swSer(0, SW_SERIAL_UNUSED_PIN); // Only use the RX part for receiving GPS data, Note GPIO0 = D3 on Wemos
        
        void setup() 
        {
            Serial.begin(9600);
            swSer.begin(9600);
        }
        
        void loop()
        {
            while (swSer.available())
            {
              yield(); // To give time to the ESP stack
              ser_read = swSer.read();
              // Process received GPS data
            }
        }
        

        I only receive (valid) GPS data when I connect the "real" Serial port (via USB), which I would expect to be independent from the working of the Software Serial port on GPIO0 (D3 on Wemos). I know about the special function of GPIO0 on boot, but the sketch seems to run OK, it just doesn't receive any valid GPS data,

        Probably the ESP32 is quite another beast where the second UARY is a real UART and not a software Serial Port? But the behavior seems similar.

        To complicate matters: this only happens for a certain kind of GPS like this one. Another GPS like this one just always works. The first one only works on a softwareserial port when the real serial (UART) is connected.

        I first tried to use the regular Serial port for reading the GPS data, there thefirst one (red board) seems not be able to pull-down the signal on RX-port of the UART on ESP8266. Also it doesn't matter if I write in the real serial port or not, or leave it completely closed.

        I think Serial1 as mentioned here: https://github.com/esp8266/Arduino/blob/master/doc/reference.md#serial is not usable as it is TX only and thus can't receive GPS data?

        I don't want to hijack your topic, but if the 2 are somehow related this info might help recognize the symptoms.

        1 Reply Last reply Reply Quote 0
        • S Offline
          SmileyChris
          last edited by SmileyChris

          It doesn't seem related to the actual peripheral device, I'm having exactly the same behaviour shown on a soil monitor over UART1 too...

          Yeah, the ESP8266 only has a single read/write UART as far as I understand but from the ESP32 spec sheet it has multiple full UART channels. It'd be nice if we had a full pin map.
          edit: not exactly related but it seems that using 'G23' pin also causes disables the rgb led and as I had this uart initialization in main.py it also stopped firmware updates from working too... :-|

          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