Giter VIP home page Giter VIP logo

firmatacurieimu's Introduction

FirmataCurieIMU

Firmata wrapper for the CurieIMU library on the Arduino101

Installation

  1. Make sure you have the following dependencies installed in the libraries folder for your Arduino installation:
  1. Clone or download and copy FirmataCurieIMU into the libraries folder for your Arduino installation:

How to use

The simplest possible example that connects the CurieIMU devices, but nothing else within the Firmata interface, would be as follows:

#include <ConfigurableFirmata.h>
#include <FirmataExt.h>
FirmataExt firmataExt;

#include <CurieIMU.h>
#include <FirmataCurieIMU.h>
FirmataCurieIMU curieIMU;

void systemResetCallback()
{
  firmataExt.reset();
}

void setup()
{
  Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);

  firmataExt.addFeature(curieIMU);

  Firmata.attach(SYSTEM_RESET, systemResetCallback);
  Firmata.begin(57600);

  // set reset to default config
  systemResetCallback();
}

void loop()
{
  while (Firmata.available()) {
    Firmata.processInput();
  }
}

As with any other sketch that uses ConfigurableFirmata, you can choose to include digital, analog, i2c, or any other interface that it supports. There are several examples of sketches that use ConfigurableFirmata along with FirmataCurieIMU in the examples directory.

Firmata clients

JavaScript

Example code that calls the FirmataCurieIMU SYSEX extended interface is here:

https://github.com/intel-iot-devkit/firmata-curie-imu.js

Protocol

Read accelerometer

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_ACCEL       (0x00)
 * 3 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_ACCEL       (0x00)
 * 3 x axis, bits 0-6 (LSB)
 * 4 x axis, bits 7-13 (MSB)
 * 5 y axis, bits 0-6 (LSB)
 * 6 y axis, bits 7-13 (MSB)
 * 7 z axis, bits 0-6 (LSB)
 * 8 z axis, bits 7-13 (MSB)
 * 9 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Read gyro

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_GYRO        (0x01)
 * 3 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_GYRO        (0x01)
 * 3 x axis, bits 0-6 (LSB)
 * 4 x axis, bits 7-13 (MSB)
 * 5 y axis, bits 0-6 (LSB)
 * 6 y axis, bits 7-13 (MSB)
 * 7 z axis, bits 0-6 (LSB)
 * 8 z axis, bits 7-13 (MSB)
 * 9 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Read temperature

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_TEMP        (0x02)
 * 3 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_TEMP        (0x02)
 * 3 int16 temperature, byte 0, bits 0-6 (LSB)
 * 4 int16 temperature, byte 0, bits 7-13 (MSB)
 * 5 int16 temperature, byte 1, bits 0-6 (LSB)
 * 6 int16 temperature, byte 1, bits 7-13 (MSB)
 * 7 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Enable shock detection

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_SHOCK_DETECT     (0x03)
 * 3 enable/disable, bit 0
 * 4 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

NONE

To enable shock detection, send 1 as the enable flag (byte 3). To disable shock detection, send 0 as the enable flag (byte 3).

Message

When shock detection is enabled, the following message will be sent each time that a shock is detected:

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_SHOCK_DETECT     (0x03)
 * 3 axis (bits 0-3)
 * 4 direction (bit 0)
 * 5 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Enable step counter

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_STEP_COUNTER     (0x04)
 * 3 enable/disable, bit 0
 * 4 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

NONE

To enable step detection, send 1 as the enable flag (byte 3). To disable step detection, send 0 as the enable flag (byte 3).

Message

When step counting is enabled, the following message will be sent each time a new step is registered:

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_STEP_COUNTER     (0x04)
 * 3 step count, bits 0-6 (LSB)
 * 4 step count, bits 7-13 (MSB)
 * 5 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Enable tap detection

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_TAP_DETECT       (0x05)
 * 3 enable/disable, bit 0
 * 4 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

NONE

To enable tap detection, send 1 as the enable flag (byte 3). To disable tap detection, send 0 as the enable flag (byte 3).

Message

When tap detection is enabled, the following message will be sent each time a tap is detected:

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_TAP_DETECT       (0x05)
 * 3 axis (bits 0-3)
 * 4 direction (bit 0)
 * 5 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Read motion sensor

Query

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_MOTION      (0x06)
 * 3 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

Response

 /* -----------------------------------------------------
 * 0 START_SYSEX                (0xF0)
 * 1 CURIE_IMU                  (0x11)
 * 2 CURIE_IMU_READ_MOTION      (0x06)
 * 3 x axis accelerometer, bits 0-6 (LSB)
 * 4 x axis accelerometer, bits 7-13 (MSB)
 * 5 y axis accelerometer, bits 0-6 (LSB)
 * 6 y axis accelerometer, bits 7-13 (MSB)
 * 7 z axis accelerometer, bits 0-6 (LSB)
 * 8 z axis accelerometer, bits 7-13 (MSB)
 * 9 x axis gyro, bits 0-6 (LSB)
 * 10 x axis gyro, bits 7-13 (MSB)
 * 11 y axis gyro, bits 0-6 (LSB)
 * 12 y axis gyro, bits 7-13 (MSB)
 * 13 z axis gyro, bits 0-6 (LSB)
 * 14 z axis gyro, bits 7-13 (MSB)
 * 15 END_SYSEX                  (0xF7)
 * -----------------------------------------------------
 */

firmatacurieimu's People

Contributors

deadprogram avatar justindevelopment avatar arfoll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.