curie

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2017 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

README

Curie

The Intel Curie is a tiny computer for the Internet of Things. It is the processor used by the Arduino/Genuino 101 and the Intel TinyTILE.

In addition to the GPIO, ADC, and I2C hardware interfaces, the Curie also has a built-in Inertial Measurement Unit (IMU), including an accelerometer, gyroscope, and thermometer.

For more info about the Intel Curie platform go to: https://www.intel.com/content/www/us/en/products/boards-kits/curie.html.

How to Install

You would normally install Go and Gobot on your computer. When you execute the Gobot program code, it communicates with the connected microcontroller using the Firmata protocol, either using a serial port, or the Bluetooth LE wireless interface.

go get -d -u gobot.io/x/gobot/...

How To Use

package main

import (
	"log"
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/drivers/gpio"
	"gobot.io/x/gobot/platforms/firmata"
	"gobot.io/x/gobot/platforms/intel-iot/curie"
)

func main() {
	firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
	led := gpio.NewLedDriver(firmataAdaptor, "13")
	imu := curie.NewIMUDriver(firmataAdaptor)

	work := func() {
		imu.On("Accelerometer", func(data interface{}) {
			log.Println("Accelerometer", data)
		})

		imu.On("Gyroscope", func(data interface{}) {
			log.Println("Gyroscope", data)
		})

		imu.On("Temperature", func(data interface{}) {
			log.Println("Temperature", data)
		})

		gobot.Every(1*time.Second, func() {
			led.Toggle()
		})

		gobot.Every(100*time.Millisecond, func() {
			imu.ReadAccelerometer()
			imu.ReadGyroscope()
			imu.ReadTemperature()
		})
	}

	robot := gobot.NewRobot("curieBot",
		[]gobot.Connection{firmataAdaptor},
		[]gobot.Device{imu, led},
		work,
	)

	robot.Start()
}

How to Connect

Installing Firmware

You need to flash your Intel Curie with firmware that uses ConfigurableFirmata along with the FirmataCurieIMU plugin. There are 2 versions of this firmware, once that allows connecting using the serial interface, the other using a Bluetooth LE connection.

To setup your Arduino environment:

  • Install the latest Arduino, if you have not done so yet.

  • Install the "Intel Curie Boards" board files using the "Board Manager". You can find it in the Arduino IDE under the "Tools" menu. Choose "Boards > Boards Manager".

    Search for the "Intel Curie Boards" package in the "Boards Manager" dialog, and then install the latest version.

  • Download the ZIP file for the ConfigurableFirmata library. You can download the latest version of the ConfigurableFirmata from here:

    https://github.com/firmata/ConfigurableFirmata/archive/master.zip

    Once you have downloaded ConfigurableFirmata, install it by using the "Library Manager". You can find it in the Arduino IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the ConfigurableFirmata library that you just downloaded.

  • Download the ZIP file for the FirmataCurieIMU library. You can download the latest version of FirmataCurieIMU from here:

    https://github.com/intel-iot-devkit/firmata-curie-imu/archive/master.zip

    Once you have downloaded the FirmataCurieIMU library, install it by using the "Library Manager". You can find it in the Arduino IDE under the "Sketch" menu. Choose "Include Library > Add .ZIP Library". Select the ZIP file for the FirmataCurieIMU library that you just downloaded.

  • Linux only: On some Linux distributions, additional device rules are required in order to connect to the board. Run the following command then unplug the board and plug it back in before proceeding:

    curl -sL https://raw.githubusercontent.com/01org/corelibs-arduino101/master/scripts/create_dfu_udev_rule | sudo -E bash -
    

Now you are ready to install your firmware. You must decide if you want to connect via the serial port, or using Bluetooth LE.

Serial Port

To use your Intel Curie connected via serial port, you should use the sketch located here:

https://github.com/intel-iot-devkit/firmata-curie-imu/blob/master/examples/everythingIMU/everythingIMU.ino

Once you have loaded this sketch on your Intel Curie, you can run your Gobot code to communicate with it. Leave your Arduino 101 or TinyTILE connected using the serial cable that you used to flash the firmware, and refer to that same serial port name in your Gobot code.

Bluetooth LE

To use your Intel Curie connected via Bluetooth LE, you should use the sketch located here:

https://github.com/intel-iot-devkit/firmata-curie-imu/blob/master/examples/bleIMU/bleIMU.ino

Once you have loaded this sketch on your Intel Curie, you can run your Gobot code to communicate with it.

Power up your Arduino 101 or TinyTILE using a battery or other power source, and connect using the BLE address or name. The default BLE name is "FIRMATA".

Documentation

Overview

Package curie contains the Gobot driver for the Intel Curie IMU.

For further information refer to intel-iot README: https://github.com/hybridgroup/gobot/blob/master/platforms/intel-iot/curie/README.md

Index

Constants

View Source
const (
	CURIE_IMU              = 0x11
	CURIE_IMU_READ_ACCEL   = 0x00
	CURIE_IMU_READ_GYRO    = 0x01
	CURIE_IMU_READ_TEMP    = 0x02
	CURIE_IMU_SHOCK_DETECT = 0x03
	CURIE_IMU_STEP_COUNTER = 0x04
	CURIE_IMU_TAP_DETECT   = 0x05
	CURIE_IMU_READ_MOTION  = 0x06
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccelerometerData

type AccelerometerData struct {
	X int16
	Y int16
	Z int16
}

AccelerometerData is what gets returned with the "Accelerometer" event.

type GyroscopeData

type GyroscopeData struct {
	X int16
	Y int16
	Z int16
}

GyroscopeData is what gets returned with the "Gyroscope" event.

type IMUDriver

type IMUDriver struct {
	gobot.Eventer
	// contains filtered or unexported fields
}

IMUDriver represents the IMU that is built-in to the Curie

func NewIMUDriver

func NewIMUDriver(a *firmata.Adaptor) *IMUDriver

NewIMUDriver returns a new IMUDriver

func (*IMUDriver) Connection

func (imu *IMUDriver) Connection() gobot.Connection

Connection returns the IMUDriver's Connection

func (*IMUDriver) EnableShockDetection

func (imu *IMUDriver) EnableShockDetection(detect bool) error

EnableShockDetection turns on/off the Curie's built-in shock detection. The result will be returned by the Sysex response message

func (*IMUDriver) EnableStepCounter

func (imu *IMUDriver) EnableStepCounter(count bool) error

EnableStepCounter turns on/off the Curie's built-in step counter. The result will be returned by the Sysex response message

func (*IMUDriver) EnableTapDetection

func (imu *IMUDriver) EnableTapDetection(detect bool) error

EnableTapDetection turns on/off the Curie's built-in tap detection. The result will be returned by the Sysex response message

func (*IMUDriver) Halt

func (imu *IMUDriver) Halt() (err error)

Halt stops the IMUDriver

func (*IMUDriver) Name

func (imu *IMUDriver) Name() string

Name returns the IMUDriver's name

func (*IMUDriver) ReadAccelerometer

func (imu *IMUDriver) ReadAccelerometer() error

ReadAccelerometer calls the Curie's built-in accelerometer. The result will be returned by the Sysex response message

func (*IMUDriver) ReadGyroscope

func (imu *IMUDriver) ReadGyroscope() error

ReadGyroscope calls the Curie's built-in gyroscope. The result will be returned by the Sysex response message

func (*IMUDriver) ReadMotion

func (imu *IMUDriver) ReadMotion() error

ReadMotion calls the Curie's built-in accelerometer & gyroscope. The result will be returned by the Sysex response message

func (*IMUDriver) ReadTemperature

func (imu *IMUDriver) ReadTemperature() error

ReadTemperature calls the Curie's built-in temperature sensor. The result will be returned by the Sysex response message

func (*IMUDriver) SetName

func (imu *IMUDriver) SetName(n string)

SetName sets the IMUDriver'ss name

func (*IMUDriver) Start

func (imu *IMUDriver) Start() (err error)

Start starts up the IMUDriver

type MotionData

type MotionData struct {
	AX int16
	AY int16
	AZ int16
	GX int16
	GY int16
	GZ int16
}

MotionData is what gets returned with the "Motion" event.

type ShockData

type ShockData struct {
	Axis      byte
	Direction byte
}

ShockData is what gets returned with the "Shock" event.

type TapData

type TapData struct {
	Axis      byte
	Direction byte
}

TapData is what gets returned with the "Tap" event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL