MySensors Raspberry port suggestions
-
Just as an update, I have the MQTT version with mongoose mostly working. Thanks for that recommendation @marceloaqno. Still very much a work in progress. If anyone is interested in following, here is the link: https://github.com/aaron832/Arduino/tree/raspberry-gateway-MQTT/libraries/MySensors/examples_RPi
-
FYI I had to ditch mongoose. It just wan't working properly. libmosquitto from http://mosquitto.org/ seems to work a lot better. Any idea about getting @marceloaqno 's branch merged into develop or vise versa? Would be nice to be working on 2.0
-
FYI I had to ditch mongoose. It just wan't working properly. libmosquitto from http://mosquitto.org/ seems to work a lot better. Any idea about getting @marceloaqno 's branch merged into develop or vise versa? Would be nice to be working on 2.0
@aaron832 I'm very close to reaching a working version for the 2.0, will release something in the coming days.
-
@aaron832 I'm very close to reaching a working version for the 2.0, will release something in the coming days.
@marceloaqno This is good news because I was about to give up trying to do the port. :sweat_smile: Hopefully some of my stuff was of some use.
-
This is the initial support for Linux/RaspberryPi for the 2.0:
https://github.com/marceloaqno/Arduino/tree/dev-raspberrypiSupports:
- RF24 radio
- Ethernet gateway
- Store "eeprom" to a file (thanks to @aaron832 )
- MQTT (thanks to @aaron832 )
- Can be compiled in a linux machine other than Pi
To be implemented:
Store "eeprom" to a fileSerialMQTTRF24 interrupts- UDP
- Act as a client to connect to a controller
I haven't extensively test it, so there are probably some bugs. Any suggestions or ideas for improvement are welcome.
-
Thanks a bunch @marceloaqno for you update to 2.0. Some initial testing shows its working fine. I went ahead and just re-implemented my MQTT addition on top of this branch. Its significantly cleaner and just sits alongside your ethernet implementation. This way you can still connect with a controller via ethernet while getting the benefit of MQTT as well if desired.
For the initial changes I created a pull request:
https://github.com/marceloaqno/Arduino/pull/2
for my branch
https://github.com/aaron832/Arduino/tree/feature/MQTTSupport -
Perhaps we should start another topic with a better name so that more people become aware of this port?
-
Perhaps we should start another topic with a better name so that more people become aware of this port?
-
@lafleur Do you recommend any RFM69h library that works well in Pi? I could try to add support if there is any.
-
There are a number of ports to the RPI...
http://rdepablos.merlitec.com/mixed/rfm69-library-for-raspberry-pi
http://jeelabs.org/wp-content/uploads/2015/05/20/rfm69-on-raspberry-pi/index.html
https://github.com/etrombly/RFM69
https://123d.circuits.io/circuits/519561-raspberry-pi-and-rfm69hw-interface
http://www.0x1.be/esa/domotic/arduino/node/domotic-howto-rfm69/
and others...
Thanks
-
Just an update, I've been using this port on my raspberry pi during the last months and it has been quite stable, the code is also up to date with the mysensors development branch.
-
That's great, thanks @marceloaqno
I just started testing but I had to revert to 7d51087e589afb1296e71442fe2164807da399ef to have it working.
Last commit SEGFAULT afterEth: Listening for connections on 0.0.0.0:5003Also, do you have an updated initscript to launch it automatically at boot? It seems the one from the old PiGateway is not working very well with this one. For now I just added a cronjob.
-
@emc2 Could you give more information about your setup? I wasn't able to reproduce the error.
For the initscript, I will try to add an updated version for systemd.
-
So I did a few tests, one of my setup is working on the last commit, the other not. Both are model B.
-
Working Pi:
Domoticz image, upgraded and up to date wheezy -
Commit 7d51087e589afb1296e71442fe2164807da399ef Pi:
Regular (non-Domoticz) old wheezy image updated to jessie
All are up to date for all package on apt and firmware is up to date for rpi-update
Linux domoticz 4.4.15+ #897 Tue Jul 12 18:38:58 BST 2016 armv6l GNU/LinuxMy bet is that my "non-working" Pi, wich is also my guinea pig Pi, is missing a dependency or something. Let me know if I can get you some logs to troubleshoot, but it may be very specific to this setup so may not be worthwhile investigation unless a common factor start to emerge.
Anyways, thanks for the port! :+1:
-
-
This is the initial support for Linux/RaspberryPi for the 2.0:
https://github.com/marceloaqno/Arduino/tree/dev-raspberrypiSupports:
- RF24 radio
- Ethernet gateway
- Store "eeprom" to a file (thanks to @aaron832 )
- MQTT (thanks to @aaron832 )
- Can be compiled in a linux machine other than Pi
To be implemented:
Store "eeprom" to a fileSerialMQTTRF24 interrupts- UDP
- Act as a client to connect to a controller
I haven't extensively test it, so there are probably some bugs. Any suggestions or ideas for improvement are welcome.
very nice fork. but... i can't compile it:
git clone https://github.com/marceloaqno/MySensors.git cd MySensors ./configure --my-gateway=mqtt --my-rf24-channel=1 --my-rf24-pa-level=RF24_PA_MAX --my-controller-ip-address=127,0,0,1 --my-mqtt-client-id=MyGW2 --my-mqtt-publish-topic-prefix="MyGW2out" --my-mqtt-subscribe-topic-prefix="MyGW2in" makeg++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/EthernetClient.o drivers/Linux/EthernetClient.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/compatibility.o drivers/Linux/compatibility.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/IPAddress.o drivers/Linux/IPAddress.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/EthernetServer.o drivers/Linux/EthernetServer.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o examples_linux/mysGateway.o examples_linux/mysGateway.cpp ./core/MyProtocolMySensors.cpp: In function ‘bool protocolMQTTParse(MyMessage&, char*, uint8_t*, unsigned int)’: <command-line>:0:32: error: ‘MyGW2in’ was not declared in this scope ./core/MyProtocolMySensors.cpp:125:21: note: in expansion of macro ‘MY_MQTT_SUBSCRIBE_TOPIC_PREFIX’ if (strcmp(str, MY_MQTT_SUBSCRIBE_TOPIC_PREFIX) != 0) { ^ In file included from ./MySensors.h:225:0, from examples_linux/mysGateway.cpp:44: ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::connect(const char*, const char*, const char*, const char*, uint8_t, boolean, const char*)’: ./drivers/PubSubClient/PubSubClient.cpp:176:55: error: ‘millis’ was not declared in this scope lastInActivity = lastOutActivity = millis(); ^ ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::readByte(uint8_t*)’: ./drivers/PubSubClient/PubSubClient.cpp:210:37: error: ‘millis’ was not declared in this scope uint32_t previousMillis = millis(); ^ ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::loop()’: ./drivers/PubSubClient/PubSubClient.cpp:284:34: error: ‘millis’ was not declared in this scope unsigned long t = millis(); ^and more, more similar errors. with --my-gateway=ethernet compiled fine
-
very nice fork. but... i can't compile it:
git clone https://github.com/marceloaqno/MySensors.git cd MySensors ./configure --my-gateway=mqtt --my-rf24-channel=1 --my-rf24-pa-level=RF24_PA_MAX --my-controller-ip-address=127,0,0,1 --my-mqtt-client-id=MyGW2 --my-mqtt-publish-topic-prefix="MyGW2out" --my-mqtt-subscribe-topic-prefix="MyGW2in" makeg++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/EthernetClient.o drivers/Linux/EthernetClient.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/compatibility.o drivers/Linux/compatibility.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/IPAddress.o drivers/Linux/IPAddress.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o drivers/Linux/EthernetServer.o drivers/Linux/EthernetServer.cpp g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DLINUX -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=MyGW2in -DMY_MQTT_PUBLISH_TOPIC_PREFIX=MyGW2out -DMY_MQTT_CLIENT_ID=MyGW2 -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_PA_LEVEL=RF24_PA_MAX -DMY_RF24_CHANNEL=1 -I. -I./core -I./drivers/Linux -I/usr/local/include/RF24 -MMD -c -o examples_linux/mysGateway.o examples_linux/mysGateway.cpp ./core/MyProtocolMySensors.cpp: In function ‘bool protocolMQTTParse(MyMessage&, char*, uint8_t*, unsigned int)’: <command-line>:0:32: error: ‘MyGW2in’ was not declared in this scope ./core/MyProtocolMySensors.cpp:125:21: note: in expansion of macro ‘MY_MQTT_SUBSCRIBE_TOPIC_PREFIX’ if (strcmp(str, MY_MQTT_SUBSCRIBE_TOPIC_PREFIX) != 0) { ^ In file included from ./MySensors.h:225:0, from examples_linux/mysGateway.cpp:44: ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::connect(const char*, const char*, const char*, const char*, uint8_t, boolean, const char*)’: ./drivers/PubSubClient/PubSubClient.cpp:176:55: error: ‘millis’ was not declared in this scope lastInActivity = lastOutActivity = millis(); ^ ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::readByte(uint8_t*)’: ./drivers/PubSubClient/PubSubClient.cpp:210:37: error: ‘millis’ was not declared in this scope uint32_t previousMillis = millis(); ^ ./drivers/PubSubClient/PubSubClient.cpp: In member function ‘boolean PubSubClient::loop()’: ./drivers/PubSubClient/PubSubClient.cpp:284:34: error: ‘millis’ was not declared in this scope unsigned long t = millis(); ^and more, more similar errors. with --my-gateway=ethernet compiled fine
@b0rmann It should work now. Thank you for reporting this.
-
Do I get it right that this is a RPi gateway with directly connected RF24L01+ tranceiver with support for both ethernet and MQTT?
If so, is there a guide somewhere on how to set this all up?
@ericvdb That's right. I hope to add support for RFM69, Serial and software signing very soon.
To use, clone the raspberryPi port for MySensors 2.0:
git clone https://github.com/marceloaqno/MySensors.git cd MySensorsTo configure it, take a look at the options available within configure:
./configure --helpFor other options, you may have to edit the sample file example_linux/mysGateway.cpp, and uncoment what you need.
Once done, run:
make sudo make installTo run the gateway you need to be root or use sudo:
sudo msyGateway -hFor wiring, follow this guide:
https://forum.mysensors.org/topic/2437/step-by-step-procedure-to-connect-the-nrf24l01-to-the-gpio-pins-and-use-the-raspberry-as-a-serial-gateway-mysensors-1-x