Espruino - Program nRF5 devices in JavaScript - See the Puck.js kickstarter

image description

Quick start (< 5 minutes)

  • Download the Espruino Web IDE from the Chrome web store.
  • Drag-and-drop espruino_nrf51.hex or espruino_nrf52.hex to your nRF51/nRF52 Development Kit. Espruino will run on any board with an nRF5 chip, i.e. the Microbit.
  • Open the Espruino Web IDE, select the COM port your nRF5 device is connected to, and start writing JavaScript immediately!

image description

Follow along with the code in the screen-shot below! (Remember the LEDs are inverted on Nordic DKs).

image description

If you run into any trouble or want more info, see: http://www.espruino.com/Quick+Start.

##What is Espruino?

Espruino is a JavaScript run-time that allows resource constrained MCUs (like nRF5 devices) to be programmed entirely in JavaScript. Espruino is open source and community driven, and has had 3 very successful kick-starter campaigns. The most recent kick-starter, Puck.js, features the nRF52 and was fully funded in less than 24 hours! It just started so check it out here: https://www.kickstarter.com/projects/gfw/puckjs-the-ground-breaking-bluetooth-beacon.

Espruino has shipped on over 12,000 boards over the last 3 years, and Nordic started working with them in August 2015 to support nRF5 series devices. Espruino uses Nordic's most recent nRF5 SDK and s130/s132 SoftDevices to expose a very simple and intuitive JavaScript API for many of the peripherals, and BLE (both central and slave capabilities). In addition it implements a lot of the JavaScript standard library. See Espruino FAQs.

Why?

The great thing about using JavaScript is that it opens up the world of microcontrollers to web developers. Boards like Espruino, together with online courses in JavaScript offered by people like CodeAcademy, will provide an easier route for beginners to get into programming. The interactive nature of the interpreter makes it easier to interface to different devices (LCDs, accelerometers, etc...) because commands can be tested one at a time.

The use of JavaScript means you can interpret, inspect and modify your code on the fly. This is different from most existing micro-controllers which run C. It can be like running code in a black box (literally) when you aren't debugging. For example, Espruino's interactive console allows users to enter code such as 'analogRead(LIGHT_SENSOR);' and have it executed, and the result returned immediately. This makes it very different from something like Arduino which requires you to write code, compile, and then upload it to a device. Having an immediate response (good or bad!) to the code you type makes using Espruino a very rewarding experience, and makes it much easier to learn.

JavaScript is also, of course, a familiar and popular language which will be recognized by millions of people around the world, including those who have not learnt to program in C.

Features

  • Event-based nature of JavaScript allows you to easily write energy-efficient code.
  • Built-in HTTP server with support for Ethernet, WiFi and GSM modules.
  • Built-in SD card and FAT filesystem support.
  • Built-in Graphics and Crypto libraries.
  • You can program nRF devices over BLE, no wires needed! https://www.youtube.com/watch?v=HKEHXOSLzCQ.
  • Built-in text mode debugger available, which allows you to step through your code line by line. The commands used are almost identical to those in GDB. http://www.espruino.com/Debugger.

References

Getting involved

To get involved or see the source code see: https://github.com/espruino. Also see the gitter.

There are many different components to this project: hardware/PCB design, firmware, web dev, building and showing off cool projects with Espruino, etc... Feel free to dive in!

Anonymous
  • Nowadays, an online presence for any business big or small is quite integral to their existence. A reliable Manchester website designing company can work wonders for a brand along with creating an engaging platform for its target audience.

  • Thanks Michael,

    I flashed a nrf52 module with provided espruino_nrf52.hex file using NrfGo Studio and it shows that it programmed application, softdevice and bootloader successfully. However, I can't seem to scan this BLE device on lightblue ios app or add as a Windows bluetooth device.

    Any ideas?

     device in any

  • Hey @Keton,

    Thanks for pointing this out. This should be a quick fix (we've been doing some bootloader/dfu stuff for nRF5 and broke save() on nRF5 in the process). I'd recommend just making an issue in the GitHub, but it will probably be fixed pretty soon anyways.

    If you want to get your hands dirty: Building Espruino. Just note that it is much easier to build Espruino on Linux and it uses gcc arm-none-eabi just like our sdk to build.

  • @mjdietz2 save() function is broken in nRF52 hex files you've attached as well as in the newest code on GitHub. I've found some info that version 1.85 should work but i can't compile it. If you by some chance have access to 1.85 hex files or know which toolchain is needed to compile it please advise.