Ways of Programming Espruino

When you've got your Espruino board, there are several different ways you can program it - they're detailed below:

Connection Types

USB

Normal Espruino boards have a USB connector, and when you plug this into your PC the board appears as a USB Serial device, which you can then connect to.

This is what we'd suggest programming Espruino devices with.

Bluetooth LE

Puck.js devices present themselves as as Bluetooth LE 'Nordic UART' device, and can be connected to and programmed through that. It's the suggested method of connection for Puck.js.

Adafruit make a Bluetooth LE UART board that can be used to add Bluetooth LE UART capability to other Espruino devices.

Serial / UART

When not connected to a computer by USB, Espruino boards usually open up a serial port on two of their pins at 9600 baud so that they can be programmed via Serial. The pins used for this are detailed in the Pinout section of your board's specific reference page (eg the Pico, where they're marked with !).

To save power, Puck.js only powers up the serial port if it detects a voltage on the RX pin at boot time. See Puck.js

Bluetooth UART

The Original Espruino Board has a footprint on the back for an HC-05/HC-06 Bluetooth Module. Once soldered, it uses the standard Serial port (detailed above) for communication. For more information see here.

Standard Bluetooth is not the same as Bluetooth LE, and can't be used to communicate from a Website.

WiFi/Ethernet

Currently Espruino boards don't come with Telnet support out of the box. If you're running Espruino on an ESP8266 then Telnet is enabled.

On other boards, once you have a network connection established you can run:

require("net").createServer(function (connection) {
  connection.pipe(LoopbackA);
  LoopbackA.pipe(connection);
  LoopbackB.setConsole();
}).listen(23);

However, using reset() will break your connection.

Headphone Jack

Yes, it is even possible to program Espruino from your headphone jack with a few external components! See here!

Applications

Espruino Web IDE

This is what we'd suggest you use for programming Espruino. It comes in a few flavours:

  • Chrome Web App - we'd suggest this for USB Espruino devices, and it's nice and easy to install.
  • Online - should be used for Bluetooth LE based Espruinos (Puck.js). It is amazingly easy to use (just go here in Chrome), however it doesn't yet work on Windows without (some effort). It does however support using your headphone jack!!
  • Native App is needed to communicate with Bluetooth LE devices like Puck.js on Windows.
  • Locally hosted IDE can be run on a Raspberry Pi, and can allow you to program Puck.js devices through any Web Browser that has access to your local network.

Despite being called a 'Web IDE', the IDE itself (including the fully online version) can function without an internet connection. If you're using modules you may need to download 'offline data' under settings first though!

Espruino Command-line tool

If you have node.js with npm you can install the Espruino command-line tools with npm install -g espruino.

These support USB, Serial, Bluetooth UART (once paired), Bluetooth LE, and Telnet.

You can:

# List what ports are available
espruino --list

# Connect to Espruino and provide a REPL (Ctrl-C exits)
espruino -p your_port

# Connect to Espruino and upload a file
espruino -p your_port code.js

# Connect to Espruino, provide a REPL, and upload the file whenever it changes
espruino -p your_port -w code.js

And much more besides! Full information is here

Third party tools

There are also several third party tools for Espruino available. Some of these may not provide some of the features (like module loading) that are used by tutorials and example code on the Espruino website, and may refuse to upload code that isn't formatted in a K&R style.

  • DroidScript lets you control/program an Espruino from an Android phone
  • espruino-cli is a node.js command-line tool for Espruino
  • espruino-cli is another node.js command-line tool for Espruino. It may not work on newer versions of Node.js

Serial Terminals

You can even program Espruino directly from a Terminal application (if using Serial or Telnet), you'll just be lacking some of the code upload features. See Alternative Terminal Apps for more information.

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.