Set the correct Date at creating a nwe File Document

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
diego.cuba
Posts: 5
Joined: Fri Nov 18, 2016 10:05 pm
Contact:

Set the correct Date at creating a nwe File Document

Post by diego.cuba » Fri Nov 25, 2016 3:09 pm

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?
((( :geek: Diego Cuba Z )))

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

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

Post by platforma » Fri Nov 25, 2016 4:48 pm

Perhaps the RTC module will be of help: http://docs.micropython.org/en/latest/p ... C.datetime

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

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

Post by dhylands » Fri Nov 25, 2016 5:59 pm

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

Post Reply