Questions regarding SD card[SOLVED]

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
skemm
Posts: 10
Joined: Thu Jul 13, 2017 9:31 am

Questions regarding SD card[SOLVED]

Post by skemm » Thu Jul 13, 2017 9:38 am

Hello there amigos!

I am new to micropython and i'm hoping to get some enlightenment here regarding sd card support. I'm currently working on a datalogger and while i've figured out how to store the incoming data to my sd card mounted on my board, i'm trying to figure out a way where i can call upon the files inside my sd card and move them to my computer's desktop.
Last edited by skemm on Tue Jul 25, 2017 2:12 am, edited 1 time in total.

User avatar
kfricke
Posts: 334
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Questions regarding SD card

Post by kfricke » Thu Jul 13, 2017 7:26 pm

How about to get "physical" and move the SD card into a reader on your PC?

Ather ways are:
  • Reboot into the USB+CDC mode where one can access the SD-card from the PC as well. Pay attention to not change files on both "ends" of the USB cable! Reading (not deleting) on the PC only should be save.The documentation for the different USB modes on is hidden a little. They can be set on boot only iirc.
  • DHyland's rshell utility and many others do implement file transfer vie USB serial. rshell does even support rsync!
  • In case your MCU+boards has a network interface there are countless ways to transfer files.

skemm
Posts: 10
Joined: Thu Jul 13, 2017 9:31 am

Re: Questions regarding SD card

Post by skemm » Fri Jul 14, 2017 5:48 am

Also another question I have regarding is the storing of data, for example when my data stores, i have these values as shown below:

10477,000411,0.00,0.00,-0.99,0.00,0.15,, , 3.97, 4.23
10478,000409,0.00,0.01,-1.00,0.00,0.30,, , 4.12, 4.26
10479,000410,0.00,0.01,-0.99,0.00,0.13,, , 4.04, 4.07
10480,000411,0.00,0.01,-0.99,0.00,0.13,, , 4.27, 4.07
10481,000411,0.00,0.01,-0.99,0.00,0.39,, , 4.16, 4.19
10482,000410,0.00,0.01,-0.99,0.00,0.20,, , 3.92, 4.03
10483,000411,0.00,0.01,-0.99,0.00,0.28,, , 3.82, 4.32
10484,000410,0.00,0.01,-0.99,0.00,0.17,, , 3.83, 4.19
10485,000411,0.00,0.01,-0.99,0.00,0.12,, , 4.05, 4.03
10486,000411,0.00,0.01,-1.00,0.00,0.39,, , 3.87, 4.14

but sometimes my value returns in this manner:

10568,000410,0.00,0.01,-0.99,0.00,10569,000411,0.00,0.01,-1.00,0.00,0.09,, , 4.07, 4.18
10570,000411,0.00,0.01,-0.99,0.00,0.39,, , 3.99, 4.17
10572,000410,0.00,0.01,-0.99,0.00,0.40,, , 4.04, 4.28
10574,000410,0.00,0.01,-0.99,0.00,0.20,, , 4.08, 3.97
0,0.29,, , 4.09, 4.06
10576,000411,0.00,0.01,-0.99,0.010577,000411,0.00,0.01,-0.99,0.00,0.37,, , 3.80, 4.17

can i attribute this to noise? interference from other sources?

Online
User avatar
Roberthh
Posts: 761
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Questions regarding SD card

Post by Roberthh » Fri Jul 14, 2017 7:39 am

No, that does not look like noise. It loks more like you loos some data to be logged while your code writes to SD. Like:

Code: Select all

10568,000410,0.00,0.01,-0.99,0.00,10569,000411,0.00,0.01,-1.00,0.00,0.09,, , 4.07, 4.18
10570,000411,0.00,0.01,-0.99,0.00,0.39,, , 3.99, 4.17
could be:

Code: Select all

10568,000410,0.00,0.01,-0.99,0.00,< .. lost data .. >
10569,000411,0.00,0.01,-1.00,0.00,0.09,, , 4.07, 4.18
10570,000411,0.00,0.01,-0.99,0.00,0.39,, , 3.99, 4.17
So you lost about 20 bytes. For the data you log you will need a larger buffer and ISR to capture the data to the buffer. If you get it from UART, extending the UART buffer may be an option. Try using a larger read_buf_len=xxx in the UART.init() call, like read_buf_len=256

skemm
Posts: 10
Joined: Thu Jul 13, 2017 9:31 am

Re: Questions regarding SD card

Post by skemm » Mon Jul 17, 2017 2:55 am

Roberthh wrote:No, that does not look like noise. It loks more like you loos some data to be logged while your code writes to SD. Like:

Code: Select all

10568,000410,0.00,0.01,-0.99,0.00,10569,000411,0.00,0.01,-1.00,0.00,0.09,, , 4.07, 4.18
10570,000411,0.00,0.01,-0.99,0.00,0.39,, , 3.99, 4.17
could be:

Code: Select all

10568,000410,0.00,0.01,-0.99,0.00,< .. lost data .. >
10569,000411,0.00,0.01,-1.00,0.00,0.09,, , 4.07, 4.18
10570,000411,0.00,0.01,-0.99,0.00,0.39,, , 3.99, 4.17
So you lost about 20 bytes. For the data you log you will need a larger buffer and ISR to capture the data to the buffer. If you get it from UART, extending the UART buffer may be an option. Try using a larger read_buf_len=xxx in the UART.init() call, like read_buf_len=256
Hi, thanks for the assistance. Unfortunately I am running into another problem where I have instead send my information online to a server but I want to call the files saved in a directory inside the SD card of the micropython and send it to the server but I do not know what are the correct procedures to do so, I can only read and send the data at the moment:

For example, i have datalogger1 saved as a csc file inside my SD card and i want to send it to the server instead of writing and sending at the same time like the stated code below:

u2.read(u2.any())
print('FTP start\r\n')
ftpFile = 'datalogger1';
u2.write('AT+CFTPPUT="'+ ftpFile +'"\r')
pyb.delay(1000)
response_3G = str(u2.read(u2.any()))
print(response_3G)
while response_3G.find("BEGIN") == -1:
pyb.delay(1000)
response_3G = str(u2.read(u2.any()))
print(response_3G)
print('response_3G done\r\n')

Online
User avatar
Roberthh
Posts: 761
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Questions regarding SD card

Post by Roberthh » Mon Jul 17, 2017 9:15 am

What kind of board and network access module are you using?

Post Reply