# OpenLog Qwiic - How to Close Communication to Allow Interrupts

**URL:** <https://community.sparkfun.com/t/openlog-qwiic-how-to-close-communication-to-allow-interrupts/39855>\
**Category:** Qwiic System\
**Tags:** qwiic\
**Created:** [June 17, 2020, 7:21pm UTC](https://community.sparkfun.com/t/openlog-qwiic-how-to-close-communication-to-allow-interrupts/39855 "2020-06-17T19:21:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmayerho\_sfu.ca](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@pmayerho\_sfu.ca](https://community.sparkfun.com/u/pmayerho_sfu.ca)\
**Post date:** [June 17, 2020, 7:21pm UTC](https://community.sparkfun.com/t/openlog-qwiic-how-to-close-communication-to-allow-interrupts/39855/1 "2020-06-17T19:21:52Z")

</div>

Hi all,

I am using the FlexiTimer2.h library to collect analog data and would like to save the data on a micro SD that is connected to the RedBoard via a Qwiic connector. When I used interrupts in my past, I usually turned off the interrupts, started communication with the sd card, wrote the data, closed communication with the sd card, and turned on interrupts again.

Now I have the problem, that I cannot find a call in the OpenLog library that allows me to close the communication.

[https://github.com/sparkfun/SparkFun\_Qw … no\_Library](https://github.com/sparkfun/SparkFun_Qwiic_OpenLog_Arduino_Library)

It seems to just have a begin() function.

Here is the code that I am using, maybe someone has some idea, how else I could write data to the micro SD with this code?

```auto
#include <compat/deprecated.h>
#include <FlexiTimer2.h>
#define SAMPFREQ 20 // ADC sampling rate 256
#define TIMER2VAL (1000/(SAMPFREQ)) // Set 256Hz sampling frequency                    
volatile unsigned char CurrentCh=0; //Current channel being sampled.
volatile unsigned int ADC_Value = 0; //ADC current value

//*** added these lines for logging
#include <Wire.h>
#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
OpenLog myLog; //Create instance
char filename[11] = "ECGdata.txt";
//***

void setup() {

noInterrupts(); // Disable all interrupts before initialization

FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
FlexiTimer2::start();

// Serial Port
Serial.begin(57600);
//*** added these lines for logging

  //Wire.begin();
  //myLog.begin(); //Open connection to OpenLog (no pun intended)
  //myLog.syncFile();
  //myLog.append(filename); // change to your own file nameexample
  
 // ***
interrupts(); // Enable all interrupts after initialization has been completed
}

void Timer2_Overflow_ISR()
{
        ADC_Value = analogRead(CurrentCh);
        //Serial.print("D!"); //this is packet header for my application
        Serial.print(millis());
        Serial.print(", ");
        Serial.println(ADC_Value);
}

void loop() {
__asm__  __volatile__ ("sleep");
}

```

I would like to save the data that right now is sent to the serial monitor.

Thanks for the help.

Cheers,

Patrick
