Ruuvitag

Ruuvitag

The Ruuvitag is a Bluetooth LE beacon with an environment sensor and accelerometer built in.

Full details on flashing Ruuvitag can be found at https://ruu.vi/setup

Binaries can be found in:

Using

Ruuvitag can be used like any other Espruino Bluetooth LE device, with full access to the NRF class for BLE Functionality.

Check out the Getting Started Guide

However to use the built-in sensors you will need to use the Ruuvitag library. For instance to get data, use:

var Ruuvitag = require("Ruuvitag");
Ruuvitag.setEnvOn(true);
Ruuvitag.setAccelOn(true);
console.log(Ruuvitag.getEnvData());
// prints { "temp": 23.70573815741, "pressure": 1017.27733597036, "humidity": 42.0771484375 }
console.log(Ruuvitag.getAccelData());
// prints { "x": 3.90625, "y": -7.8125, "z": 984.375 }

You can also call a function whenever acceleration data is received:

var Ruuvitag = require("Ruuvitag");
Ruuvitag.setAccelOn(true, function(xyz) {
  console.log(xyz);
});

By default Espruino uses the low power accelerometer mode, however the peripherals can be accessed directly:

  • Ruuvitag.env is an instance of the BME280 environment sensor library
  • Ruuvitag.accel is an instance of the LIS2DH12 accelerometer library

Saving Code

Normally, uploading code to Espruino will put everything in RAM and it will be lost when power is removed. You can type save() on the left-hand side of the IDE to save to Flash memory though (more information).

When you do that, the sensors will require initialising at power on (so may not work if you 'just' save your code). You'll need to create an onInit function like this, where you turn the sensors' power on at boot time:

var Ruuvitag = require("Ruuvitag");

function onInit() {
  Ruuvitag.setAccelOn(true, function(xyz) {
    console.log(xyz);
  });
}

Tutorials

First, it's best to check out the Getting Started Guide

Tutorials using Bluetooth LE:

About Bluetooth LE (BLE)About Bluetooth LE (BLE)BLE Advertising with Node.js/Python/C#/AndroidBLE Advertising with Node.js/Python/C#/AndroidControlling Bluetooth Lights with Puck.jsControlling Bluetooth Lights with Puck.jsControlling Other BLE Espruino DevicesControlling Other BLE Espruino DevicesExercise Machine controlled VideoExercise Machine controlled VideoGetting Started with Puck.jsGetting Started with Puck.jsPixl.js Bluetooth to Ethernet MQTT BridgePixl.js Bluetooth to Ethernet MQTT BridgePixl.js SMS Remote MonitoringPixl.js SMS Remote MonitoringPuck.js Bluetooth with the Graphical EditorPuck.js Bluetooth with the Graphical EditorPuck.js MIDIPuck.js MIDIPuck.js Music ControllerPuck.js Music ControllerPuck.js Security and Access ControlPuck.js Security and Access ControlPuck.js and BLE PrintersPuck.js and BLE PrintersPuck.js and BLE UARTsPuck.js and BLE UARTsPuck.js and Eddystone BeaconsPuck.js and Eddystone BeaconsPuck.js and HID KeyboardsPuck.js and HID KeyboardsPuck.js and HTTP ProxiesPuck.js and HTTP ProxiesPuck.js and If This Then ThatPuck.js and If This Then ThatPuck.js and Node-RED with MQTTPuck.js and Node-RED with MQTTPuck.js and iBeaconsPuck.js and iBeaconsPuck.js with SMS controlPuck.js with SMS controlQuick Start (Bluetooth LE)Quick Start (Bluetooth LE)Using Puck.js from a Web Bluetooth WebsiteUsing Puck.js from a Web Bluetooth WebsiteWeb Bluetooth on LinuxWeb Bluetooth on LinuxWeb IDE on a Raspberry PiWeb IDE on a Raspberry Pi

Tutorials using Bluetooth LE and functionality that may not be part of Ruuvitag:

Door Controlled Light with Puck.jsDoor Controlled Light with Puck.jsInfrared Record and Playback with Puck.jsInfrared Record and Playback with Puck.jsPixl.js Wireless Temperature DisplayPixl.js Wireless Temperature DisplayPixl.js Wireless Weather StationPixl.js Wireless Weather StationTemperature Controlled Night Light with Puck.jsTemperature Controlled Night Light with Puck.js

Reference

// Set whether the environmental sensor is on or off
exports.setEnvOn = function (on) { ... }

/* Set whether the accelerometer is on or off. A callback can be supplied
  which will be called with an {x,y,z} argument
*/
exports.setAccelOn = function (on, callback) { ... }

// Get the last received environment data { temp: degrees_c, pressure: kPa, humidity: % }
exports.getEnvData = function (on) { ... }

// Get the last received accelerometer data, or undefined
exports.getAccelData = function (on) { ... }

Firmware Updates

Check out Ruuvi's DFU instructions

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