An Elixir wrapper around [MySensors]
(https://github.com/mysensors/MySensors).
specifically mysgw
. This allows driving the nrf24
chip directly off the
SPI bus on Nerves devices.
The default mysgw
configure script
doesn't easily allow for cross-compilation. (Something that Nerves requires).
A couple source file also need to be patched to allow for Erlang to start the
program as a port
. See these threads for more info on this:
# Disable logs
config :my_sensors_mysgw, MySensors.MySGW.Logger, [
level: false
]
# Configure meta information
config :my_sensors_mysgw, MySensors.MySGW.Logger, [
level: :info,
meta: [:some, "cool", 'info']
]
# Don't start the daemon.
config :my_sensors_mysgw, MySensors.MySGW.Application, [
daemon: false
]
# Start the daemon later: (this is blocking, spawn it)
MySensors.MySGW.start_gw()
# Configure eeprom + config_file location
config :my_sensors_mysgw, MySensors.MySGW, [
eeprom_file: "/root/mysensors.eeprom",
config_file: "/root/mysensors.conf"
]
For Raspberry Pi devices you can follow [the guide provided by mysensors] (https://www.mysensors.org/build/raspberry#wiring)
There is no wiring guide for beaglebone based devices. Wiring is similar
to Raspberry Pi. Match the pin names between the radio and beaglebone.
You will also need to set my_sensors_mysgw_spi_dev
in your mix.exs
project config.
def project do
[
# ...
my_sensors_mysgw_spi_dev: "/dev/spidev1.0",
# ...
]
end
You will probably need to configure your the pins outside of spi_dev
.
def project do
[
# ...
my_sensors_mysgw_spi_dev: "/dev/spidevStopCopyPastingThings",
my_sensors_mysgw_irq_pin: 9000,
my_sensors_mysgw_cs_pin: 9001,
my_sensors_mysgw_ce_pin: 9002,
# ...
]
end
If you are running my_sensors
on the same device as my_sensors_mysgw
:
iex()> MySensors.Gateway.add_transport(MySensors.Transport.TCP, [])
otherwise:
iex()> MySensors.Gateway.add_transport(MySensors.Transport.TCP, [host: 'nerves.local'])
The Makefile in this package requires tar
and wget
when building as a hex
package. This is because the MySensors code is a submodule. PRs welcome.
THe MySensors
code is liscensed under GPLv2, the Elixir code is licensed under
MIT.