The NRF24L01+ chip is used in many MySensors projects. This chip depends on an additional processor like an ATMEGA. With Nordic Semiconductor NRF5 series a powerful alternative is available.
The NRF5 chips have an on-chip radio module which is compatible with the NRF24 series or BLE. At the current state, BLE is not supported by MySensors. The NRF5 series has a lot of internal Hardware:
With Shortcuts and the PPI (Programmable peripheral interconnect), the periphery can do a lot, work without CPU interaction like enable or disable radio on a timer event.
At the moment two series are available. The nRF51 series including the nRF51822 (BLE license) and nRF51422 (BLE & ANT+ license) and the nRF52 series including the nRF52832. An enhanced version, the nRF52840 is in hardware development and currently not available and not supported by MySensors.
There are a lot of modules available. If you plan to use an nRF5 module with MySensors you have to choose a Version with the high-frequency oscillator, this is included in most modules available.
If you plan a battery-powered sensor, you should choose a module including the low-frequency oscillator (32,768kHz) for precise low power sleep modes and the inductor the for DC/DC regulator. The NRF52 do things faster while consuming less power.
Arduino doesn't support the nRF5 platform in a standard setup. You have to add the arduino-nRF5 platform via Arduino's Board Manager like described in https://github.com/sandeepmistry/arduino-nRF5/#installing
Use https://github.com/d00616/MySensors/tree/add_nrf5_platform for your MySensors installation until the code is merged.
There is no need to configure anything special to create a MySensors Node or Gateway. Add a "#define MY_RADIO_NRF5_ESB" to your sketch to enable the radio device in Enhanced ShockBurst mode (ESB). This mode is compatible with MySensors nRF24 implementation.
The nRF5 MCU has no EEPROM memory like AVR controllers. The internal flash can erased 10,000 (nRF52) or 20,000 (nRF51) times per page. To extend the lifetime there is implemented a NVRAM class. By using hwReadConfigBlock, hwWriteConfigBlock, hwReadConfig or hwWriteConfig the memory can accessed.
Any write operation is added to an internal log. This operation is fast until the log is full. When the log is full, a new flash page from an internal pool is written. This process can take up to 4 seconds. If you need to write often in a time critical situation, call the MySensors "sleep" function with a time > 5000ms. This forces to clear the log when its not possible to write more than 32 bytes.
The number of available writes per byte depending on the highest address written in NVRAM. When you only use the first 8 Bytes of the NVRAM, you have 5,100,000 write cycles per byte. If you use all 3072 bytes available, you have only 3,300 write cycles per byte.
Many of MySensors examples configure input with a pullup resistor by writing high to the input pin. This didn't work:
// Incorrect // pinMode(BUTTON_PIN,INPUT); // Setup the button // digitalWrite(BUTTON_PIN,HIGH); // Activate internal pull-up // Correct hwPinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
If you configure a pin as OUTPUT pin with pinMode command, the pin can drive a current of 2mA without violating the specification. If you want to use more current, you have to switch to the "High Drive" mode. Please read the GPIO documentation at https://infocenter.nordicsemi.com
At the moment on Arduino, there is no definition of various OUTPUT modes. If you want to access all nRF5 output modes, you have to use hwPinMode and the OUTPUT_... macro. The modes available are:
If you create your own interrupt routines, please use the NRF_RESET_EVENT macro to reset an event. This macro incorporates with the caching of NRF52 MCUs.
The MySensors port for nRF5 supports using the Watchdog. You can use the same commands like defined in "avr/wdt.h" but disable cannot disable the watchdog. The watchdog is set to a period of 36h of CPU runtime.
When the CPU is in a sleep mode, the watchdog timer is stopped.
Don't set the watchdog timeout below 4500ms, this can conflict with the usage of the NVRAM (s. EEPROM like memory)
While sleeping and wait for a pin change, the current consumption is 1mA. The needs fixed in arduino-nRF5: https://github.com/sandeepmistry/arduino-nRF5/issues/153