microsoft / microsoft/pxt-microbit
Ability to log data with the local date and time
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
When logging data on the order of hours or days, users would like to know what time of day the measurement occurred, or what date. The current options for the timestamp when data logging do not include the current date or time because the micro:bit doesn't maintain a clock. With the current minute, hour, day timestamps you don't really know when something happened if you don't record exactly when the program started. Is minute 213 morning or afternoon?
The set timestamp block could have 3 new options
clock time: log entries get a timestamp in the form hh:mm:ss - in 24 hour format
date: log entries timestamp in the form yyyy-mm-dd
date-time: timestamp with both date and clock time.
This would need additional support in the download step to pass the current date/time to the micro:bit. CODAL also needs to maintain the clock on the device if it is unplugged without losing power.
If the device does lose power then the default date/time should probably be set to epoch time 1 Jan 1970.
Maybe there can be support for getting the current date/time over bluetooth if the micro:bit is connected to the computer via bluetooth?
You could create your own timestamp column in the data with the time and date extension using the value of the 'date and time stamp' block but the methods described to initialize the time and date are quite burdensome. The extension also has a rich set of date and time formats, but for the data logging use case it adds complexity that isn't necessary.
Some other features that would be nice to have.
a reporter with options for time, date, hour, minute, second, day, month, year, day of week
Again, the extension has the time as numbers block for complete flexibility, and multiple reporters with different date and time formats. It would be nice to have a simpler block that works for a majority of users.
If there's just the one new block it probably belongs in inputs after the running time blocks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing set timestamp block and the download step that initializes logging, then investigate the CODAL clock behavior described in the issue. Done would require an agreed scope and implementation for clock time, date, or date-time logging, including behavior after power loss and any required device or Bluetooth support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data, embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100