Skip to content

dryex/nerves_grove

Repository files navigation

Nerves.Grove

Project license Travis CI build status Coveralls.io code coverage Hex.pm package Hex.pm downloads Gratipay donations

Grove module support for the Nerves embedded software framework.

Supported Hardware

Grove Button Grove Buzzer Grove Collision Sensor Grove I2C ADC Grove LED Grove OLED Display 96×96 Grove Relay Grove Rotary Angle Sensor Grove Slide Potentiometer Grove Sound Sensor Grove Temperature Sensor

Reference

https://hexdocs.pm/nerves_grove/

Examples

Seeed Studio Grove Button

alias Nerves.Grove.Button

{:ok, pid} = Button.start_link(pin)

state = Button.read(pid)  # check if button is pressed

Seeed Studio Grove Buzzer

alias Nerves.Grove.Buzzer

{:ok, pid} = Buzzer.start_link(pin)

Buzzer.beep(pid, 0.1)  # make some noise for 100 ms
alias Nerves.Grove.Sensor

{:ok, pid} = Sensor.Collision.start_link(pin)

state = Sensor.Collision.read(pid)  # check if sensor was triggered

Seeed Studio Grove I2C ADC

alias Nerves.Grove.I2C

{:ok, pid} = I2C.ADC.start_link(address)

I2C.ADC.read_voltage(pid)
alias Nerves.Grove.LED

{:ok, pid} = LED.start_link(pin)

LED.blink(pid)
alias Nerves.Grove.OLED

{:ok, pid} = OLED.Display.start_link(address)

OLED.Display.reset(pid)
OLED.Display.clear(pid)
OLED.Display.set_text_position(pid, 0, 0)
OLED.Display.put_string(pid, "Hello, world")

Seeed Studio Grove Relay

alias Nerves.Grove.Relay

{:ok, pid} = Relay.start_link(pin)

Relay.on(pid)   # start current flow
Relay.off(pid)  # stop current flow
alias Nerves.Grove.Potentiometer

{:ok, pid} = Potentiometer.start_link(address)

Potentiometer.read_value(pid)

Seeed Studio Grove Sound Sensor

alias Nerves.Grove.Sensor

{:ok, pid} = Sensor.Sound.start_link(address)

Sensor.Sound.read_value(pid)
alias Nerves.Grove.Sensor

{:ok, pid} = Sensor.Temperature.start_link(address)

Sensor.Temperature.read_centigrade(pid)

Installation

Add nerves_grove to your list of dependencies in your project's mix.exs file:

defp deps do
  [{:nerves_grove, "~> 0.5.0"}]
end

Alternatively, to pull in the dependency directly from a Git tag:

defp deps do
  [{:nerves_grove, github: "bendiken/nerves_grove", tag: "0.5.0"}]
end

Alternatively, to pull in the dependency directly from a Git branch:

defp deps do
  [{:nerves_grove, github: "bendiken/nerves_grove", branch: "master"}]
end