💬 Building a Raspberry Pi Gateway
MasMat last edited by
@mfalkvidd Made the password 10 characters. From looks of the logs, it's working now.
I cant believe I skipped the step of making the password longer... Just got too fixated on the password I came up with.
@masmat the nonce failures is because the backend never initialized so basically any call to the backend that can fail will fail.
I just discovered these USB-to-NRF24 devices. Would it be possible to use that instead of connecting to the GPIO pins?
@alowhum not with the existing code. Is there a datasheet that describes how these modules work?
One of the reviews says "have no idea wath software to use with this" so documentation might be hard to come by.
Background: I use signing software on some nodes + whitelisting on a node (of course only PI serial is on the whitelist).
With current --development branch (I think 2.3.0alpha) I cannot anymore set my previous personalized flags on gateway RPI3.
In detail, with current master (2.2.0) I can do:
sudo mysgw --set-soft-hmac-key=F618D4[...]848992B sudo mysgw --set-soft-serial-key=26[...]9 sudo mysgw --set-aes-key=EC7[...]CEB4
WIth development I did see only the
--get[...]flags and cannot set anymore. Can you confirm?
How can I set my previous values for signing?
@sineverba I believe this change alters how rPi port handles signing related personalisation: https://github.com/mysensors/MySensors/commit/3c0b2727a56907277d4d04c985fd72b14e4a483c
And, as usual, the documentation is a good place to start https://www.mysensors.org/apidocs-beta/group__MySigninggrpPub.html#MySigninggrphowuse
I'm currently compiling the code for connecting the NRF24l01+ directly to the Raspberry PI. Since I'm running the controller (on this case OpenHab) on the same Raspberry PI, would it be recommended the Ethernet or the serial flavor of it?
In the case of ethernet, can I place the own machine IP (127.0.0.1)? This way, if I need to change the IP address of the PI it wouldn't affect the communication between the controller and the MySensors code, right?
And by the way, for the signing configuration, it is mentioned in the documentation "Update the gateway config file with the generated keys/valeus", what file is that (name, path)?
I should be able to re-use the keys I have defined before, right? So I just go to step 2 (no need to generate new keys).
I'm refering to this link.
--my-controller-url-address=127.0.0.1 is not needed for ethernet
I found that the configuration file is /etc/mysensors.conf but " The first time you start the gateway the configuration file will be created if it does not already exist.", so that's why I wasn't finding it.
Anyway, the file states that:
"Note: The gateway must have been built with signing support to use the options below."
What flags should I include to have signing support?
OK, found it: just run ./configure -h and there is a list of options. Leaving it here just for future reference
ust run ./configure -h and there is a list of options. Leaving it here just for future reference
it is already written in the article
joaoabs last edited by
Thanks for the replies.
I've changed the PI from a PI1 to a PI3 and was able to make it working with signing. Its running smoothly, I guess the GW is chosen :).
I'll now focus on the nodes, specially the SenseBender micros that are 2xAA battery powered and are consuming ~3% bat per day, but that will be for another post...
Hi, is there any way to check the current gateway operating parameters? My purpose is to check the radio channel and power level set before compilation but I would be glad if I could check other configurable parameters. I looked at Makefile.inc and found some flags set, but not the information I was looking for (does it mean that the default values are set)? Debug logs neither provide these informations.
What radio are you using?
@gohan nrf24, one deployment pa+lna version with external antenna and the other standard with build-in "zig-zag" antenna.
I always set gw to max power if the radio is shielded
Is it normal to have frequently these errors in the RPI GW?
May 11 00:43:54 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:43:54 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:43:56 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:43:56 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:43:58 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:43:58 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:44:00 nettemp mysgw: RF24: Recovered from a bad interrupt trigger. May 11 00:44:00 nettemp mysgw: RF24: Recovered from a bad interrupt trigger.
@gohan Well, that is not an answer to my question apparently I suppose that max power lever is the default setting according to the configure script's help.
also look for a channel outside the WiFi range
kberck3 last edited by
Openhab2 on pi3b+ using nrf24 radios and mqtt. I can follow the wiring diagram, but the commands are a bit confusing and seem to jump around randomly. Do I put all the --my-blah-blah together after the ./configure to build a file? Should I do development version? Do the nfr improvements go together with everything else?
Do I put all the --my-blah-blah together after the ./configure to build a file?
From the article "Note: All options must be added to the same line, after ./configure"
Leave the development version for now, the stable works fine.
@gohan to be fair, I added that note this morning so kberck3 might not have seen it
kberck3 last edited by
Appreciate the reply mfalkvidd and gohan! Service is running, will report back if I run into other issues.
Mark Swift last edited by
Is anyone here using the Pi with OTA updates? I'm finding them painfully slow (1-2 stream messages every few seconds). It's taking 1 hour per OTA update compared with 2-3 minutes when using the Arduino gateway!
I did some tests on pi3 and I found slow ota too. Tekka has an open issue on github about this.
I tried to setup my Raspberry running Node-RED and serial gateway but I got stuck halfway. I followed the serial gateway compilation above and got it up and running, however using the serial nodes an Node-RED I could not manage to get them to connect tho the gateway.
First I tried to connect to
/dev/ttyMySensorsGatewaywhich did not work due to permissions (owned by root). When checking out
/dev/ttyMySensorsGatewayI found it links to
which belongs to root and the tty group. But I could not connect to this as the tty group only has write privileges. I think I miss some crucial point connecting those two together so I hope somebody can save the day by pointing me in the right direction.
Thanks in advance,
So you run a separate arduino board as a mysensors gateway, connected with serial (USB) to your raspberry pi? Or do you mean that you are using the rpi directly with radio, and then run the rpi variant of the mysensors gateway code?
@tbowmo I run the gateway on my Pi directly with the radio is connected to the Pi's GPIOs. Compilation and gateway do just fine I, if only I could convince my Pi to let Node-RED talk to the device
This is my output:
dietpi@buddy:~ $ ll /dev/ttMySensorsGateway lrwxrwxrwx 1 root root 10 Jun 18 14:38 /dev/ttMySensorsGateway -> /dev/pts/2 dietpi@buddy:~ $ ll /dev/pts/ total 0 crw--w---- 1 dietpi tty 136, 0 Jun 18 14:38 0 crw--w---- 1 dietpi tty 136, 1 Jun 18 14:38 1 crw--w---- 1 root tty 136, 2 Jun 18 14:38 2 crw--w---- 1 dietpi tty 136, 3 Jun 18 14:38 3 c--------- 1 root root 5, 2 Nov 3 2016 ptmx
wasn't it the problem of the missing permission on the dialup group?
Unfortunately adding my nodered user to dialout did not bring the hoped success. I still get premission denied messages after a reboot of my raspberry.
As my console print above shows the
/dev/ptsdevice belongs to tty but adding nodered to tty did not work out either (since the group only has write privileg). I have no idea how to fix this other then chowning the port to nodered but that feels wrong for me after years using linux based systems.
it is not a solution, but you could switch to ethernet GW and you will avoid all the permissions problems.
My 5 cents:
Run it as a MQTT gateway, if possible. It makes things so much easier, when you interact with the data in node-red. Even integrating other controllers is easier, as you have the MQTT as standard backbone bus between everything.
You need to have a MQTT broker (mosquitto) running as well.. But it's worth it..
Yes I came to the conclusion that this might be my only option even if it sucks as I have to subscribe to all events from MySensors, process them with Node-RED and republish again which screws my logging a bit. Right now I have another flow subscribed to "#" and write every event into my DB.
Since I have everything talking to mosquitto setup to follow Homie Convention I was hoping for only having my MQTT broker bombarded with compliant messages and have Node-RED convert everything (assign device names, etc. using a SQLite DB) from serial so the rather cryptic MySensors topics do not show up there.
@mirodin you actually need only mysensors-in and mysensors-out topics and their subtopics
@gohan Yes I know but now I can no longer just wildcard-dump every event on my mosquitto instance into my DB as I need to filter out the mysensor-in and -out topics.
Or meanwhile just use the ethernet gw
Well... I think I fixed it, let's hear it for documentation. Just when I had MQTT setup half way I got struck by the idea that there was some group flag for
configure. And indeed there is, setting
--my-serial-groupname=nodereddid the trick making
/dev/pts/Xowned by group nodered and let Node-RED connect to it, writing and reading works just fine now.
Thanks @gohan for your input I think I would have gone the ethernet route in the end if this last test had failed.
Inso last edited by
I am currently trying to update to 2.3
Have stopped service and deleted the file (systemctl status mysgw -> Unit mysgw.service could not be found.)
Also renamed the config file /etc/mysensors.dat
Renamed the old folder, then copied new files.
Checked readme.md in MySensors-folder: MySensors Library v2.3.0
Then I configured the radio and -> make, no errors
However, changing to bin folder and executing mysgw shows: Protocol 2.2.0
What am I missing?
@inso Did you
sudo make installafter building it? This command copies the service file and mysgw to their respective locations.
@inso remember to unregister the service and then make a new make install of the new gw
@gohan how is the unregistration done? I didn’t know that was needed. We should probably add upgrade instructions to the build page.
Inso last edited by
make install before testing did the trick, now it is 2.3.0 .
Was just going step by step through tutorial, there it´s make -> test -> make install. Didn´t realized it would use old parts if it´s not first install
thought stop, disable and remove the service would be enough to ensure the service is completely "uninstalled" - could you give me a hint what I´ve missed?
ricorico94 last edited by ricorico94
I try to access log info from my gateway installed on my domoticz raspberry pi, but I get no success..
First, I can't find the mysensors.conf file : nothing in the /etc folder. I tried to use "find / -name 'mysensors.conf' 2>/dev/null" command, but it finds nothing.
I tried creating such a file (then it's found by the fond command above) and in which I have the lines
as instructed above.
I restarted the wole Raspberry PI, then tried the command cat /tmp/mysgw.pipe but error message:
cat: /tmp/mysgw.pipe: Aucun fichier ou dossier de ce type
(= no file or folder like that)
I then tried this: sudo mysgw -c /etc/mysensors.conf and I got also error message:
mysgw: invalid option -- 'c'
I installed the Mysensor gateway on 17th October 2017 and my raspberry pi is working on Wheezy. In Domoticz, I see the Mysensor gateway has version 2.1.1.
MY gateway seems working fine, communicating properly with sensors (both ways). I'm trying to find log because I face an issue with a new sensor which works properly when powered with external FTDI 3.3V and only 1 way (sensor to gateway only) when powered on battery (I raised question in another post, where I was suggested to check log fil on gtw side..)
Any idea of what I should do (except "reinstall whole raspberry pi with latest OS..) ?
Thanks a lot,
@ricorico94 there seems to have been some major changes in the raspberry pi gateway, without vorresponding updates to the documentation.
I have not been able to locate the exact changes though. @marceloaqno might know.
Found the reference: https://github.com/mysensors/MySensors/pull/1061
ricorico94 last edited by
@mfalkvidd : thanks a lot ! I had searched for such version history and couldn't find it.
Indeed it seems introduction of the switches for log files was introduced in February, so I should probably update my install.
Precisely, talking about upgrade process: I read in previous posts that we should uninstall/unregister the install/service. WHat would be commands to do so ? Should it be:
sudo systemctl disable mysgw.service
and executed before anything else ? So upgrade process would be:
sudo systemctl disable mysgw.service make sudo make install sudo systemctl enable mysgw.service
(and maybe test the gateway before the "systemctl enable..")
Is there anyfile to remove manually ? or any other command to apply before or after ?
Would someone be willing to create a post that lists each step required to set up the simple encryption+signing option? I understand I have to add a password line to the arduino sketch. But how exactly one sets up the server side is still a bit of a mystery to me. It would rock if there was a similar simple command to give during the make process.
That is straight from the documentation. Which in the case of Linux ports is also what you get if you issue
pepson last edited by
I also need this info...
@ricorico94 to update your install run:
sudo make install sudo systemctl restart mysgw.service
ricorico94 last edited by
Thank you for the clarification !
alowhum last edited by alowhum
@Anticimex Thanks, but a documentation page (which I have checked before) is not the same as an easy to use guide for beginners.
In my ideal world it would be this:
- Add the MY_SIMPLE_PASSWORD line to your Arduino sketch.
- Compile the gateway with --MY_SIMPLE_PASSWORD="yabadabad000!"
@alowhum it is not easy to have simple guides tailored for specific usecases when there are so many options.
Those tend to not follow implementation and our documentation is made to live with the implementation to ensure it is always up to date. Maintaining a simple guide for every conceivable use case is simply not feasible. The signing and security documentation does have a step by step guide for setting up security.
@Anticimex: I understand, but:
- Currently even the outline of the steps eludes me. Seeing the steps for usecase #14 or #385 would already help me understand the scope, and to see what ballpark of difficulty it's in. It's easier to mod a guide when there is something to go on.
- Secondly, there must be a common use case? The defaults that MySensors uses already suggests a lot of these: a Raspberry Pi with the default settings of the software (ethernet), with the nRF24 radio.
@alowhum ok, well first of all, I don't have a rPi setup to test on, secondly I don't have time to look into that (this) environment.
But, this is a open source project so anyone is free to contribute with both code and documentation (which in our case lives in the same repositories) so if there are guides missing enyone is welcome to contribute with experiences and guides to help others out.
It is just important to understand that the guides need to be maintained in order to remain valid.
I don't mind guides at all. But it makes little sense for me to write guides for an environment which I am not familiar with nor can test on.
And it is exactly my goal to create a more elaborate guide after someone points out the basic steps.
John Oliva last edited by
I have designed a 3D printable enclosure for this and the design/STL files are available here: https://www.thingiverse.com/thing:3072244
@John-Oliva, nice! Added it to the MySensors collection:
I have same error
Can you write that rigth do you ser to folder ?
@cadet I just remove /usr/local/bin/mysgw and compile again
And I have one question - why is it happened?
MysGW work fine about 3 months.
what problem did you have?
@gohan mysgw: ERROR accept: Bad file descriptor - today morning
I get that when another instance of the process is already running
@gohan I was try to find it with ps -ef, but nothing found. Reload RPI.
@korleone was write about this
"Hello, it seems I found the problem: Complete newbie thing:
sudo ./bin/mysgw -h worked, but /usr/local/bin/mysgw didn't
I just gave the right to the folder, and now it's working."
But what right hi gave ?
sudo ./bin/mysgw -h could work, it only depends in which folder you are running the command from
mvader last edited by
FYI looks like on the 2.3.1 beta the transport has been changed to rf24 instead of nrf24
magjef29 last edited by
Is the rasberry pi serving as a gateway and a server in this project? Or do you have to have a separate pi to host something like openhab and another pi for your gateway?
Hi @magjef29, welcome to the MySensors forum!
You can run your controller(s) on the same Raspberry Pi.
Depending on what tou mean by ”server”, the gateway can be a server, but the gateway is not a controller.
If you haven’t already, see the getting started guide for information about the different parts.
Hi! Does anybody test Cubieboard as Gateway? I have a cubieboard runing archlinux with spi enabled in kernel. How i define pins for nrf24 gateway connection? Or i need to make big changes in code to star work with different bord than Rpi?
This is my old dream to connect directly nrf to Cubieboard GPIOs. Few years ago i try to do this without success using this lib - https://github.com/bearpawmaxim/librf24-sunxi
Hi @артем-тихонович, welcome to the MySensors forum!
For the NRF24, the same defines as for normal sketches are used. Documentation: https://www.mysensors.org/apidocs/group__RF24SettingGrpPub.html
The defines can be added to the Raspberry Pi gateway by following the instructions on https://www.mysensors.org/build/raspberry#advanced
I have not heard about anyone using the Cubieboard but hopefully someone else has. The information provided on https://www.mysensors.org/build/orange might be useful if the Cubieboard is similar to the Orange Pie.
oh, and in case you haven't already, see the ./configure --help text about the most common NRF24 defines; you might not need the advanced build options.
Thank you, @mfalkvidd. Ihave a little troubles with correct defining gpios from Cubie. In fex file the gpios defines is:
gpio_used = 1
gpio_num = 2
gpio_pin_1 = port:PH07<0><default><default><default>
gpio_pin_2 = port:PH15<6><default><default><default>
[root@Archey boot]# ls -ls /sys/class/gpio/
0 --w------- 1 root root 4096 Nov 21 11:58 export
0 lrwxrwxrwx 1 root root 0 Nov 18 17:01 gpio1_ph7 -> ../../devices/platform/gpio-sunxi/gpio/gpio1_ph7
0 lrwxrwxrwx 1 root root 0 Nov 21 11:54 gpio2_ph15 -> ../../devices/platform/gpio-sunxi/gpio/gpio2_ph15
0 lrwxrwxrwx 1 root root 0 Nov 18 10:45 gpiochip1 -> ../../devices/platform/gpio-sunxi/gpio/gpiochip1
0 --w------- 1 root root 4096 Nov 18 16:52 unexport
When i define in configure: --my-rf24-ce-pin=1 --my-rf24-cs-pin=2 build is ok, but test failed with error:
Nov 21 11:58:15 ERROR Could not open /sys/class/gpio/gpio1/direction[root@Archey MySensors]#
when i define --my-transport=nrf24 --my-rf24-ce-pin=gpio1_ph7 the build failed wirh error:
./drivers/RF24/RF24.cpp: In function 'void RF24_ce(bool)':
<command-line>:0:16: error: 'gpio1_ph7' was not declared in this scope
./drivers/RF24/RF24.cpp:52:17: note: in expansion of macro 'MY_RF24_CE_PIN'
How can i resolve this problem? Please help.
I just see for another app using nrf24 on cubieboard
and funcrtion to use nrf24 have GPIO defining is RF24 radio(SUNXI_GPB(10), SUNXI_GPB(11), "/dev/spidev0.0");
GPIO set using this style: SUNXI_GPB(10), this type of gpio defined in #include "gpio_sun4i.h" file. Maybe this specific defining in ARCHLINUX ARM distro.
I hereby donate these images: