Nrf52832 - sandeepmistry core & nordic SDK libraries sleeping

Hi,
I’m going to build to a project based on nrf52832, developed with arduino IDE (I am using sandeepmistry core). So: I’m going to configure accelerometer interrupt pin (motion detection) and one nrf’s GPIO as wake up pin using

nrf_gpio_cfg_sense_input(Pin_number, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);

and nrf52832 will be put into system off sleep mode.
If motion is detected nrf wakes up, takes reading, sends it over bluetooth and goes to sleep with RTC alarm set. If no motion is detected when it wakes up again, it goes to sleep again.
As I read there: nRF5 action! | MySensors Forum I have to use Library files extracted from SDK. I just don’t understand how to includes these files and what does the includes .h and .c means? here is the code that I based on, in the link and the includes copied there:

// Include app_gpiote and related files from NRF5 SDK 12
extern "C" {
#include "app_gpiote.h"
#include "nrf_gpio.h"
#include "app_error.h"
}

// Files to include from SDK:
// app_error_weak.h + .c
// app_gpiote.h + .c
// app_util.h
// nordic_common.h
// nrf_error.h
// nrf_gpio.h
// sdk_errors.h
// app_error.h + .c
//   for this last one (c file) I decided to stop the endless list of includes so I commented the following includes:
//   #include "sdk_errors.h", #include "nrf_log.h", #include "nrf_log_ctrl.h"  lines

#include <nrf.h>

And here are the files that he included

My question is: 1. How the includes of the code should look like, so that I could use this sense input configuration function. 2. I get an error while compiling like:
#error “Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)”
3. Am I using the ble pheripheral library right way? I based on this example:

Here’s my code:

#include <BLEPeripheral.h>
#include <Arduino.h>
#include <ADXL362.h>
#include <SPI.h>
#include <Rtc_Pcf8563.h>
#include <Wire.h>
#include <SPI.h>
// Include app_gpiote and related files from NRF5 SDK 12
extern "C" {
#include "app_gpiote.h"
#include "nrf_gpio.h"
#include "app_error.h"
}

// Files to include from SDK:
#include "app_error_weak.h"
#include "app_gpiote.h"
#include "app_util.h"
#include "nordic_common.h"
#include "nrf_error.h"
#include "nrf_gpio.h"
#include "sdk_errors.h"
#include "app_error.h" 
#include "sdk_errors.h" #include "nrf_log.h" #include "nrf_log_ctrl.h"

Rtc_Pcf8563 rtc;
ADXL362 xl;


int16_t interruptStatus = 0;
BLEPeripheral                    blePeripheral                            = BLEPeripheral();



BLEService pressFService = BLEService("CCC0");     //-----------------------



BLEDescriptor pressFDescriptor = BLEDescriptor("2901", "Bar");
const int accPin = 2;
int reading = 0;
int sleepmode = 1;
int spinning = 0;
static app_gpiote_user_id_t m_gpiote_user_id;
void setup() {

  
  Serial.begin(115200);

  
  xl.begin();


  blePeripheral.setLocalName("Pressure_in_Bar_Front");    //----------------------



  blePeripheral.setAdvertisedServiceUuid(pressFService.uuid()); //---------------------

  blePeripheral.addAttribute(pressFService);

  blePeripheral.addAttribute(pressFDescriptor);

  blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);

  blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

  blePeripheral.begin();
  
  nrf_gpio_cfg_sense_input(4, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);                //Pin names are only for example
  nrf_gpio_cfg_sense_input(5, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);               //tututuut

  Serial.println(F("Pressure-front"));                                                       //------------------------------------------------

}

  xl.setupDCActivityInterrupt(300, 10);
  xl.setupDCInactivityInterrupt(80, 500);                           //I will have to set adxl362 by writing to its registers
 
void loop() { 
  blePeripheral.poll();               
  spinning = digitalRead(accPin);               //Detect if it was woken up by accelerometer or RTC (accelerometer has setable turn off delay time)
  if (spinning == HIGH) {                       //I know I would be a better idea to use some kind of mask for those Pins
    reading = analogRead(A1);                                                    // I will need to do a bit of math here...
    float(reading);
    Serial.print(F("Pressure-Front: ")); Serial.print(reading); Serial.println(F("Bar")); //--------------------------------------
    if (sleepmode < 9) {
      sleepmode = sleepmode + 1;
                                                                                // here I would need to retain Ram to retain sleepmode                                
      setRTC();
    }
  }
  sd_power_system_off()  
}






void blePeripheralConnectHandler(BLECentral& central) {
  Serial.print(F("Connected event, central: "));
  Serial.println(central.address());
}



void blePeripheralDisconnectHandler(BLECentral& central) {
  Serial.print(F("Disconnected event, central: "));
  Serial.println(central.address());
}


void setRTC() {
   rtc.initClock();
   rtc.setDate(1, 1, 1, 0, 10);
         
   if (sleepmode < 4) {               //setting RTC to 10s sleep
          /* hr, min, sec */
     rtc.setTime(0, 0, 50);                   
      //        min, hr, day, weekday
     rtc.setAlarm(1, 99, 99, 99);             // 99 = don't matter
   } else if (sleepmode == 5) {               //setting RTC to 30s sleep
              /* hr, min, sec */
     rtc.setTime(0, 0, 30); 
      //        min, hr, day, weekday
     rtc.setAlarm(1, 99, 99, 99);
   } else if (sleepmode == 6) {               //setting RTC to 60s sleep
              /* hr, min, sec */
     rtc.setTime(0, 0, 0); 
      //        min, hr, day, weekday
     rtc.setAlarm(1, 99, 99, 99);
   } else if (sleepmode == 7) {               //setting RTC to 120s sleep
              /* hr, min, sec */
     rtc.setTime(0, 0, 0); 
      //        min, hr, day, weekday
     rtc.setAlarm(2, 99, 99, 99);
   } else if (sleepmode == 8) {               //setting RTC to 360s sleep
              /* hr, min, sec */
     rtc.setTime(0, 0, 0); 
      //        min, hr, day, weekday
     rtc.setAlarm(6, 99, 99, 99);
   } else if (sleepmode == 9) {               //setting RTC to 600s sleep
              /* hr, min, sec */
     rtc.setTime(0, 0, 0); 
      //        min, hr, day, weekday
     rtc.setAlarm(10, 99, 99, 99);
   }
}

Hi Alert2

I have been also struggling to work with SDK libraries in Arduino environment, for quite a long time, but end up with failure.

Anyway, getting back to your question, I would like you to take a look at this library here.

The headers need to be included while compiling the examples.
If you need help, or have an update of the work, please feel free to contact. :slight_smile: :wink: