Another problem with SD and UART



  • 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.


  • Banned

    This post is deleted!


  • @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.



  • 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.



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


Log in to reply
 

Pycom on Twitter