Differences between Arduino and Espruino code

Here are some common 'gotchas' you might encounter when moving from writing Arduino code to writing Espruino code. This might be especially helpful when 'porting' existing code.

There is no delay() function

This is intentional, as adding a delay will stop Espruino doing other things. Instead, for large delays (>5ms) use setTimeout to execute the second set of code after a time period:

So the following:

// some commands 1
// some commands 2


// some commands 1
setTimeout(function() {
  // some commands 2
}, 500);


Espruino doesn't have millis(). It has getTime(), which reports the current time in seconds as a floating point number.

Unlike most Arduinos, Espruino contains a Real Time Clock which allows it to keep track of time and date very accurately. This means you don't need an external RTC, and can instead use the Date class.

There is no loop() function

A lot of Arduino code uses the following pattern:

void call_me_from_loop() {
  if (millis() > last_time_called+1000) {
    last_time_called = millis();

    // do stuff

In Espruino, this is really inefficient because it stops Espruino from sleeping when it knows it doesn't need to do anything. It's also needlessly complex.

Instead, use the following:

setInterval(function() {
  // do stuff
}, 1000);

Analog IO

Other IO

Library Functions


Found something else?

Please let us know in the Forum...

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