nRF24L01 Large network help needed
-
I'll have to come back to it another day, I've been reading your guides about gateways all morning and they're simply making no sense to me at all any more >.<
-
There are nodes, repeaters, gateways and a controller in a Mysensors setup.
Nodes have sensors or act as actuators. They can send radio messages to other nodes or to the controller. In the MySensors code you can define the destination.
Repeaters in MySensors, are nodes that can receive radio messages and pass them on. They do not change the messages, just pass them on to the next repeater or the gateway or the destination node.
In the latest versions of the MySensors library they can also have sensors or act as actuators. These repeaters need to be awake at all times to be able to function as repeaters. Nodes that sleep can not receive radio messages, so giving them a repeater function would not make sense.Gateways are devices sitting between nodes (sensors or actuators) / repeaters and a controller (any of the 18+ which now can understand the data sent by a MySensors gateway).
Gateways in MySensors receive the radio messages, and translate those radio messages into a string per radio message and sends those strings to a controller over serial port or USB or over ethernet. The format of those translated messages is described in the documentation.
Basically for each message (packet of bytes sent by the radio of the node) over the radionetwork addressed to the controller, the gateway would send a string to the controller. The controller can send a string to the gateway, which is then translated into a radio packet by the gateway and send to the appropriate node over the radionetwork.
Address and payload of that packet are all defined in 1 string from controller sent to gateway.
That is how I understood the "serial protocol".On a network you can have only 1 gateway per radio-channel. Since a gateway can handle 254 nodes, any need for more nodes, means using several gateways on a different radiochannel each. Some controllers are capable of handling several gateways in parallel. So the maximum size of your network depends on the controller used.
-
There are nodes, repeaters, gateways and a controller in a Mysensors setup.
Nodes have sensors or act as actuators. They can send radio messages to other nodes or to the controller. In the MySensors code you can define the destination.
Repeaters in MySensors, are nodes that can receive radio messages and pass them on. They do not change the messages, just pass them on to the next repeater or the gateway or the destination node.
In the latest versions of the MySensors library they can also have sensors or act as actuators. These repeaters need to be awake at all times to be able to function as repeaters. Nodes that sleep can not receive radio messages, so giving them a repeater function would not make sense.Gateways are devices sitting between nodes (sensors or actuators) / repeaters and a controller (any of the 18+ which now can understand the data sent by a MySensors gateway).
Gateways in MySensors receive the radio messages, and translate those radio messages into a string per radio message and sends those strings to a controller over serial port or USB or over ethernet. The format of those translated messages is described in the documentation.
Basically for each message (packet of bytes sent by the radio of the node) over the radionetwork addressed to the controller, the gateway would send a string to the controller. The controller can send a string to the gateway, which is then translated into a radio packet by the gateway and send to the appropriate node over the radionetwork.
Address and payload of that packet are all defined in 1 string from controller sent to gateway.
That is how I understood the "serial protocol".On a network you can have only 1 gateway per radio-channel. Since a gateway can handle 254 nodes, any need for more nodes, means using several gateways on a different radiochannel each. Some controllers are capable of handling several gateways in parallel. So the maximum size of your network depends on the controller used.
@GertSanders said:
sends those strings to a controller over serial port or USB or over ethernet. The format of those translated messages is described in the documentation.
This is the part that i was getting confused about. Now, i would like to keep my current structure of having the controller and gateway as the same machine, if possible, do you know if this is possible? At the moment my .cpp file is handling all the data coming in, sorting it to the correct structure and channels, then passing them over to the MQTT broker (Mosquitto) via the loopback address that i specify in the .cpp file. (127.0.0.1) through the following code:
// Print some radio details (for debug purposes) radio.printDetails(); network.update(); mosq.connect("127.0.0.1"); mosq.subscribe(0, action_channel1); mosq.subscribe(0, action_channel2);So, essentially i have it complete now, i just need to be able to have more nodes on my network, and i fear that i may need to reprogram the whole of my controller/gateway machine for this.
-
@samuel235 It is certainly possible, I use PiSerialGateway on my Raspi. I have an nrf24l01+ directly connected to some GPIO pins. The PiSerialGateway software takes care of the gateway function and sends it's data to Domoticz running on the very same Raspi 2. I know nothing about MQTT so I can not help there. Just to prove it's possible: here is my gateway/controller in one:

Hardware is simple, software does all the work. -
Fantastic! Now, the only thing i want different is to use OpenHAB over Domoticz. And for that to work i just simply use the MQTT. I think the MQTT isnt that hard to sort out, the big struggle for me is in the radio communication.
I have a feeling that with a little research on this site i might be able to see that openhab can use a serial connection. I will have a look now :)
Thank you for going to the extent of an image, that brings back so much faith in my to complete this project now.
-
Does anyone happen to know where the MQTT gateway library/repo is for the RaspberryPi? I can't seem to find it anywhere, I've looked in the raspberrypi directory of the mysensors github, nothing there either. I have the arduino version, just not the raspberrypi one.
-
Domoticz (which I run on my Raspberry Pi) uses mosquitto. Binary packages are available for at least the following platforms:
Windows, Max, Arch Linux, CentOS, Fedora, FreeBSD, Gentoo, Mandriva, OpenSUSE, OpenWRT, Raspberry Pi (Raspbian), Redhat Enterprise Linux, Slackware, SUSE Linux Enterprise Server, Ubuntu, QNX, iOS. In Raspbian you can install it by runningsudo apt-get install mosquittoThe source for mosquitto is available here.
Other mqtt implementations are also available, for example paho.
-
Domoticz (which I run on my Raspberry Pi) uses mosquitto. Binary packages are available for at least the following platforms:
Windows, Max, Arch Linux, CentOS, Fedora, FreeBSD, Gentoo, Mandriva, OpenSUSE, OpenWRT, Raspberry Pi (Raspbian), Redhat Enterprise Linux, Slackware, SUSE Linux Enterprise Server, Ubuntu, QNX, iOS. In Raspbian you can install it by runningsudo apt-get install mosquittoThe source for mosquitto is available here.
Other mqtt implementations are also available, for example paho.
@mfalkvidd said:
Domoticz (which I run on my Raspberry Pi) uses mosquitto. Binary packages are available for at least the following platforms:
Windows, Max, Arch Linux, CentOS, Fedora, FreeBSD, Gentoo, Mandriva, OpenSUSE, OpenWRT, Raspberry Pi (Raspbian), Redhat Enterprise Linux, Slackware, SUSE Linux Enterprise Server, Ubuntu, QNX, iOS. In Raspbian you can install it by runningsudo apt-get install mosquittoThe source for mosquitto is available here.
Other mqtt implementations are also available, for example paho.
Sorry, i seems i confused you. I need the mysensors gateway file that communicates with the mosquitto program running on the pi.
This, but for the Raspberry Pi, not arduino.
-
Would i be correct in saying that i need to modify this to use MQTT to pass the messages onto the MQTT program that i have running in the background?
@samuel235 I developed a Perl implementation of a MySensors serial protocol to MQTT converter. You can find it here.
I use it to connect to a MySensors ethernet gateway, but support is in for a serial gateway. Serial gateway support hasn't been tested by me, so there might be issues using it.
Anyway, the converter (also called gateway to raise the confusion ;-) ) you can just run on your raspberry Pi. It connects to the MySensors gateway on one side and your MQTT broker (e.g. Mosquitto) on the other side. -
@samuel235 I developed a Perl implementation of a MySensors serial protocol to MQTT converter. You can find it here.
I use it to connect to a MySensors ethernet gateway, but support is in for a serial gateway. Serial gateway support hasn't been tested by me, so there might be issues using it.
Anyway, the converter (also called gateway to raise the confusion ;-) ) you can just run on your raspberry Pi. It connects to the MySensors gateway on one side and your MQTT broker (e.g. Mosquitto) on the other side.@Yveaux At the moment i obviously have my MQTT broker running, OpenHAB running and my current 'method' of using MQTTController.cpp to read the RF network, grab the messages from the sensors and then convert them to the MQTT topics for OpenHAB to use, for example i have the MQTTController.cpp receiving a message of '1' or '0' and publishing it on a topic 'home/bedroom/lightswitch' and then OpenHAB converts the 1, 0 or - to a readable message (On, Off or Unavailable).
Do you think that i could just implement mysensors gateway for the raspberry pi, then refer to it in OpenHAB using:
mqtt:mysensor.url=tcp://localhost:1883 mqtt:mysensor.clientId=MQTTThe current config I'm using is:
mqtt:mymosquitto.url=tcp://localhost:1883 mqtt:mymosquitto.retain=trueIs there any difference between the two apart from one is using mymosquitto and the other mysensor? Why is one using .retain=true and the other is using a clientId=MQTT?
-
@samuel235 I developed a Perl implementation of a MySensors serial protocol to MQTT converter. You can find it here.
I use it to connect to a MySensors ethernet gateway, but support is in for a serial gateway. Serial gateway support hasn't been tested by me, so there might be issues using it.
Anyway, the converter (also called gateway to raise the confusion ;-) ) you can just run on your raspberry Pi. It connects to the MySensors gateway on one side and your MQTT broker (e.g. Mosquitto) on the other side.@Yveaux From looking through the openhab.cfg file i have found the following information regarding the code for the binding:
####################################################################################### ##### Transport configurations ##### ####################################################################################### ################################# MQTT Transport ###################################### # # Define your MQTT broker connections here for use in the MQTT Binding or MQTT # Persistence bundles. Replace <broker> with a id you choose. # # URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883 #mqtt:<broker>.url=tcp://<host>:1883 # Optional. Client id (max 23 chars) to use when connecting to the broker. # If not provided a default one is generated. #mqtt:<broker>.clientId=<clientId> # Optional. User id to authenticate with the broker. # mqtt:<broker>.user=<user> # Optional. Password to authenticate with the broker. #mqtt:<broker>.pwd=<password> # Optional. Set the quality of service level for sending messages to this broker. # Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2 # (Deliver exactly once). Defaults to 0. #mqtt:<broker>.qos=<qos> # Optional. True or false. Defines if the broker should retain the messages sent to # it. Defaults to false. #mqtt:<broker>.retain=<retain> # Optional. True or false. Defines if messages are published asynchronously or # synchronously. Defaults to true. #mqtt:<broker>.async=<async> # Optional. Defines the last will and testament that is sent when this client goes offline # Format: topic:message:qos:retained <br/> #mqtt:<broker>.lwt=<last will definition>So, from this it shows that the only part that i would need to specify is the URL to the MQTT broker, which i'm assuming that once i install the mysensor package onto my Pi i can then just call the localhost in this line like i currently doing so, nothing needs to be changed as the broker name is not relevant to anything. However because it has to match throughout all of the bindings and items i will just change it to mysensor for ease.
I'm just stuck with how the controller reads the data from the sensors.... I need to modify or replace my MQTTController.cpp with a file from here that reads the radio communications...
-
Finally found the repo for what i think is the raspberry pi MQTT Gateway... Link, I'm assuming the file i need to be looking at is the MyGatewayTransportMQTTClient.cpp. However, there is no MakeFile there, am i being stupid or blind, how would i compile this gateway file to then be able to run it?