Real time clock on Pico (rev 1.4)

Posted on
Page
of 2
/ 2
Next
  • 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.

  • are this:
    Capacitors: http://ebay.eu/2yWBy9u
    Quarz: http://ebay.eu/2hJBupe

    correct for espruino pico ?

  • ...expensive...

    (accidentally created 2 posts... so read next)

  • ...expensive...

    may be you have to put a lot of hot air next to the Pico or Wifi or Puck on a big board a thick fat ceramic resistor across + and - and sell it for... you know: where no costs on acquiring and operating, no pain and gain - impression is it called (With cars it is: Nothing can replace displacement!... except TESLA... Nothing wrong with Muscle cars - @Gordon, did you not do such things in your past? ...do you still do it?... but after washing the hands, fine (French) dining is an excellent (hybrid) combination.

    I'm amazed how much tinkering time goes into opportunity cost to try to beat something by a few £ (GPB) or $ (USD)... by standing on a giant shoulder ground without having had to pay for it... But it is still an inspiring challenge...

    Btw, keep your coins save in Fr (CHF)... you will get it later... (not working for me: I'm by US imposed Freedom Bank Rules and Treaties with CH (Banks?) forbidden to have as a Swiss citizen a (CHF) Bank account at a Swiss Bank in my home Country... actually it is not really the rules... I just do not have enough coins to comply with and pass the lower limit... and of course, there is no upper limit... not helpful either).

    I wonder why there is something like the PADI from Pine64.org for $1.99... to buy. May be it is a 8266-clone custom ordered in orbitant high numbers... but it is silent about how easy you get code done... SW development falls back into middle ages... for things it has not really to do it. The maker space is not looking for more and harder C/C++... - impressive though the 30mA for Wifi... just don't know the test/measurement conditions.

    I know that PINE46 kickstarter was a killer - AND (close to) KILLING - success (on the good side: PINE64 hired private China Post postal worker to get the shipment done... on the not so fun side: dead threats and police protection from inpatient pledgers got mentioned in the communication... not so fun language was the least to worry). I do not know how things moved on, but more recent is a board out - ROCK64 - that for sure cannot live anymore of less than 500mA, as one of the kill factors were in the kickstarter... Burning nKmA is just more the same of Raspberri Pi #+ (sure may be better, but not as popular... yet). As long (large) investments flow into this booming MC business until the thinning sets in due to ROI not happening, more jungle book episodes are to be expected. Not the first time in history big orgs buy the market with lots of money for an inferior product -
    with success (How about the I.. 8088 PC?). Took quite quickly the markets abut catch up on technology tock a few decades (including overcoming the stand-up commedy worthy P fdiv Episode.

    Anyway... was a bit a ramble (and it goes on for a bit more).

    I stick to my few things - horses - that serve me well and leave fashion to others... they will reshow anyway... in circle cycles... Yes, once in a while I renew my wardrobe too.. but I keep my 'gatlings' and 'winchesters'... just as Swiss' have some nice blank and capable metal standing next to the hanging and neatly folded cloths.

    JS was declared dead by some large corporations around Y2K... and guess what: like Java and its robust VMs run under the hood, so runs JavaScript and its matured VMs as 'dessous' under many fancy, shiny client AND server 'prêt-à-porter' apparel... (Honi soit qui mal y pense!). Just to notice, Java disappeared form the client (except on power mobiles)... and even then, many just send to/create on the devices HTML with embedded JavaScript to show affordable and maintainable UX/life.

  • @L0cutus yes, those parts look spot on.

    @allObjects I'm not quite sure I understand? The PADI looks pretty interesting though - it's nice if see ARM WiFi chips hitting ESP8266 prices in maker quantities.

    But yes, I still have the VX220 - although with everything else going on I swapped the engine back to a standard one so it gets a bit more use now :)

  • 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