gobot: gobot.io/x/gobot/platforms/particle Index | Files

package particle

import "gobot.io/x/gobot/platforms/particle"

Package particle provides the Gobot adaptor for the Particle Photon and Electron.

Installing:

go get gobot.io/x/gobot && go install gobot.io/x/gobot/platforms/particle

Example:

package main

import (
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/drivers/gpio"
	"gobot.io/x/gobot/platforms/particle"
)

func main() {
	core := paticle.NewAdaptor("device_id", "access_token")
	led := gpio.NewLedDriver(core, "D7")

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

	robot := gobot.NewRobot("particle",
		[]gobot.Connection{core},
		[]gobot.Device{led},
		work,
	)

	robot.Start()
}

For further information refer to Particle readme: https://github.com/hybridgroup/gobot/blob/master/platforms/particle/README.md

Index

Package Files

adaptor.go doc.go

type Adaptor Uses

type Adaptor struct {
    DeviceID    string
    AccessToken string
    APIServer   string

    gobot.Eventer
    // contains filtered or unexported fields
}

Adaptor is the Gobot Adaptor for Particle

func NewAdaptor Uses

func NewAdaptor(deviceID string, accessToken string) *Adaptor

NewAdaptor creates new Photon adaptor with deviceId and accessToken using api.particle.io server as default

func (*Adaptor) AnalogRead Uses

func (s *Adaptor) AnalogRead(pin string) (val int, err error)

AnalogRead reads analog ping value using Particle cloud api

func (*Adaptor) AnalogWrite Uses

func (s *Adaptor) AnalogWrite(pin string, level byte) (err error)

AnalogWrite writes analog pin with specified level using Particle cloud api

func (*Adaptor) Connect Uses

func (s *Adaptor) Connect() (err error)

Connect returns true if connection to Particle Photon or Electron is successful

func (*Adaptor) DigitalRead Uses

func (s *Adaptor) DigitalRead(pin string) (val int, err error)

DigitalRead reads from digital pin using Particle cloud api

func (*Adaptor) DigitalWrite Uses

func (s *Adaptor) DigitalWrite(pin string, level byte) (err error)

DigitalWrite writes to a digital pin using Particle cloud api

func (*Adaptor) EventStream Uses

func (s *Adaptor) EventStream(source string, name string) (event *gobot.Event, err error)

EventStream returns a gobot.Event based on the following params:

* source - "all"/"devices"/"device" (More info at: http://docs.particle.io/api/#reading-data-from-a-core-events) * name - Event name to subscribe for, leave blank to subscribe to all events.

A new event is emitted as a particle.Event struct

func (*Adaptor) Finalize Uses

func (s *Adaptor) Finalize() (err error)

Finalize returns true if connection to Particle Photon or Electron is finalized successfully

func (*Adaptor) Function Uses

func (s *Adaptor) Function(name string, args string) (val int, err error)

Function executes a core function and returns value from request. Takes a String as the only argument and returns an Int. If function is not defined in core, it will time out

func (*Adaptor) Name Uses

func (s *Adaptor) Name() string

Name returns the Adaptor name

func (*Adaptor) PwmWrite Uses

func (s *Adaptor) PwmWrite(pin string, level byte) (err error)

PwmWrite writes in pin using analog write api

func (*Adaptor) ServoWrite Uses

func (s *Adaptor) ServoWrite(pin string, angle byte) (err error)

ServoWrite writes the 0-180 degree angle to the specified pin. To use it requires installing the "tinker-servo" sketch on your Particle device. not just the default "tinker".

func (*Adaptor) SetName Uses

func (s *Adaptor) SetName(n string)

SetName sets the Adaptor name

func (*Adaptor) Variable Uses

func (s *Adaptor) Variable(name string) (result string, err error)

Variable returns a core variable value as a string

type Event Uses

type Event struct {
    Name  string
    Data  string
    Error error
}

Event is an event emitted by the Particle cloud

Package particle imports 9 packages (graph). Updated 2019-07-01. Refresh now. Tools for package owners.