Page 1 of 1

Set the correct Date at creating a nwe File Document

Posted: Fri Nov 25, 2016 3:09 pm
by diego.cuba
Hi Group,

I would like to know how is possible set the correct date when i create a new file , in order to store values that i'm sensing with a sensor.

#========================================
archivo=open('/sd/archivo.txt','w')
archivo.write('{},{},{},{},{},{},{}\n'.format(t,xm,ym,zm,xg,yg,zg))
#========================================

Which part of the code must I have set the time or date characteristic?

Is it possible to preserve on memory the correct time?, and the next time i rund code ,it sets the correct datetime?

Re: Set the correct Date at creating a nwe File Document

Posted: Fri Nov 25, 2016 4:48 pm
by platforma
Perhaps the RTC module will be of help: http://docs.micropython.org/en/latest/p ... C.datetime

Re: Set the correct Date at creating a nwe File Document

Posted: Fri Nov 25, 2016 5:59 pm
by dhylands
And in order to preserve the RTC date/time across power cycles, you'll need to add a small coin cell battery. Typically a CR2032.

On the original pyboard (V1.0) connect the + side of the battery to the VBAT, and the - side to GND. On the newer pyboards (V1.1) use the VBACK and GND pins (VBAT on the newer boards refers to a battery for powering the board).