nRF5 action!
-
@NeverDie said in nRF5 Bluetooth action!:
Which settings are key for ensuring that packets sent by the nRF24 are correctly received by the nRF5? It would be nice to leverage the versions of the nRF24 that have amplified Tx.
These are more than settings. You have to set the Radio configuration like in Radio_ESB.cpp, reverse the addresses and handle sending ACK packages by software.
This is a good resource to understand the OTA protocol: https://hackaday.io/project/11942-antenna-diversity-receive-and-transmit/log/39510-shockburst-vs-enhanced-shockburst-nrf24-vs-nrf5x
I can provide a simple example how to use the MySensors transport code without Radio Head. This works for nRF5 and nRF24 modules, but its outside of that what the MY_CORE_ONLY mode is designed for.
#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> void setup() { Serial.begin(115200); hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } void loop() { // Check for packages while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } wait(1000); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); }@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
Which settings are key for ensuring that packets sent by the nRF24 are correctly received by the nRF5? It would be nice to leverage the versions of the nRF24 that have amplified Tx.
These are more than settings. You have to set the Radio configuration like in Radio_ESB.cpp, reverse the addresses and handle sending ACK packages by software.
This is a good resource to understand the OTA protocol: https://hackaday.io/project/11942-antenna-diversity-receive-and-transmit/log/39510-shockburst-vs-enhanced-shockburst-nrf24-vs-nrf5x
I can provide a simple example how to use the MySensors transport code without Radio Head. This works for nRF5 and nRF24 modules, but its outside of that what the MY_CORE_ONLY mode is designed for.
#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> void setup() { Serial.begin(115200); hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } void loop() { // Check for packages while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } wait(1000); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); }I tried compiling it using the Arduino Windows IDE, but for some reason it complains about not finding a whole litany of .h files: socket.h, w5100.h, netdb.h.... Does mysensors.h really need to drag in all of those .h files, even if only indirectly? Or, if there's an easy way to make it find them, what is it?
-
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
Which settings are key for ensuring that packets sent by the nRF24 are correctly received by the nRF5? It would be nice to leverage the versions of the nRF24 that have amplified Tx.
These are more than settings. You have to set the Radio configuration like in Radio_ESB.cpp, reverse the addresses and handle sending ACK packages by software.
This is a good resource to understand the OTA protocol: https://hackaday.io/project/11942-antenna-diversity-receive-and-transmit/log/39510-shockburst-vs-enhanced-shockburst-nrf24-vs-nrf5x
I can provide a simple example how to use the MySensors transport code without Radio Head. This works for nRF5 and nRF24 modules, but its outside of that what the MY_CORE_ONLY mode is designed for.
#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> void setup() { Serial.begin(115200); hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } void loop() { // Check for packages while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } wait(1000); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); }I tried compiling it using the Arduino Windows IDE, but for some reason it complains about not finding a whole litany of .h files: socket.h, w5100.h, netdb.h.... Does mysensors.h really need to drag in all of those .h files, even if only indirectly? Or, if there's an easy way to make it find them, what is it?
@NeverDie said in nRF5 Bluetooth action!:
I tried compiling it using the Arduino Windows IDE, but for some reason it complains about not finding a whole litany of .h files: socket.h, w5100.h, netdb.h.... Does mysensors.h really need to drag in all of those .h files, even if only indirectly? Or, if there's an easy way to make it find them, what is it?
I can compile it with Linux. What are missing is part of the Ethernet library. I don't know why it's included in you build.
-
@NeverDie said in nRF5 Bluetooth action!:
I tried compiling it using the Arduino Windows IDE, but for some reason it complains about not finding a whole litany of .h files: socket.h, w5100.h, netdb.h.... Does mysensors.h really need to drag in all of those .h files, even if only indirectly? Or, if there's an easy way to make it find them, what is it?
I can compile it with Linux. What are missing is part of the Ethernet library. I don't know why it's included in you build.
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. :) So, if anyone else encounters the same problem, I recommend doing that.
-
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. :) So, if anyone else encounters the same problem, I recommend doing that.
@NeverDie said in nRF5 Bluetooth action!:
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. So, if anyone else encounters the same problem, I recommend doing that.
Sorry. I have forgotten my uncommited changes. At the moment, you have to start the HFCLK in the CORE_ONLY mode. This is done in hwInit() later.
-
@NeverDie said in nRF5 Bluetooth action!:
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. So, if anyone else encounters the same problem, I recommend doing that.
Sorry. I have forgotten my uncommited changes. At the moment, you have to start the HFCLK in the CORE_ONLY mode. This is done in hwInit() later.
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. So, if anyone else encounters the same problem, I recommend doing that.
... At the moment, you have to start the HFCLK in the CORE_ONLY mode. ...
Do you have a revised sketch which does that? I tried running the sketch you gave above on an nRF52 DK, but it immediately goes into a boot-loop, wherein in keeps rebooting itself, over and over and over again.
-
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
I just now upgraded to the current release of the mysensors development library, and the compile problem went away. So, if anyone else encounters the same problem, I recommend doing that.
... At the moment, you have to start the HFCLK in the CORE_ONLY mode. ...
Do you have a revised sketch which does that? I tried running the sketch you gave above on an nRF52 DK, but it immediately goes into a boot-loop, wherein in keeps rebooting itself, over and over and over again.
@NeverDie said in nRF5 Bluetooth action!:
I tried running the sketch you gave above on an nRF52 DK, but it immediately goes into a boot-loop, wherein in keeps rebooting itself, over and over and over again.
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
-
@NeverDie said in nRF5 Bluetooth action!:
I tried running the sketch you gave above on an nRF52 DK, but it immediately goes into a boot-loop, wherein in keeps rebooting itself, over and over and over again.
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
@NeverDie said in nRF5 Bluetooth action!:
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
Please replace wait() with delay(). This is an issue in the transport code, which is triggered while sleep() or wait() is executed.
-
@NeverDie said in nRF5 Bluetooth action!:
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
Please replace wait() with delay(). This is an issue in the transport code, which is triggered while sleep() or wait() is executed.
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
Please replace wait() with delay(). This is an issue in the transport code, which is triggered while sleep() or wait() is executed.
OK, made that change, and it no longer boot-loops.
However, neither node appears to be receiving anything from the other.
Please advise.
-
@NeverDie said in nRF5 Bluetooth action!:
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
Please replace wait() with delay(). This is an issue in the transport code, which is triggered while sleep() or wait() is executed.
@d00616
Since the original code didn't work, I upgraded it somewhat to give a larger Rx window. However, it still doesn't work:#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> void setup() { Serial.begin(115200); Serial.println("Starting...."); Serial.print("MY_NODE_ID="); Serial.println(MY_NODE_ID); Serial.print("SND_TO="); Serial.println(SND_TO); hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } uint32_t theTime=0; uint32_t loopCounter=0; void loop() { // Check for packages while ((millis()-theTime)<1000) { while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } } theTime=millis(); //delay(1000); Serial.print(loopCounter++); Serial.println(", SENDING: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); }One node is an nRF24 on a pro mini, and the other is an nRF52832.
-
@d00616
Since the original code didn't work, I upgraded it somewhat to give a larger Rx window. However, it still doesn't work:#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> void setup() { Serial.begin(115200); Serial.println("Starting...."); Serial.print("MY_NODE_ID="); Serial.println(MY_NODE_ID); Serial.print("SND_TO="); Serial.println(SND_TO); hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } uint32_t theTime=0; uint32_t loopCounter=0; void loop() { // Check for packages while ((millis()-theTime)<1000) { while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } } theTime=millis(); //delay(1000); Serial.print(loopCounter++); Serial.println(", SENDING: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); }One node is an nRF24 on a pro mini, and the other is an nRF52832.
@NeverDie said in nRF5 Bluetooth action!:
Since the original code didn't work, I upgraded it somewhat to give a larger Rx window. However, it still doesn't work:
Please add this to your setup() function (https://forum.mysensors.org/topic/6961/nrf5-bluetooth-action/985):
// Clock is manged by sleep modes. Radio depends on HFCLK. // Force to start HFCLK NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) ; // Enable low latency sleep mode NRF_POWER->TASKS_CONSTLAT = 1; // Enable cache on >= NRF52 #ifndef NRF51 NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Msk; #endifAt the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
-
@NeverDie said in nRF5 Bluetooth action!:
I just now tried running it on a pro-mini using a nRF24, and it also gets into a boot-loop.
Please replace wait() with delay(). This is an issue in the transport code, which is triggered while sleep() or wait() is executed.
-
@Toyman said in nRF5 Bluetooth action!:
@d00616 is this universal recommendation?
I think you mean to start the HFCLK. This isn't a universal recommendation. At the moment the HFCLK is started in MyMainNRF5.cpp. This file is ignored in CORE_ONLY mode. I moved any initialization code into hwInit().
-
@NeverDie said in nRF5 Bluetooth action!:
Since the original code didn't work, I upgraded it somewhat to give a larger Rx window. However, it still doesn't work:
Please add this to your setup() function (https://forum.mysensors.org/topic/6961/nrf5-bluetooth-action/985):
// Clock is manged by sleep modes. Radio depends on HFCLK. // Force to start HFCLK NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) ; // Enable low latency sleep mode NRF_POWER->TASKS_CONSTLAT = 1; // Enable cache on >= NRF52 #ifndef NRF51 NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Msk; #endifAt the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
@d00616 said in nRF5 Bluetooth action!:
At the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
The Pull Request is available: https://github.com/mysensors/MySensors/pull/938
-
@d00616 said in nRF5 Bluetooth action!:
At the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
The Pull Request is available: https://github.com/mysensors/MySensors/pull/938
@d00616 said in nRF5 Bluetooth action!:
@d00616 said in nRF5 Bluetooth action!:
At the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
The Pull Request is available: https://github.com/mysensors/MySensors/pull/938
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
-
@d00616 said in nRF5 Bluetooth action!:
@d00616 said in nRF5 Bluetooth action!:
At the moment I prepare a new Pull Request fixing this including some small fixes and improvements for nRF5 MCUs. When it's integrated the HFCLK is startet in hwInit().
The Pull Request is available: https://github.com/mysensors/MySensors/pull/938
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
@NeverDie said in nRF5 Bluetooth action!:
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
You have to checkout this pull request: https://help.github.com/articles/checking-out-pull-requests-locally/
-
@NeverDie said in nRF5 Bluetooth action!:
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
You have to checkout this pull request: https://help.github.com/articles/checking-out-pull-requests-locally/
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
You have to checkout this pull request: https://help.github.com/articles/checking-out-pull-requests-locally/
Maybe I need write-access or something? Those instructions refer to a command line, and I just don't see one anywhere.

-
Well, anyway, I added code to start the high frequency clock, and now it seems to work:
#define MY_CORE_ONLY #ifndef ARDUINO_ARCH_NRF5 #define MY_NODE_ID (1) #define SND_TO (2) #else #define MY_NODE_ID (2) #define SND_TO (1) #endif // Enable debug #define MY_DEBUG //#define MY_DEBUG_VERBOSE_RF24 //#define MY_DEBUG_VERBOSE_NRF5_ESB // RF24_250KBPS RF24_1MBPS RF24_2MBPS #define MY_RF24_DATARATE (RF24_1MBPS) // NRF5_250KBPS NRF5_1MBPS NRF5_2MBPS #define MY_NRF5_ESB_MODE (NRF5_1MBPS) // Enable and select radio type attached #ifndef NRF5 #define MY_RADIO_NRF24 #else #define MY_RADIO_NRF5_ESB #endif #include <MySensors.h> #include <nrf.h> void setup() { Serial.begin(115200); Serial.println("Starting...."); Serial.print("MY_NODE_ID="); Serial.println(MY_NODE_ID); Serial.print("SND_TO="); Serial.println(SND_TO); if (MY_NODE_ID==2) { NRF_CLOCK->TASKS_HFCLKSTART=1; //activate the high frequency crystal oscillator while ((NRF_CLOCK->EVENTS_HFCLKSTARTED==0)) {}; //wait until high frequency clock start is confirmed } hwInit(); transportInit(); transportSetAddress(MY_NODE_ID); } uint32_t theTime=0; uint32_t loopCounter=0; void loop() { // Check for packages while ((millis()-theTime)<1000) { while (transportAvailable()) { uint8_t buffer[256]; uint8_t num = transportReceive(&buffer); Serial.print("Data="); for (int i=0;i<num;i++) { if (buffer[i]<0x10) Serial.print("0"); Serial.print(buffer[i], HEX); Serial.print(" "); } Serial.println(); } } theTime=millis(); //delay(1000); Serial.print(loopCounter++); Serial.println(", SENDING: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); // Send data transportSend(SND_TO, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",32, false); } -
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
That link lists changes to the files, but it doesn't seem to provide the new files. Or else I'm overlooking where it does?
You have to checkout this pull request: https://help.github.com/articles/checking-out-pull-requests-locally/
Maybe I need write-access or something? Those instructions refer to a command line, and I just don't see one anywhere.

@NeverDie said in nRF5 Bluetooth action!:
Maybe I need write-access or something? Those instructions refer to a command line, and I just don't see one anywhere.
You can do this with git on your local machine:
git clone https://github.com/mysensors/MySensors.git cd MySensors git fetch origin pull/938/head:pr938 git checkout pr938 -
@NeverDie said in nRF5 Bluetooth action!:
Maybe I need write-access or something? Those instructions refer to a command line, and I just don't see one anywhere.
You can do this with git on your local machine:
git clone https://github.com/mysensors/MySensors.git cd MySensors git fetch origin pull/938/head:pr938 git checkout pr938@d00616
Thanks for trying. That would probably work with a linux machine, but mine is running Windows. I'm surprised there's no easy way to do this from Windows.I guess I'll just wait for the next developers release of mysensors.
