Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)
-
@ahmedadelhosni said:
Is connecting the nrf directly to the pi causes any problems and u need to restart it ?
No, I have not had any big problems. The problem may only be the nrf24l01+ - I had to have a few changed plus fix the con to make it work. Wiring could be an issue. Also pay attention to CE pin.
CE Pin = Custom GPIO25 (I have Custom GPIO22) - this can be changed by the constructorExcellent write-up
-
Very nice writeup.
One thing that comes to mind is, the latest rasbian Jessie uses systemd instead of init. It would be good if we could add a systemd unit file to the library and a description here how to use it.
-
Thanks for the writeup @mfalkvidd. I'll add it to the main site when updating for the 1.6 release.
If someone feel comfortable merging the RPi specific code to the MySensors library in the development branch, let me know. Would've been nice to have one codebase as the RPi code has diverged from Arduino quite a bit since it was created.
A configure/autoconf is also something I'd need help with.
-
Great write-up! Should we consider instructions on how to create an init.d start/stop script so it can run as a daemon? I've done this, however, I'm having a hard time getting the output to log to syslog. (would be nice for monitoring/diagnostics purposes) The logging doesn't happen until I stop/kill the service.
pi@homeauto01 ~ $ cat /etc/init.d/PiGatewaySerial #! /bin/sh # /etc/init.d/PiGatewaySerial ### BEGIN INIT INFO # Provides: PiGatewaySerial # Required-Start: $all # Required-Stop: # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start and stop PiGatewaySerial # Description: PiGatewaySerial ### END INIT INFO # The following part carries out specific functions depending on arguments. case "$1" in start) echo "Starting PiGatewaySerial" /root/Raspberry/PiGatewaySerial 2>&1 | logger & ;; stop) echo "Stopping PiGatewaySerial" killall PiGatewaySerial ;; *) echo "Usage: /etc/init.d/PiGatewaySerial {start|stop}" exit 1 ;; esac exit 0 -
Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.
https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial
-
Excellent writeup, double plus plus good !!!
-
@mfalkvidd
:+1: :clap: -
@mfalkvidd I used direct NRF24l01+ with RPI long ago and I felt slow data transfer compare to
USB-to-Serial(ttl)<-->MySensors Gatewayconnection. especially on OTA firmware update. -
@mfalkvidd I used direct NRF24l01+ with RPI long ago and I felt slow data transfer compare to
USB-to-Serial(ttl)<-->MySensors Gatewayconnection. especially on OTA firmware update.@jkandasa said:
@mfalkvidd I used direct NRF24l01+ with RPI long ago and I felt slow data transfer compare to
USB-to-Serial(ttl)<-->MySensors Gatewayconnection. especially on OTA firmware update.Thanks. Let's add that under the other notes section.
-
This is a very good work !
Is there anything in place for RFM69 ? Would it be difficult to port the code from arduino to rpi ? (I have never coded on RPI).
Also, do you think any performance difference is involved in managing the radio directly from the RPI, compared to having a dedicated atmega/arduino ? Especially if a controller solution is already running on it?
-
My experience: the Raspberry 2 indicates usually less then 1% processor, with very occasional maximum peaks to 15%. So I would say, Raspberry 2: no worries. My setup is Domoticz + NRF24based gateway on the same Raspi.
-
Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.
https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial
@martinhjelmare said:
Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.
https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial
Ugh! Correct. Also, @mfalkvidd did cover this with his "MAKE THE GATEWAY AUTOSTART" section.....If I only could read! I will test this soon to see how the logging works.
Finally, by enabling ser2net and adding something like this to /etc/ser2net.conf:
5003:raw:600/dev/ttyMySensorsGateway....you have yourself an Ethernet Gateway! Great stuff! Thanks again!
-
This is a very good work !
Is there anything in place for RFM69 ? Would it be difficult to port the code from arduino to rpi ? (I have never coded on RPI).
Also, do you think any performance difference is involved in managing the radio directly from the RPI, compared to having a dedicated atmega/arduino ? Especially if a controller solution is already running on it?
@Myna said:
This is a very good work !
Is there anything in place for RFM69 ? Would it be difficult to port the code from arduino to rpi ? (I have never coded on RPI).
Also, do you think any performance difference is involved in managing the radio directly from the RPI, compared to having a dedicated atmega/arduino ? Especially if a controller solution is already running on it?
I've got no experience myself with rfm69 yet, but I've been thinking about it and searching the web says it should work, connecting the rfm69 to the raspberry pi, for example here:
https://github.com/abouillot/HomeAutomation/tree/master/piGatewayThere are also custom pcbs for simplicity, don't know if it's tested though:
https://oshpark.com/profiles/thinkpeace -
Perhaps re-word the last note from:
A user experienced data transfer compare to USB-to-Serial(ttl)<-->MySensors Gateway connection. especially on OTA firmware update. If you think this will cause a problem for you, an ethernet gateway might be a better alternative.
to:
A user notes that data transfer speeds are comparable to that of a USB-to-Serial(ttl)<-->MySensors Gateway connections. If you think this may be an issue for your application (e.g. OTA firmware updates), an ethernet gateway might be a better alternative.
thanx,
JpS -
I have a trouble with CPU utilization when I start the gateway : 100% all the time. I use Jessie and not Wheezy on a RPI 2. Does someone can help me to troubleshoot this problem ? I have not add a decoupling capacitor , can it be the reason ?
Solved : see this post
-
I have a trouble with CPU utilization when I start the gateway : 100% all the time. I use Jessie and not Wheezy on a RPI 2. Does someone can help me to troubleshoot this problem ? I have not add a decoupling capacitor , can it be the reason ?
Solved : see this post
@minscof said:
I have a trouble with CPU utilization when I start the gateway : 100% all the time. I use Jessie and not Wheezy on a RPI 2. Does someone can help me to troubleshoot this problem ? I have not add a decoupling capacitor , can it be the reason ?
This happened to me as well, I mixed up the boards I had at home and discover later it was a B+ and not a RPI2 :-) Maybe you've made the same mistake?
-
@minscof got an answer in this thread: http://forum.mysensors.org/topic/2367/pigatewayserial-using-interrupts/3
The high cpu usage will go away as soon as you start your controller (or something else that reads from the tty the gateway creates).