nRF5 action!
-
Good point. To avoid that as a potential problem then, can anyone suggest a better connector to use?
-
@NeverDie check out a product called "TAG-CONNECT". It is perfect for programming. It is used on the Nordic Semiconductor Beacon Reference Design.
@Jokgi said in nRF5 Bluetooth action!:
@NeverDie check out a product called "TAG-CONNECT". It is perfect for programming. It is used on the Nordic Semiconductor Beacon Reference Design.
Thank you. Here is an programmer with this connector: http://aconno.de/acnprog/
I don't know if this is compatible to the Beacon Reference Design, but its compatible with the nRF52 boards provided by aconno. -
@Jokgi said in nRF5 Bluetooth action!:
@NeverDie check out a product called "TAG-CONNECT". It is perfect for programming. It is used on the Nordic Semiconductor Beacon Reference Design.
Thank you. Here is an programmer with this connector: http://aconno.de/acnprog/
I don't know if this is compatible to the Beacon Reference Design, but its compatible with the nRF52 boards provided by aconno.@d00616 not familiar with the USB interface / tag connect. The ones I have used have the connector type that plugs onto the nRF5x-DK, uLinks, jlink lite, etc. a ten pin Micro Cortex connector to six or ten pin "pogo pin" tag-connect connector. There is also a clip that allows the connector to stay attached for debugging purposes.
-
A bit off-topic perhaps, but does anyone here happen to know what kind of switch Enocean uses to transduce a button press into the electrical energy needed to send a packet? I'm guessing it's some kind of piezo switch. Can just that transducer part be purchased by itself? I'm wondering whether the same trick can be done using an nRF5...
-
I would stick with cortex 10-pin connector. Mostly because it's (a) standard (b) a cable can be made without soldering by using IDC connectors and a ribbon cable.
The only downside is height.
Using USB connector for sometging that's not USB is generally a bad idea as it's not foolproof -
Is signing soft supported or not yet ?
The personalizer sketch do not have hash define for the NRF52.
-
Is signing soft supported or not yet ?
The personalizer sketch do not have hash define for the NRF52.
@ahmedadelhosni pull requests are always welcome.
-
Is signing soft supported or not yet ?
The personalizer sketch do not have hash define for the NRF52.
@ahmedadelhosni said in nRF5 Bluetooth action!:
Is signing soft supported or not yet ?
The personalizer sketch do not have hash define for the NRF52.The security personalizer is working with the NRF5X. Random numbers for the Soft Signing are generated with the internal AES hardware, seeded with the hardware number generator. This allows a fast and secure nonce generation.
At the Moment the NRF5 with Soft Signing is not at the same level like the ATSHA204, because the read back protection is not enabled. If you want to do this, you have to add some code.
-
What else should I turn-off to save power during sleep?
Presently, I turn-off these things: the radio, NFC, the high frequency clock, and uarte, Meanwhile, the low frequency clock is working.
Presently getting a sleep current drain of apprxoimately 2.8 microamps.
-
What else should I turn-off to save power during sleep?
Presently, I turn-off these things: the radio, NFC, the high frequency clock, and uarte, Meanwhile, the low frequency clock is working.
Presently getting a sleep current drain of apprxoimately 2.8 microamps.
@NeverDie said in nRF5 Bluetooth action!:
What else should I turn-off to save power during sleep?
Presently, I turn-off these things: the radio, NFC, the high frequency clock, and uarte, Meanwhile, the low frequency clock is working.
Presently getting a sleep current drain of apprxoimately 2.8 microamps.
Which chip are you talking about ?
-
nRF52832. I'm guessing the same will apply to the nRF51822, except for the NFC (which the nRF51822 doesn't have).
-
I should probably add that the 2.8ua is with the RTC and LPCOMP running. So, maybe it's already as low as it can go, I don't know. Just wondering if there are any other obvious suspects I should try turning off. I'll try i2C and SPI to see if it makes a difference... Not sure, but maybe SPI gets initialized through the header file without my even being aware of it.
-
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
-
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
@NeverDie said in nRF5 Bluetooth action!:
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
Is I2C or SPI used somewhere in your code?
-
@NeverDie said in nRF5 Bluetooth action!:
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
Is I2C or SPI used somewhere in your code?
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
Is I2C or SPI used somewhere in your code?
Not in the current test code that I'm running.
-
@d00616 said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
Well, it could be within the bounds of measurement error, but it appears that dropping I2c and SPI has reduced the drain to 2.6ua.
Is I2C or SPI used somewhere in your code?
Not in the current test code that I'm running.
@NeverDie said in nRF5 Bluetooth action!:
Not in the current test code that I'm running.
Interesting. The SPI is rated with <1µA idle current. TWI has no idle current in the datasheet.
-
@NeverDie said in nRF5 Bluetooth action!:
Not in the current test code that I'm running.
Interesting. The SPI is rated with <1µA idle current. TWI has no idle current in the datasheet.
-
So far, UARTE is the biggest offender. Turning off and disabling that saves a lot of current.
-
So, here is code which works! Many thanks to @d00616 and others for their helpful comments above.
To keep from distracting, I stripped out the radio code, but you can easily insert your favorite brand of that.
Basically, the sketch blinks an LED very briefly once every 5 seconds. Between blinks, it sleeps. However, if a leak is detected (which is equivalent to a button push), it wakes up immediately and blinks a lot. It runs on both nRF52832 and nRF51822. The sleep current is ~2.6ua on an nRF52832. To get sleep current that low, it is using the Low Power Comparator (LPCOMP) to watch for a change on the leak detector pin while the CPU sleeps.
I haven't yet measured the sleep current consumption on an nRF51822, but I expect it would be something comparable.
//This sketch is applicable to Coincell Multisensor nRF51822, version 10 #define MY_CORE_ONLY #define IS_NRF51 //true iff the target is an nRF51. If an nRF52, then comment this line out! #define I2C_INTERRUPT_PIN 3 #define LEAK_DETECTION_PIN 2 #include <nrf.h> #include <MySensors.h> volatile bool button_pressed=false; void blinkityBlink(uint8_t pulses, uint8_t repetitions) { for (int x=0;x<repetitions;x++) { for (int i=0;i<pulses;i++) { digitalWrite(LED_BUILTIN,HIGH); wait(20); digitalWrite(LED_BUILTIN,LOW); wait(100); } wait(500); } } void disableNfc() { //only applied to nRF52 #ifndef IS_NRF51 //Make pins 9 and 10 usable as GPIO pins. NRF_NFCT->TASKS_DISABLE=1; //disable NFC NRF_NVMC->CONFIG=1; // Write enable the UICR NRF_UICR->NFCPINS=0; //Make pins 9 and 10 usable as GPIO pins. NRF_NVMC->CONFIG=0; // Put the UICR back into read-only mode. #endif } void turnOffRadio() { NRF_RADIO->TASKS_DISABLE=1; while (!(NRF_RADIO->EVENTS_DISABLED)) {} //until radio is confirmed disabled } void turnOffUarte0() { #ifndef IS_NRF51 NRF_UARTE0->TASKS_STOPRX = 1; NRF_UARTE0->TASKS_STOPTX = 1; NRF_UARTE0->TASKS_SUSPEND = 1; NRF_UARTE0->ENABLE=0; //disable UART0 while (NRF_UARTE0->ENABLE!=0) {}; //wait until UART0 is confirmed disabled. #endif #ifdef IS_NRF51 NRF_UART0->TASKS_STOPRX = 1; NRF_UART0->TASKS_STOPTX = 1; NRF_UART0->TASKS_SUSPEND = 1; NRF_UART0->ENABLE=0; //disable UART0 while (NRF_UART0->ENABLE!=0) {}; //wait until UART0 is confirmed disabled. #endif } void turnOffAdc() { #ifndef IS_NRF51 if (NRF_SAADC->ENABLE) { //if enabled, then disable the SAADC NRF_SAADC->TASKS_STOP=1; while (NRF_SAADC->EVENTS_STOPPED) {} //wait until stopping of SAADC is confirmed NRF_SAADC->ENABLE=0; //disable the SAADC while (NRF_SAADC->ENABLE) {} //wait until the disable is confirmed } #endif } void turnOffHighFrequencyClock() { NRF_CLOCK->TASKS_HFCLKSTOP = 1; while ((NRF_CLOCK->HFCLKSTAT) & 0x0100) {} //wait as long as HF clock is still running. } void mySleepPrepare() { turnOffHighFrequencyClock(); turnOffRadio(); turnOffUarte0(); } void activateLpComp() { //NRF_LPCOMP->PSEL=1; // monitor AIN1 (pin P0.03 on nRF52832 test board). //while (!(NRF_LPCOMP->PSEL==1)) {} //wait until confirmed NRF_LPCOMP->PSEL=3; // monitor AIN3 (pin P0.02 on nRF51822 for coincell_multisensor_v10) while (!(NRF_LPCOMP->PSEL==3)) {} //wait until confirmed NRF_LPCOMP->REFSEL=1; // choose 1/4 VDD as the reference voltage while (!(NRF_LPCOMP->REFSEL==1)) {} //wait until confirmed NRF_LPCOMP->ANADETECT=1; //detect UP events. while (NRF_LPCOMP->ANADETECT!=1) {} //wait until confirmed NRF_LPCOMP->INTENSET=B0100; //Enable interrupt for UP event while (!(NRF_LPCOMP->INTENSET==B0100)) {} //wait until confirmed NRF_LPCOMP->ENABLE=1; //Enable LPCOMP while (!(NRF_LPCOMP->ENABLE==1)) {} //wait until confirmed NRF_LPCOMP->TASKS_START=1; //start the LPCOMP while (!(NRF_LPCOMP->EVENTS_READY)) {} //wait until ready NVIC_SetPriority(LPCOMP_IRQn, 15); NVIC_ClearPendingIRQ(LPCOMP_IRQn); NVIC_EnableIRQ(LPCOMP_IRQn); } void suspendLpComp() { //suspend getting more interrupts from LPCOMP before the first interrupt can be handled if ((NRF_LPCOMP->ENABLE) && (NRF_LPCOMP->EVENTS_READY)) { //if LPCOMP is enabled NRF_LPCOMP->INTENCLR=B0100; //disable interrupt from LPCOMP while (NRF_LPCOMP->INTENCLR==B0100) {} //wait until confirmed } } void resumeLpComp() { //suspend getting interrupts from LPCOMP NRF_LPCOMP->INTENSET=B0100; //Enable interrupt for UP event while (!(NRF_LPCOMP->INTENSET==B0100)) {} //wait until confirmed } void setup() { hwInit(); hwPinMode(LED_BUILTIN,OUTPUT_D0H1); disableNfc(); turnOffAdc(); activateLpComp(); blinkityBlink(2,1); //Signify end of setup with two quick pulses. mySleepPrepare(); button_pressed=false; } void loop() { sleep(5000); //sleep for 5 seconds. mySleepPrepare(); //An ounce of prevention: Turn-off HF clock, etc, ASAP to save power, just in case the library's sleep() routine resumed them. if (button_pressed) { //if a leak is detected suspendLpComp(); //suspend LPCOMP to prevent multiple interrupts blinkityBlink(10,3); //blink a lot to show that a leak was detected. button_pressed=false; //Clear the semaphore NRF_LPCOMP->EVENTS_UP=0; //Clear the semaphore resumeLpComp(); //operations of LPCOMP were suspended after detecting the LPCOMP iterrupt } else { blinkityBlink(1,1); //otherwise, just one short blink to indicate the wakeup was scheduled by the RTC } } // * Reset events and read back on nRF52 //* http://infocenter.nordicsemi.com/pdf/nRF52_Series_Migration_v1.0.pdf #if __CORTEX_M == 0x04 #define NRF5_RESET_EVENT(event) \ event = 0; \ (void)event #else #define NRF5_RESET_EVENT(event) event = 0 #endif // This must be in one line extern "C" { void LPCOMP_IRQHandler(void) {button_pressed=true; NRF5_RESET_EVENT(NRF_LPCOMP->EVENTS_UP); NRF_LPCOMP->EVENTS_UP=0; MY_HW_RTC->CC[0]=(MY_HW_RTC->COUNTER+2);}} -
So, here is code which works! Many thanks to @d00616 and others for their helpful comments above.
To keep from distracting, I stripped out the radio code, but you can easily insert your favorite brand of that.
Basically, the sketch blinks an LED very briefly once every 5 seconds. Between blinks, it sleeps. However, if a leak is detected (which is equivalent to a button push), it wakes up immediately and blinks a lot. It runs on both nRF52832 and nRF51822. The sleep current is ~2.6ua on an nRF52832. To get sleep current that low, it is using the Low Power Comparator (LPCOMP) to watch for a change on the leak detector pin while the CPU sleeps.
I haven't yet measured the sleep current consumption on an nRF51822, but I expect it would be something comparable.
//This sketch is applicable to Coincell Multisensor nRF51822, version 10 #define MY_CORE_ONLY #define IS_NRF51 //true iff the target is an nRF51. If an nRF52, then comment this line out! #define I2C_INTERRUPT_PIN 3 #define LEAK_DETECTION_PIN 2 #include <nrf.h> #include <MySensors.h> volatile bool button_pressed=false; void blinkityBlink(uint8_t pulses, uint8_t repetitions) { for (int x=0;x<repetitions;x++) { for (int i=0;i<pulses;i++) { digitalWrite(LED_BUILTIN,HIGH); wait(20); digitalWrite(LED_BUILTIN,LOW); wait(100); } wait(500); } } void disableNfc() { //only applied to nRF52 #ifndef IS_NRF51 //Make pins 9 and 10 usable as GPIO pins. NRF_NFCT->TASKS_DISABLE=1; //disable NFC NRF_NVMC->CONFIG=1; // Write enable the UICR NRF_UICR->NFCPINS=0; //Make pins 9 and 10 usable as GPIO pins. NRF_NVMC->CONFIG=0; // Put the UICR back into read-only mode. #endif } void turnOffRadio() { NRF_RADIO->TASKS_DISABLE=1; while (!(NRF_RADIO->EVENTS_DISABLED)) {} //until radio is confirmed disabled } void turnOffUarte0() { #ifndef IS_NRF51 NRF_UARTE0->TASKS_STOPRX = 1; NRF_UARTE0->TASKS_STOPTX = 1; NRF_UARTE0->TASKS_SUSPEND = 1; NRF_UARTE0->ENABLE=0; //disable UART0 while (NRF_UARTE0->ENABLE!=0) {}; //wait until UART0 is confirmed disabled. #endif #ifdef IS_NRF51 NRF_UART0->TASKS_STOPRX = 1; NRF_UART0->TASKS_STOPTX = 1; NRF_UART0->TASKS_SUSPEND = 1; NRF_UART0->ENABLE=0; //disable UART0 while (NRF_UART0->ENABLE!=0) {}; //wait until UART0 is confirmed disabled. #endif } void turnOffAdc() { #ifndef IS_NRF51 if (NRF_SAADC->ENABLE) { //if enabled, then disable the SAADC NRF_SAADC->TASKS_STOP=1; while (NRF_SAADC->EVENTS_STOPPED) {} //wait until stopping of SAADC is confirmed NRF_SAADC->ENABLE=0; //disable the SAADC while (NRF_SAADC->ENABLE) {} //wait until the disable is confirmed } #endif } void turnOffHighFrequencyClock() { NRF_CLOCK->TASKS_HFCLKSTOP = 1; while ((NRF_CLOCK->HFCLKSTAT) & 0x0100) {} //wait as long as HF clock is still running. } void mySleepPrepare() { turnOffHighFrequencyClock(); turnOffRadio(); turnOffUarte0(); } void activateLpComp() { //NRF_LPCOMP->PSEL=1; // monitor AIN1 (pin P0.03 on nRF52832 test board). //while (!(NRF_LPCOMP->PSEL==1)) {} //wait until confirmed NRF_LPCOMP->PSEL=3; // monitor AIN3 (pin P0.02 on nRF51822 for coincell_multisensor_v10) while (!(NRF_LPCOMP->PSEL==3)) {} //wait until confirmed NRF_LPCOMP->REFSEL=1; // choose 1/4 VDD as the reference voltage while (!(NRF_LPCOMP->REFSEL==1)) {} //wait until confirmed NRF_LPCOMP->ANADETECT=1; //detect UP events. while (NRF_LPCOMP->ANADETECT!=1) {} //wait until confirmed NRF_LPCOMP->INTENSET=B0100; //Enable interrupt for UP event while (!(NRF_LPCOMP->INTENSET==B0100)) {} //wait until confirmed NRF_LPCOMP->ENABLE=1; //Enable LPCOMP while (!(NRF_LPCOMP->ENABLE==1)) {} //wait until confirmed NRF_LPCOMP->TASKS_START=1; //start the LPCOMP while (!(NRF_LPCOMP->EVENTS_READY)) {} //wait until ready NVIC_SetPriority(LPCOMP_IRQn, 15); NVIC_ClearPendingIRQ(LPCOMP_IRQn); NVIC_EnableIRQ(LPCOMP_IRQn); } void suspendLpComp() { //suspend getting more interrupts from LPCOMP before the first interrupt can be handled if ((NRF_LPCOMP->ENABLE) && (NRF_LPCOMP->EVENTS_READY)) { //if LPCOMP is enabled NRF_LPCOMP->INTENCLR=B0100; //disable interrupt from LPCOMP while (NRF_LPCOMP->INTENCLR==B0100) {} //wait until confirmed } } void resumeLpComp() { //suspend getting interrupts from LPCOMP NRF_LPCOMP->INTENSET=B0100; //Enable interrupt for UP event while (!(NRF_LPCOMP->INTENSET==B0100)) {} //wait until confirmed } void setup() { hwInit(); hwPinMode(LED_BUILTIN,OUTPUT_D0H1); disableNfc(); turnOffAdc(); activateLpComp(); blinkityBlink(2,1); //Signify end of setup with two quick pulses. mySleepPrepare(); button_pressed=false; } void loop() { sleep(5000); //sleep for 5 seconds. mySleepPrepare(); //An ounce of prevention: Turn-off HF clock, etc, ASAP to save power, just in case the library's sleep() routine resumed them. if (button_pressed) { //if a leak is detected suspendLpComp(); //suspend LPCOMP to prevent multiple interrupts blinkityBlink(10,3); //blink a lot to show that a leak was detected. button_pressed=false; //Clear the semaphore NRF_LPCOMP->EVENTS_UP=0; //Clear the semaphore resumeLpComp(); //operations of LPCOMP were suspended after detecting the LPCOMP iterrupt } else { blinkityBlink(1,1); //otherwise, just one short blink to indicate the wakeup was scheduled by the RTC } } // * Reset events and read back on nRF52 //* http://infocenter.nordicsemi.com/pdf/nRF52_Series_Migration_v1.0.pdf #if __CORTEX_M == 0x04 #define NRF5_RESET_EVENT(event) \ event = 0; \ (void)event #else #define NRF5_RESET_EVENT(event) event = 0 #endif // This must be in one line extern "C" { void LPCOMP_IRQHandler(void) {button_pressed=true; NRF5_RESET_EVENT(NRF_LPCOMP->EVENTS_UP); NRF_LPCOMP->EVENTS_UP=0; MY_HW_RTC->CC[0]=(MY_HW_RTC->COUNTER+2);}}