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

    Another problem with SD and UART

    Scheduled Pinned Locked Moved Discussion
    5 Posts 4 Posters 82 Views 4 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.
    • V Offline
      VST Admin
      last edited by

      Continuing my Search for writing incoming data from a UART to the SD Card

      I have a program that is supposed to read data from the UART to the SD Card. When the SD card is commented out, my loop reads from the serial port and accurately displays in the terminal the data I am expecting. I was ecstatic that I was able to pull this off on the very first try.

      from machine import UART
      from machine import SD
      
      import time
      import pycom
      import os
      
      sd = SD()
      #fs = os.mkfat(sd)
      os.mount(sd, '/sd')
      
      line='header record\n'
      f = open('/sd/logfile.csv', 'w')
      f.write('{}'.format(line))
      f.close()
      
      uart = UART(1, 9600)                         # init with given baudrate
      uart.init(9600, bits=8, parity=None, stop=1, pins=('P10','P11')) # init with given parameters
      

      However, when I add the SD Card module, things get hairy. The program goes from logging once per second to once per minute (at least) and the data never gets written to the SD Card.

      However, if I remove the UART modules and send Dummy data to the SD card, the functions and program work fine. I have also attempted to change the Pins, first from P3 / P3 on TX1 / RX1 because they appear to clash with SDCard pin functions in the pinout chart for the Gpy. I moved them to Pin 20/21 and then to Pin 10/11. I get the same results each time. I can run either module separately while I dummy the rest of the code and everything runs as expected, but as soon as I add BOTH modules, my code slows by a factor of at least 100 and no data ever gets written to the Card.

      Any help would be very much appreciated.

      1 Reply Last reply Reply Quote 0
      • catalinC Offline
        catalin
        last edited by

        hi @VST-Admin, I will check this scenario.

        Catalin,

        Have you checked out our docs for the answer? (Now with an easy search function) https://docs.pycom.io
        Check out our newly revamped device management platform, Pybytes! https://pybytes.pycom.io/

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

          HI @catalin, I've run into exactly the same problem trying to develop a GPS logger. I can write to the SD card on its own and I can read the GPS data using UART 1 P10/P11 but as soon as I initialise the UART I see exactly the same problem as @VST-Admin, code slows down and nothing is written to the SD card.

          I've found I can close the log file however when I try to open it again I get an error - OSError: [Errno 2] ENOENT.

          In my case -

          uos.uname()
          (sysname='GPy', nodename='GPy', release='1.20.1', version='v1.11-12f4ce0 on 2019-10-06', machine='GPy with ESP32', pybytes='1.1.2')

          Any help would be greatly appreciated.

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

            @drl provided a workaround - https://forum.pycom.io/topic/662/wipy-2-0-expansion-board-2-0-sd-card-and-uart1/2

            Initialise the UART before mounting the SD card. Works for me.

            1 Reply Last reply Reply Quote 0
            • N Offline
              nowakowski912 Banned
              last edited by

              This post is deleted!
              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