Raspberry Pi is a small computer that uses very little power (2-3 watts). It has all the horsepower necessary to serve as a cloud-enabled all-in-one Controller.
Several controllers available here can run directly on the RPi. E.g. OpenHAB and PiDome.
Install and Build
Login to your Raspberry Pi and get the code from MySensors repository:
git clone https://github.com/mysensors/MySensors.git cd MySensors
A list of options to set the gateway is available by running the command:
Other customizations can be made by editing the file example_linux/mysGateway.cpp.
In options that requires a pin number, use the Raspberry Pi physical pin number and not the GPIO numbers.
To build, run:
If everything went well the file examples_linux/mysGateway will be created.
To get a list of parameters that can be used to pass to the gateway, run:
The following command runs the gateway as root with debug enabled:
sudo ./examples_linux/mysGateway -d
If you wish to install:
sudo make install
The last command will provide instructions for your system on how to start the gateway on every boot.
If for some reason you can't use the GPIO pins of the Raspberry Pi, you could connect the radio to a arduino with the GatewaySerial sketch and feed the pi through a serial port:
./configure --my-gateway=serial --my-serial-port=/dev/ttyACM0 --my-serial-baudrate=115200
To know the right value for the serial port, dmesg can give you some hint.
If you are running a controller on the Raspberry Pi that doesn't support communication with the gateway through ethernet, you can use a virtual serial port:
./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
For some controllers a more recognisable name needs to be used: e.g. /dev/ttyUSB020 (check if this is free).
The following is an example of how to build a MQTT gateway:
./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1
Use the Pin No. and not the GPIO.
Raspberry Pi 2/3
Raspberry Pi 1
|5VReg -> 3.3V||VCC||Red|
Obs: RFM69 is not yet supported.
Improving throughput for nrf24
Normally the gateway asks the nrf24 module if a new radio message is available and then sleep a few milliseconds before asking again. This is necessary to avoid high CPU usage. During the gateway sleeping period, the module will still listen for new messages, but if multiple messages arrive, it won't take all.
There is another method were the interrupt pin from the nrf24 modules is used to inform when a new message arrives and it's immediately added to a queue for further processing. To use this method connect the interrupt pin from the nrf24 module to your Raspberry Pi (check the wiring part for more details) and use the "--my-rf24-irq-pin=PIN" option to build the gateway.
In the following example, the interrupt pin is connected to the Raspberry Pi pin 15:
./configure --my-radio=nrf24 --my-rf24-irq-pin=15
The following is an example of how to add LEDs for ERR/RX/TX blinking.
./configure --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18