jeanmatthieud / nrf51822-low-power-sensor

A low power sensor based on the NRF51822 chip and the Arduino framework.
https://www.iot-experiments.com/nrf51822-and-ble400/
15 stars 1 forks source link

Issue #1

Open tcpipchip opened 4 years ago

tcpipchip commented 4 years ago

Can i do some comments ?

jeanmatthieud commented 4 years ago

You can find some explanation on the dedicated article: https://www.iot-experiments.com/nrf51822-and-ble400/

tcpipchip commented 4 years ago

Jean, first of all, congratulations about your Article! It´s really good!!!!!

Your code is running nice in a NRF51822 module!

But i would like to ask some help...if possible...

in piece of code sd_app_evt_wait();

That makes the the NRF51822 in sleep until:

Right ?

Do you have some tip to make sd_app_evt_wait() in sleep during only 3 seconds and then execute the updateAdvertisingScanData() in the loop() ?

My idea is to execute updateAdvertisingScanData() each 3 seconds in loop()

Thank you Jean!!!!!

tcpipchip commented 4 years ago

Hi Jean, can you help me ?

tcpipchip commented 4 years ago

Jean

How are you ?

How can i enable the


De: Jean-Matthieu DECHRISTÉ notifications@github.com Enviado: quarta-feira, 25 de setembro de 2019 08:51 Para: jeanmatthieud/nrf51822-low-power-sensor nrf51822-low-power-sensor@noreply.github.com Cc: tcpipchip tcpipchip@hotmail.com; Author author@noreply.github.com Assunto: Re: [jeanmatthieud/nrf51822-low-power-sensor] Issue (#1)

You can find some explanation on the dedicated article: https://www.iot-experiments.com/nrf51822-and-ble400/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jeanmatthieud/nrf51822-low-power-sensor/issues/1?email_source=notifications&email_token=ACXUZTHEY63V323KVQNIADDQLMRCFA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7REDTA#issuecomment-534921676, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACXUZTBJX75I644HQ2YN4CTQLMRCFANCNFSM4I2EGEVQ.

tcpipchip commented 4 years ago

Jean

How are you ?

How can i enable the

attachInterruptLowAccuracy

function ?

The platformio cant find it !

Where is this function ?

Thank you so much!


De: Jean-Matthieu DECHRISTÉ notifications@github.com Enviado: quarta-feira, 25 de setembro de 2019 08:51 Para: jeanmatthieud/nrf51822-low-power-sensor nrf51822-low-power-sensor@noreply.github.com Cc: tcpipchip tcpipchip@hotmail.com; Author author@noreply.github.com Assunto: Re: [jeanmatthieud/nrf51822-low-power-sensor] Issue (#1)

You can find some explanation on the dedicated article: https://www.iot-experiments.com/nrf51822-and-ble400/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jeanmatthieud/nrf51822-low-power-sensor/issues/1?email_source=notifications&email_token=ACXUZTHEY63V323KVQNIADDQLMRCFA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7REDTA#issuecomment-534921676, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACXUZTBJX75I644HQ2YN4CTQLMRCFANCNFSM4I2EGEVQ.

jeanmatthieud commented 4 years ago

Hi,

If you want to wake up your device every 3 seconds, I think you can do that with a specific timer interrupt. I did not used this kind of functionality yet. To use the attachInterruptLowAccuracy() function, you need to change the platform definition in your platform.ini file as in this repo : https://github.com/jeanmatthieud/nrf51822-low-power-sensor/blob/master/platformio.ini

tcpipchip commented 4 years ago

Hi, timers make the ble stack to stop! I dont know why! Thank you so much to help me! I will test that

Enviado do meu iPhone

Em 29 de out de 2019, às 13:02, Jean-Matthieu DECHRISTÉ notifications@github.com<mailto:notifications@github.com> escreveu:

Hi,

If you want to wake up your device every 3 seconds, I think you can do that with a specific timer interrupt. I did not used this kind of functionality yet. To use the attachInterruptLowAccuracy() function, you need to change the platform definition in your platform.ini file as in this repo : https://github.com/jeanmatthieud/nrf51822-low-power-sensor/blob/master/platformio.ini

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jeanmatthieud/nrf51822-low-power-sensor/issues/1?email_source=notifications&email_token=ACXUZTC2UPIQ6GRAEJWMNWLQRBNBVA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECRCMUI#issuecomment-547497553, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEMN3J5RNVHJTAIVWLQRBNBVANCNFSM4I2EGEVQ.

tcpipchip commented 4 years ago

hi, falling and rising works

change not

tcpipchip commented 4 years ago

hi, falling and rising works

change not


De: Jean-Matthieu DECHRISTÉ notifications@github.com Enviado: terça-feira, 29 de outubro de 2019 16:02 Para: jeanmatthieud/nrf51822-low-power-sensor nrf51822-low-power-sensor@noreply.github.com Cc: tcpipchip tcpipchip@hotmail.com; Author author@noreply.github.com Assunto: Re: [jeanmatthieud/nrf51822-low-power-sensor] Issue (#1)

Hi,

If you want to wake up your device every 3 seconds, I think you can do that with a specific timer interrupt. I did not used this kind of functionality yet. To use the attachInterruptLowAccuracy() function, you need to change the platform definition in your platform.ini file as in this repo : https://github.com/jeanmatthieud/nrf51822-low-power-sensor/blob/master/platformio.ini

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jeanmatthieud/nrf51822-low-power-sensor/issues/1?email_source=notifications&email_token=ACXUZTC2UPIQ6GRAEJWMNWLQRBNBVA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECRCMUI#issuecomment-547497553, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEMN3J5RNVHJTAIVWLQRBNBVANCNFSM4I2EGEVQ.

tcpipchip commented 4 years ago

Jean, can you implement to us a routine that wakeup the ble processor each 10 seconds ?

Let me know the cost


De: Jean-Matthieu DECHRISTÉ notifications@github.com Enviado: terça-feira, 29 de outubro de 2019 16:02 Para: jeanmatthieud/nrf51822-low-power-sensor nrf51822-low-power-sensor@noreply.github.com Cc: tcpipchip tcpipchip@hotmail.com; Author author@noreply.github.com Assunto: Re: [jeanmatthieud/nrf51822-low-power-sensor] Issue (#1)

Hi,

If you want to wake up your device every 3 seconds, I think you can do that with a specific timer interrupt. I did not used this kind of functionality yet. To use the attachInterruptLowAccuracy() function, you need to change the platform definition in your platform.ini file as in this repo : https://github.com/jeanmatthieud/nrf51822-low-power-sensor/blob/master/platformio.ini

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jeanmatthieud/nrf51822-low-power-sensor/issues/1?email_source=notifications&email_token=ACXUZTC2UPIQ6GRAEJWMNWLQRBNBVA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECRCMUI#issuecomment-547497553, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEMN3J5RNVHJTAIVWLQRBNBVANCNFSM4I2EGEVQ.

sullivanzheng commented 3 years ago

Hi I know this is a very old post, and I wondered if you got any success getting nRF51822 wake up every 3 seconds. What I know as far it that softdevice uses RTC0 as time source so if you set up RTC0 to implement 3 second timer soft device may crash.

Hi, timers make the ble stack to stop! I dont know why! Thank you so much to help me! I will test that Enviado do meu iPhone Em 29 de out de 2019, às 13:02, Jean-Matthieu DECHRISTÉ notifications@github.com<mailto:notifications@github.com> escreveu: Hi, If you want to wake up your device every 3 seconds, I think you can do that with a specific timer interrupt. I did not used this kind of functionality yet. To use the attachInterruptLowAccuracy() function, you need to change the platform definition in your platform.ini file as in this repo : https://github.com/jeanmatthieud/nrf51822-low-power-sensor/blob/master/platformio.ini — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#1?email_source=notifications&email_token=ACXUZTC2UPIQ6GRAEJWMNWLQRBNBVA5CNFSM4I2EGEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECRCMUI#issuecomment-547497553>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEMN3J5RNVHJTAIVWLQRBNBVANCNFSM4I2EGEVQ.

tcpipchip commented 3 years ago

I had aborted the NRF51 and replace by a NRF52832, using RTOS ZEPHYR Thank you

sullivanzheng commented 3 years ago

How easy is ZEPHYR? (compared to Arduino-nRF5) My feeling is that Arduino-nRF5 is a Arduino core half done, and not smoothly compatible with Soft Device.

I am more or less in the same situation as yours in 2019. Trying very hard to create a Eddystone beacon based on nRF51822 chip + Arduino-nRF5 + BLE_peripheral + Soft device sd_app_evt_wait() to save battery power.

My goal is just to send out temperature and humidity sensor data from a wearable device to a BLE beacon observer.

However, sd_app_evt_wait() is permanently waiting. No code after sd_app_evt_wait() will be executed.

I wondered if ZEPHYR is easier and more up to the task.

Just in case you are interested, here is the Arduino code for this little Eddystone beacon.


// Import libraries (EddystoneBeacon depends on SPI)
#include <SPI.h>
#include <EddystoneBeacon.h>
#define ADVERTISING_INTERVAL 500
#include "nrf_soc.h"
#include "nrf_nvic.h"

//custom boards may override default pin definitions with EddystoneBeacon(PIN_REQ, PIN_RDY, PIN_RST)
EddystoneBeacon eddystoneBeacon = EddystoneBeacon();

void setup() {
  Serial.begin(9600);

  eddystoneBeacon.setAdvertisingInterval(ADVERTISING_INTERVAL);
  eddystoneBeacon.begin(-18, "http://www.example.com"); // power, URI

  Serial.println(F("Eddystone URL Beacon"));

  // enable low power mode
  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
}

int counter = 0;
void loop() {
  // Enter Low power mode
  sd_app_evt_wait();            // Trapped forever, nothing after this will be executed. I only got a beacon that constantly advertise "http://www.example.com" which I initialized in setup() function.
  // Exit Low power mode

  // Clear IRQ flag to be able to go to sleep if nothing happens in between
  sd_nvic_ClearPendingIRQ(SWI2_IRQn);

  char buf[20];
  sprintf(buf,"http://test.com/%d.html",counter);
  counter++;
  eddystoneBeacon.setURI(buf);

  eddystoneBeacon.loop();
}

I had aborted the NRF51 and replace by a NRF52832, using RTOS ZEPHYR Thank you

tcpipchip commented 3 years ago

much more easy https://zephy-platformio.blogspot.com/2020/03/nina-b112-zephyr-platformio.html

macvenez commented 1 year ago

How easy is ZEPHYR? (compared to Arduino-nRF5) My feeling is that Arduino-nRF5 is a Arduino core half done, and not smoothly compatible with Soft Device.

I am more or less in the same situation as yours in 2019. Trying very hard to create a Eddystone beacon based on nRF51822 chip + Arduino-nRF5 + BLE_peripheral + Soft device sd_app_evt_wait() to save battery power.

My goal is just to send out temperature and humidity sensor data from a wearable device to a BLE beacon observer.

However, sd_app_evt_wait() is permanently waiting. No code after sd_app_evt_wait() will be executed.

I wondered if ZEPHYR is easier and more up to the task.

Just in case you are interested, here is the Arduino code for this little Eddystone beacon.


// Import libraries (EddystoneBeacon depends on SPI)
#include <SPI.h>
#include <EddystoneBeacon.h>
#define ADVERTISING_INTERVAL 500
#include "nrf_soc.h"
#include "nrf_nvic.h"

//custom boards may override default pin definitions with EddystoneBeacon(PIN_REQ, PIN_RDY, PIN_RST)
EddystoneBeacon eddystoneBeacon = EddystoneBeacon();

void setup() {
  Serial.begin(9600);

  eddystoneBeacon.setAdvertisingInterval(ADVERTISING_INTERVAL);
  eddystoneBeacon.begin(-18, "http://www.example.com"); // power, URI

  Serial.println(F("Eddystone URL Beacon"));

  // enable low power mode
  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
}

int counter = 0;
void loop() {
  // Enter Low power mode
  sd_app_evt_wait();            // Trapped forever, nothing after this will be executed. I only got a beacon that constantly advertise "http://www.example.com" which I initialized in setup() function.
  // Exit Low power mode

  // Clear IRQ flag to be able to go to sleep if nothing happens in between
  sd_nvic_ClearPendingIRQ(SWI2_IRQn);

  char buf[20];
  sprintf(buf,"http://test.com/%d.html",counter);
  counter++;
  eddystoneBeacon.setURI(buf);

  eddystoneBeacon.loop();
}

I had aborted the NRF51 and replace by a NRF52832, using RTOS ZEPHYR Thank you

Hi, are you still interested in this topic? I managed to obtain something similar to what you were mentioning. I'm planning anyway to create a repo about my experiments on NRF51822 (btw I don't think anyone is still interested in NRF51), if you want I can send you my code that works now with very little power consumption (less than 4µA on average sending temp and humidity data every 30 seconds). Let me know

tcpipchip commented 1 year ago

please, yes, continue

macvenez commented 1 year ago

Hi, I created that said repository I would be very happy if someone would like to contribute, I need to add tons of comments and created a good readme. Code snippets are in the readme file. If you have any questions don't hesitate to ask (you should easily find contact info on my profile).