0

I would like to start data logging in a bbc micro:bit with the press of its button_a, in order to be able to synchronize the timestamps with an external clock. The idea is that, if I press the button at 12:10 o'clock, I would know that the first row of data (with 0.00 timestamp) was taken at that time (+/- human reaction time, of course).

The problem is that the zero time of the timestamps begin when the bbc micro:bit is turn on (or reset); so the first timestamp in the log file is not 0.00.

Of course, I could synchronize with that turning-on, but I think it would not be that accurate (I'm using the micro:bit with a robotbit board, which has a big 'on-off' switch.)

What I would like would be some kind of reset_time() method. :)

The code is this:

from microbit import *
import log

log.set_labels('altitude', 'azimuth', 'measure', timestamp=log.SECONDS)

# Wait until Button 'A' is pressed. This way, we can sinchronize the measures with an external clock or watch
while not button_a.was_pressed():
    pass

for altitude in...
  for azimuth in...
    measure=take_reading()
    log.add({
            'altitude': altitude,
            'azimuth': azimuth,
            'measure': measure
            })

The full code is here: https://github.com/lopezsolerluis/foto-teodolito-log

Luis López
  • 159
  • 8
  • 3
    could it be solution, that on Button_A press you take measurements how much seconds elapsed after board started and use that value in your logging function to subtract that amount of secods from "current" time? – Lixas Feb 10 '23 at 07:42
  • @Lixas It's a great solution, indeed! Although it would be more 'elegant' to be able to reset the time, I'll certainly use your approach if anything else fails. Thank you very much! – Luis López Feb 10 '23 at 12:57

0 Answers0