💬 Building a Raspberry Pi Gateway

@Oli I´m thinking is hard to "only" update (changing from develop to master branch) directly from github if the repository is not been previously prepared to do this kind of updates... but maybe I´m wrong.

@mfalkvidd hah... thats a good question, don't know. After dozen or more reinstallations, spending hours on Google I finally make it work. Got some notes but frankly I am worrying it will happen again. Hahaha

@Oli: by the way, the name of the port you used is ttyMySensorsGateway, not ttyUSBMySensorsGateway:

@mfalkvidd I could not find ttyMySensorsGateway on Domoticz. Only ttyUSB0, ttyUSB20 and ttyAMA0. Even after I did ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway

@jacikaas : on MYSController go to Settings -> Gateway -> TCP/IP and add the IP address of the Gateway and use port 5003. It works even if the gateway is feeding data to Domoticz, so you can monitor your sensors in "raw" mode.

@luizrrocha as You can see, on the picture above, I've wrote that ttyUSBMySensors.... is from my previous backup copy. On the same pictures You can also see that I can choose only from three serial ports: USB0, USB20 and AMA0. Thera are no ttyMySensorsGateway despite that it is present after ls /dev.
And that's the problem, I dont know how to make it present in the serial ports popup menu.

@Oli : why not remove the old definition to avoid any trash information and restarting Domoticz to make shure it rereads the port info before creating the new entry ?

And I do not understand why if you are running domoticz and the gateway on the same Pi, why not use a ethernet gateway and set 127.0.0.1 and port 5003 on the Domoticz gateway entry. I did that and never had to worry about USB ports at all.

And I do not understand why if you are running domoticz and the gateway on the same Pi, why not use a ethernet gateway and set 127.0.0.1 and port 5003 on the Domoticz gateway entry. I did that and never had to worry about USB ports at all.

simple... I have no free LAN on my rotuer... there is more, I also have raZberry daughter board (Z-Wave) connected to same Raspberry Pi GPIO port. And till today everything works perfect until... "Better is the enemy of the good"

@Oli : if both the gateway and Domoticz run on the same Raspi, there is no physical network involved, hence the 127.0.0.1 dummy local address is used by Domoticz to talk to the gateway on the same machine, just using port 5003... and since you use localhost (127.0.0.1, a virtual network) there is no need to create a virtual USB port which is what you did...

@Oli: delete the Makefile.inc file on mysensors folder
./configure --my-gateway=ethernet
make
sudo ./bin/mysgw -b
go to domoticz and create a new MySensors Gateway with LAN, inform 127.0.0.1 as the address and 5003 as the port...

The Pi MQTT Gateway with IRQ connected may handle better the messages into a loaded network than Ethernet MQTT Gateway where IRQ is not used? (with NRF24)
Also I would like to know if I can use the other pins of RPi to connect some digital sensors directly there.

Maybe i'm wrong but IRQ is used on all gateways if you read above :
"""
Improving throughput for nrf24
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
"""
for the second part yes you can use other pins on RPi ... i have RF module NRF24L01 for gateway and DHT11 on RPi.

I have Domoticz, Cacti, Heyu and MySensors Gateway running in a 30 dollars RASPBERRY PI 2, all without a glitch, all talking to each other and hopefully soon will also have Alexa for RASPBERRY PI running there also.

If in doubt, by a RASPBERRY PI and thank people who develop and support it for free instead of complaining all the time.

'nuff said.

Luiz Roberto

Can you please give me the instructions for Domoticz setup?

I have a node with DHT11 sensor and I can see mygsw service is getting messages. How do I connect Domoticz with mysensors ?

I have been following openhab until today and I'm switching to Domoticz now.

@eyesoft
Thank you for the answer, I am happy to get a confirmation about sensors works on a Pi Gateway. Since at least one of my sensor is analogue, I still have to add an Arduino board to the gateway, I plan to connect it via USB.
I have tested and get very good results with Home Assistant controller running on a Pi where I add sensors directly on Pi and to an Arduino (USB to Pi).
The Ethernet Gateway do not use IRQ: https://www.mysensors.org/build/ethernet_gateway
Nor the nodes: https://www.mysensors.org/build/connect_radio Even if the wire is connected at Arduino pin 2, is mentioned: Note: The IRQ is currently not used by the MySensors library so it can be left un-connected
If you know how to connect and manage this IRQ on Arduino sketch, please let me know.
I have built this some time ago and works without the IRQ connected. Now I have updated the MySensors to 2.1.0 , IRQ is still unconnected and works the same. As far as I see, it is used for the Pi Gateway. I plan to migrate to this configuration of Pi Gateway, but I would like to get more info before change my working system:

this IRQ improve the reliability? (sometimes I have encountered problems due the load of NRF24 network with many messages)

I would like to set retain=true for the MQTT Gateway, this will improve the reliability.
I already addressed the last question somwhere else, still waiting for more info if somebody know.
Thank you

Has there been any progress on the RFM69 version? Looking at the repository, it looks like some of the code is there. I did find this RFM69 driver for the Pi that has a LowPowerLabs interface. Would this help in moving forward?

@Mihai
you can attach analogue sensor to ESP2866 with espeasy firmware ... more info here : http://www.letscontrolit.com/wiki/index.php/ESPEasy ... i'm using one ESP8266-12E and i have good results and Uptime: 74209 minutes (usb powered).
i'm using IRQ on NRF24L01 connected to my Rpi, but i don't have many sensor with nrf+arduino (only 2) and i had no problems ... i don't if IRQ improve the reliability and i never play with irq fron nrf on arduino.
regarding retain=true have a look here : http://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages
for more reliability on mqtt i think you can use qos=1 ( The broker/client will deliver the message at least once, with confirmation required.), but all depends on your set-up .. not all messages need special attention.

@eyesoft
As far as I understand, MySensors relay on PubSubClient for MQTT and it does not allow to publish messages with QOS=1 or 2, only 0.
Retain is different that QOS, it offers the possibility to recover the state for a device that loose connection for a while (e.g. after a restart). I find it very usefull. For example I have to restart the controller. When come back I got all states to their real values if retain=true. Otherwise they goes to the default, usually 0.
I have now 6 nodes, each with several sensors and relays.

Data is not stored... to store the data and do something usefull with it (or not) you need a controller. I use mycontroller, and from this software you can "push" data to an external server.
I use my controller, but i am sure that other controller software also has this feature.

@hek It looks like development is the default branch in the repository. I was following the build instructions and couldn't figure out why I kept getting "connection refused". Just typing up a troubleshooting post when I saw my log said 2.2.0-beta. Sure enough when I grabbed master(2.1.0) instead it ran fine. Should probably add a checkout in the instructions.

Edit: Now I see. The link in the first post in this thread. It doesn't mention the master branch because up until Dec 25th the development branch was required. But now that 2.1 has been released the instructions should indeed use the stable version. I've updated the instructions. Thanks for noticing!

This is also new for me since i do not send data into any cloud... but i can imagine that you can use MQTT. (see https://www.mysensors.org/build/mqtt_gateway for more details) is important that the receiving side supports MQTT. in this case google is your friend

if you do a ./configure --help you will find you can build the mysensors gateway with MQTT support

./configure --help
...
--my-gateway=[ethernet|serial|mqtt]
Gateway type, set to none to disable gateway feature. [ethernet]
--my-node-id=<ID> Disable gateway feature and run as a node with given id.
--my-controller-url-address=<URL>
Controller or MQTT broker url.
--my-controller-ip-address=<IP>
Controller or MQTT broker ip.
--my-port=<PORT> The port to keep open on gateway mode.
If gateway is set to mqtt, it sets the broker port.
...

@marceloaqno
i am beginner and i can not turning off the UART functioning. . . also on some board usb port after power off/on lost and i should disconnect/connect cable... i test your steps serial gateway with raspberry and GPIO with virtual usb serial . and i see this problem solve and after power off/on gateway is connect .
i suggest that you add this commands to page of rs485 gateway step by step and update this .
(https://www.mysensors.org/build/rs485)

@b0rmann
thank you friend , but i am sorry i am very beginner in raspberry pi . because i use vera before and with raspberry and orange pi i use recently. so i need a full steps for a rs485 gateway(wiring and commands . . .) i dont know what is ttyAMA0 ! i use a serial gateway with usb port with raspberrypi 3 but i have some problem , but with a raspberrypi gateway and use a virtual serial port (ttyUSB020) all of my problem resolve. but i have problem with wireless. so i want have a wiring network. i want a full steps for setup a rs485 module with raspberrypi 3(wiring and steps for install...) thank you for help

just cloned and read the --help, but still I don't know how to use.
To make it a litte less abstract: I have a ethernet gateway (ESP8266) running at 192.168.38.19 with port 5003 to connect to. I want to have this accessible by a serial-only controller on the raspberry.

I tried to do this config and make afterwards, but starting gave only FAILs...

I using RPi2 and NRF24 for this. I followed the instructions, to clone the repo, and then added config
./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 --my-transport=nrf24

make

when i run with sudo ./bin/mysgw -d, it is failing to connect to MQTT. Can you please help?

I use pimatic which does not have a native compatibility to ethernet or mqtt. Thats why my question came up on how to configure it to do this...

Building a Raspberry Pi Gateway:

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

If not, I'm getting the same problem on the 2.1.1 that was just released. 2.1.0 was working "fine"(besides my suspecting a bug that doesn't let any inclusion happen, hence I tried the new version). Time to go back to the serial gateway right into the vera.

@pete1450 If you use the --my-controller-ip-address= option, the gateway will act as a client and attempt to conect to the supplied ip and port. If you want the gateway to open port 5003, omit this option.

@marceloaqno what is the correct configure option to make this gatway connect to an ethernet gateway and let a serial-only-controller connect to it. I suppose to use the pty option, but didn't got this working. As said above, socat and nodered are no option.

@marceloaqno Well that fixed the connection issue. Now I'm just back to square one where pressing start doesn't do anything. Why do I not need to specify my controllers ip? That is the ip for my veralite. Whats the use case for that option.