Close

Unexpected issue with RTC in PyBoard Lite with accelerometer.

A project log for Cheap underwater tilt current sensor.

Cheap (<$100) underwater current sensor that can be deployed at 70ft depth. Your thoughts, comments and advice are very welcome here!

max-kviatkouskiMax Kviatkouski 05/21/2018 at 20:410 Comments

Yesterday after soldering 3V backup battery holder to my PyBoard and playing with RTC I explored an issue. RTC in my PyBoard is much slower my PC system clock. Error is about 2-3% which is not really good for data logger. What's worse is that this level of error is beyond what can be corrected with RTC.calibration(). After asking a question on MicroPython forum I was told that it's a known issue since PyBoard lite uses internal resonator instead of crystal. And this resonator is quite inaccurate. Indeed feature table confirms that:

https://store.micropython.org/pyb-features

There are a few options I can deal with it:

- Buy and use regular PyBoard

- Buy external crystal oscillator

- Write a few scripts to "stretch" timestamps based on reference times during log postprocessing

I think I'll go with option number 3. Because it's cheaper, my datalogger doesn't require continuous clock precision. Eventual is fine. Also since I'm going to measure current once every 5 to 60 seconds (didn't decide on frequency yet) precise clock is not that important at all.

I'm going to write two scripts:

- First one to setup first time reference point (take system time from PC, set PyBoard's RTC, save this timestamp to file on PyBoard)

- Second one to read clock time from PyBoard, compare with PC time and write difference into another file

- Third script is to use results of first two scripts to adjust timestamps in logs after they've been downloaded

Discussions