Real time clock on Pico (rev 1.4)

Posted on
  • Hi

    I'm building a Programmable Timer Switch (Synchronizing time with DCF77 - from time to time) on espruino Pico so I need a quite accurate clock.
    Do I need a external RTC (like DS1307 or DS3231) or internal crystal is accurate enough for a clock?
    I'm quite confused because here we've got: https://www.espruino.com/Pico+Clock

    While the Pico has an RTC built in, by default it doesn't have an accurate watch crystal and so uses its internal oscillator which isn't that accurate. It won't keep proper time over a month

    but, on the other hand, there is a clock frequency crystal in schematic - which should generate very accurate time

    Thanks for your help

  • Ahh, yeah - it's in the schematic, and there are pads for it (right at the end of the board), but it isn't fitted.

    You can fit one if you want, and it'll be automatically detected and used. In reality the capacitor values should be under 4pF, and are so small they can actually be left off without any real problems. You just need an ABS06-107 crystal. The 107 bit is important though.

    The Espruino WiFi does have the crystal installed, so if you wanted then that is another option as well.

  • Thanks @Gordon

    am I getting it right?

    btw, is there a way to check if it's successfully detected and used?


    1 Attachment

    • IMG_0820.jpg
  • That's right, yes! Definitely try without the capacitors first, as they can be a pain to solder :) If you have a hot air gun then the crystal should be pretty easy to add though.

    To test, just run the following magic code more than 5 seconds after startup:

    (function() {
      console.log("LSEON",peek32(1073887344)&1­);
      console.log("LSERDY",peek32(1073887344)&­2);
      console.log("LSION",peek32(1073887348)&1­);
      console.log("LSIRDY",peek32(1073887348)&­2);
      console.log(["NONE","LSE","LSI","HSE"][(­(peek32(1073887344)&768)>>8)]);
      console.log("RTCEN",!!peek32(1073887344)­&32768);
      // RTC subsecond
      console.log("Subsecond:", peek32(0x40002828));
    })();
    

    It'll say LSI without a crystal (low speed internal), and LSE with one (low speed external)

  • I have soldered ABS06-107 but I'm still getting LSI :/

    Connected
    >Loading 2484 bytes from flash...
    >
    >(function() {
    :  console.log("LSEON",peek32(1073887344)&1­);
    :  console.log("LSERDY",peek32(1073887344)&­2);
    :  console.log("LSION",peek32(1073887348)&1­);
    :  console.log("LSIRDY",peek32(1073887348)&­2);
    :  console.log(["NONE","LSE","LSI","HSE"][(­(peek32(1073887344)&768)>>8)]);
    :  console.log("RTCEN",!!peek32(1073887344)­&32768);
    :  // RTC subsecond
    :  console.log("Subsecond:", peek32(0x40002828));
    :})();
    LSEON 0
    LSERDY 0
    LSION 1
    LSIRDY 2
    LSI
    RTCEN 0
    Subsecond: 26177
    =undefined
    > 
    

    do you think this is caused by absence of 4pF capacitors?


    1 Attachment

    • IMG_0851.JPG
  • Is your firmware up to date? I know some of the older firmwares had problems detecting the LSI.

    It looks good - are you sure it's soldered properly each side though? It could be the lack of capacitors, but I doubt it - I'm sure I've had boards running ok with just the crystal on its own.

  • I'm 80% sure it's soldered properly - I have 2 espruinos pico soldered on both.
    Yep firmware - 1.92

  • Sorry - looks like I was wrong about that.

    I just swapped the ABS06-107 from a dead WiFi board and I got the same as you. However after soldering on the two 4pF capacitors it sprung into life:

    >(function() {
    :  console.log("LSEON",peek32(1073887344)&1­);
    :  console.log("LSERDY",peek32(1073887344)&­2);
    :  console.log("LSION",peek32(1073887348)&1­);
    :  console.log("LSIRDY",peek32(1073887348)&­2);
    :  console.log(["NONE","LSE","LSI","HSE"][(­(peek32(1073887344)&768)>>8)]);
    :  console.log("RTCEN",!!peek32(1073887344)­&32768);
    :  // RTC subsecond
    :  console.log("Subsecond:", peek32(0x40002828));
    :})();
    LSEON 1
    LSERDY 2
    LSION 0
    LSIRDY 0
    LSE
    RTCEN 0
    Subsecond: 21319
    
  • Thank you for checking @Gordon
    Soldering these subatomic capacitors ain't going to be easy... ;)

    if there is going to be pico rev 1.5 soldered clock crystal and capacitors would be a good idea

  • No problem - hope you get it sorted. If you're thinking of doing any more surface mount stuff at all I could highly recommend a hot air rework station. The chinese ones are super cheap (under $50) and seem to work fine (it's what I use). They make stuff like this really easy.

    The problem really is just that of cost - almost every day someone tells me they're not buying Espruino boards because they're too expensive (maybe using ESP8266 instead). I guess one option could be to do a fully loaded Pico as a second product. Maybe Micro USB, watch crystal, and one of the huge new STM32F413 chips.

  • This is what I was thinking , pico rev 1.5 or pico pro if you will :)

    • build in watch crystal
    • micro usb instead of type A
    • replace 0.05 GPIO pins with extra 0.1 GPIO pins (0.05 are hard to access unless you surface mount unpinned pico ). I would definitely back it on Kickstarter ;)

    On the other hand a low cost very basic board would be an affordable option for people with limited budgets

  • You are basically describing an Espruino WiFi without the WiFi on it... Would one of them do you? It's not like you have to turn WiFi on: http://www.espruino.com/WiFi

    I think next on my list is probably a Bluetooth LE device on a 0.1" breakout board. There wouldn't be USB, but there's some fancy temperature-based drift correction in the RTC so it's actually pretty decent.

  • You are right ;)

    When I was buying my espruinos it was only pico and board available

  • What about adding bluetooth LE to the Espruino WIFI? That way it could act as a 'relay' for the Puck . (the puck only needs a coin battery whereas the wifi needs something more robust)...

  • I wonder how popular it'd be? The ideal solution there would be to add Bluetooth LE support to the ESP32 port, but that could be a bit tricky to make anything out of.

    You can actually attach an ESP8266 WiFi board (or even GSM!) directly to a Puck.js right now... So really I guess the most sensible option might be to come up with a board containing Puck.js's processor, but on a bare PCB that was easier to connect to?

  • Well, the use case is that I have a puck acting as a sensor (say a movement sensor attached to a door or temperature/light measurement) which is powered by the coin battery and lasts for months/years. I need to send the sensor results to something (a gateway) for further processing and/or recording that may require sending data to a cloud service - it will be powered by mains (or solar). That 'something' needs to have BLE to communicate with the puck as well as whatever other connectivity (eg HTTP) is needed.

    A raspberry pi would fit the bill quite well - but so would an espruino powered device with BLE + wifi - and be much simpler to programme!

    Attaching the wifi directly to the puck will require more power and negates the advantages of the long life that the puck currently enjoys...

    Just a thought...

    cheers...

  • Ahh - what I meant is you have a second Puck.js in your gateway. An ESP8266 board like this one already has a regulator, so it's just a matter of soldering 4 wires to a Puck and you're sorted: http://www.ebay.co.uk/itm/ESP8266-ESP-12­F-WiFi-Module-on-IoTBear-Adapter-Board-V­2-2-with-Voltage-Regulator-/172674450571­

    However, a Raspberry Pi W is $10 (plus a card) and does what you need, as well as providing stuff like SSH access and being available in a fancy box. Apart from being a simpler/easier to program, a fully-loaded Espruino board is a hard sell at 3 times the price :(

  • Ah yes - that's true. Haven't played with the W as yet, but as you say hard to compete with that as a gateway... The puck is in a league of its own though!

  • Yeah, they're great little things. I wish I could afford to get the prices of Espruino boards that low, but it's just a matter of volume. It costs me more to make the WiFi than the Pi W sells for - and that's even before I've shipped them back to the UK!

  • @Gordon
    The other option would be to add ble support to the Linux build and run that on a pi 3?

  • Yes, absolutely. It'd be very cool if someone were able to put the time in to implement Linux's BLE API - and it'd be a big help for separating it out enough that it could be implemented on other platforms too (ESP32?).

    There's still a small gotcha where the networking API uses 100% CPU while waiting for requests to finish on Linux, but to be honest that could be solved pretty easily.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Real time clock on Pico (rev 1.4)

Posted by Avatar for ancienthero @ancienthero

Actions