NRF51822 - anyone still using it?

Posted on
  • there is the microbit v1 and there is some thread about NRF51TAG here­320879/ also some fitness tracker attempts here­342982/

    Is anyone still using it?

    Just made a fresh 2.10 build for bare nrf51 module with 16K RAM and found it somehow broken. Also the number of variables in Microbit V1 board file proved to be quite unrealistic, I had to go far below 300 to let webide connect and read board info as the board JSON would not print due to low stack.

    I tried some additional trimming to enable some other features (like native code via inline C or arrow functions to enable button to view storage files in WebIDE - It calls require('Storage').list().forEach(x=>pri­nt(JSON.stringify(x))); ). Again with that complex expression I had to reduce variables even more to 250 to allow even more stack so the JSON.stringify(x) inside that forEach would still produce some data instead of " ... "

    Then with various builds I triggered unaligned jsVars array so it would crash completely at startup with new compact variables code. And when I got it somehow into shape and tried some bluetooth scanning code (NRF.findDevices, NRF.setScan) it again crashed/freezed/disconnected randomly so I noticed that nrf51 code path disables interrupts completely when working with JS variables which the SoftDevice doesn't like. After fixing that, NRF.findDevices would still not work correctly. It triggers low memory condition making console unusable with flood of "interrupted" messages even with simple NRF.findDevices((x)=>print(x),1000) with ~15 devices around. So looked into .data and .bss segment size usage and managed to reduce some usage to go up with variable to current 286 and 8 flash pages for Storage.

    Now pasting simple code like

    function findDevices(cb){
      var devs = {};
      var nonew=0;
      function add(x){
        if (!devs) return;
        if ( in devs) {
          if (++nonew>30) {NRF.setScan(undefined);setTimeout(()=>{­cb(devs);devs=undefined;},0);}
        } else {devs[];nonew=0;}

    does not crash or produce console errors and finds all my devices around even when the function is in RAM. But adding any more code pushes it over the edge (like enabling watchdog and kicking it from setInterval). Moving the code to flash would certainly make it better, however not sure whether with ~290 variables I could e.g. draw to small OLED display while also having some bluetooth code there (=51822 fitness tracker usage).

    Anyway, wanted to ask, is anyone still trying to use microbit v1 or any other 51822 device with Espruino? If yes, what use cases still work for you? Maybe some old Espruino versions are better?

    I found there are some cheap 51822 boards on aliexpress claiming to have the QFAC 32K RAM variant so ordered few to test how usable that would be. However the 16K version module I have seems barely usable for any a bit more advanced code.

    EDIT: boards from aliexpress arrived, they have QFAA with 16kB despite description and images claiming QFAC/32kB :-(
    item link removed

  • I think some folks are (or were) using micro:bit firmwares. It did work better in the past, at least for simple stuff using setAdvertising. I think setScan was always a bit flakey though.

    It'd be great to get it back working properly though, if only because I've got a friend with a bunch of micro:bits who wants to build a big display out of them - and it'd be so easy with Espruino if setScan worked ok - but I think you may have fixed that already :)

  • With recent merges nrf51 should have more free ram +488 bytes for recent MICROBIT1 build ~= 40 variables or more room in stack. Also some flash was saved during the process so even stock MICROBIT1 build can have 5 flash pages for storage now.

    I don't have any microbit 1 so can't test but now also the hardware i2c can be removed from the build so current microbit sensor code could use software i2c possibly saving some further tiny bits of ram and flash (and even power?).

    As for my build for generic nrf51 module I am back to using 300 variables and listing and viewing files in storage in WebIDE works :) Also I have 6 pages of storage with some extra features enabled like arrow functions, Inline C, watchdog

  • I just got a few 51822 boards, all with 16K RAM (same story: seller claimed QFAC). Can you tell me what to define/comment out so I can make a minimal working build? I'm hoping to use them as simple bluetooth switches.

  • Best bet is to look at the MICROBIT1 build file and just strip out anything that references Microbit - then I think you should be ok...

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

NRF51822 - anyone still using it?

Posted by Avatar for fanoush @fanoush