0

sending data to adafruit App
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: sending data to adafruit App

by naley on Mon Jun 26, 2017 4:01 pm

Thank you so much. That worked beautifully.

Is there any option to ploT Double Y graph on the plotter? ( Having 2 Y axis and one X axis)

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Mon Jun 26, 2017 6:08 pm

no. sorry

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: sending data to adafruit App

by naley on Tue Jun 27, 2017 2:56 pm

Okay! Thanks for all the help!

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by naley on Sat Aug 12, 2017 9:10 pm

Hello,

The bluetooth writes data to the app very slowly when compared to the speed with which I get the data on the serial monitor.
Also, while it is writing data to the app, when I open the serial monitor, the serial monitor shows "Initialising the Bluefruit LE module: Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring? "and the data speed in the app increases and suddenly the data stops and shows ATZ ATZ ATZ. Please correct me where am going wrong.
Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Arduino.h>
#include <Wire.h>

#include <SoftwareSerial.h>
#include"Adafruit_BLE.h"
#include"Adafruit_BluefruitLE_SPI.h"
#include"Adafruit_BluefruitLE_UART.h"
#include"BluefruitConfig.h"

SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                      BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);
void setup()
{
   
 
 
  Wire.begin(); // wake up I2C bus
  delay (500);
  Serial.begin(9600);
  Serial.println ("Sketch has started");
  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(/*VERBOSE_MODE*/) )
  {
    Serial.println(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
    while(1);
  }
  Serial.println( F("OK!") );

    // Set module to COMMAND mode
  Serial.println( F("Switching to COMMAND mode!") );
  ble.setMode(BLUEFRUIT_MODE_COMMAND);

 while (! ble.isConnected()) {
      delay(500);
  }
    // Set module to DATA mode
  Serial.println( F("Switching to DATA mode!") );
  ble.setMode(BLUEFRUIT_MODE_DATA);

}
void loop()
{
 ble.print(time);
      ble.print(',');
      ble.print(getPressure());
      ble.print(',');
      ble.print(solenoidvalue);
      ble.println();

}
 

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Sun Aug 13, 2017 12:51 pm

What sort of Arduino are you using? Probably, opening Serial Monitor causes the sketch to reset. But you're still connected, so you see the reset commands coming out on the app.
What wiring are you using? Can you post a picture of your wiring?

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: sending data to adafruit App

by naley on Mon Aug 14, 2017 5:14 pm

Hello,

Am using arduino Promini (3.3V,8Mhz). I have the arduino connected to the Uart like this:

Arduino ------ > BLE UART

12 ----> MOD
11 ----> CTS
10 ----> TXO
9 ---> RXI
VCC ----> VIN
GND ----> GND
8 ----> RTS

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Wed Aug 16, 2017 4:43 pm

Opening the serial monitor will reset the processor and restart the sketch. But the Bluefruit ought to handle that properly when the ble.begin function is called. Not sure why you're seeing that problem.

As for the data rate issue, I think the problem is the way that you're sending your data to the BLE. You are doing six separate writes to the module.
Code: Select all | TOGGLE FULL SIZE
 ble.print(time);
      ble.print(',');
      ble.print(getPressure());
      ble.print(',');
      ble.print(solenoidvalue);
      ble.println();


What I think may be happening is that it is sending 6 separate BLE packets, which will be slow. Try using a String object or the snprintf function to construct your data string before you pass it to the module.

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: sending data to adafruit App

by naley on Mon Dec 04, 2017 2:48 pm

Try using a String object or the snprintf function to construct your data string before you pass it to the module.


Can you please give me example of how I can do this?
Last edited by naley on Mon Dec 04, 2017 6:42 pm, edited 2 times in total.

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by naley on Mon Dec 04, 2017 3:49 pm

I am trying to write data to sd card and view data on the app using BLE uart.

Code: Select all | TOGGLE FULL SIZE

#include <SPI.h>
#include <SD.h>
#include <Arduino.h>
#include <Wire.h>
#define FILE_BASE_NAME "Data"
#include <SoftwareSerial.h>
#include"Adafruit_BLE.h"
#include"Adafruit_BluefruitLE_SPI.h"
#include"Adafruit_BluefruitLE_UART.h"
#include"BluefruitConfig.h"

SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                              BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);

#include <RTClib.h>
#include <float.h>
#define DS3231_Address 0x68
#define HSCDRRN400MD2A3_I2C 0x28
#define OUTPUT_MIN 1638.4
#define OUTPUT_MAX 14745.6
#define PRESSURE_MIN -400
#define PRESSURE_MAX +400
unsigned long time;
RTC_DS3231 rtc;
int chipSelect = 10;
File file;
int BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
char filename[] = FILE_BASE_NAME "00.csv";


//added button library, variables and button function
#include <Bounce2.h>
Bounce button = Bounce(); //instantiate a Bounce object

const byte LedPin = 5;

const byte ButtonPin = 7;
bool logFlag = true;//default status to enable SD writes in Loop

int solenoidPin = 4;
int count = 0;
float senval[3] = {0, 0, 0};
float temperature;

void buttonCheck()//debounced function to check if button pressed
{
  button.update();
  if (button.fell())
  {
    if (logFlag == true)
    {
      logFlag = false;
      Serial.println();
      Serial.println("Data Logging in Loop Disabled");
      Serial.println("Press Reset to Enable");
      Serial.println();
    }
  }
}

float getPressure()
{
  float pressure;
  float pressure_mmhg;

  //send a request
  Wire.beginTransmission(HSCDRRN400MD2A3_I2C);
  Wire.write(1);
  Wire.endTransmission();
  // now get the data from the sensor
  delay (5);

  Wire.requestFrom(HSCDRRN400MD2A3_I2C, 4);

  byte a     = Wire.read();
  byte b     = Wire.read();
  byte c     = Wire.read();
  byte d     = Wire.read();
  byte status1 = (a & 0xc0) >> 6;
  int bridge_data = ((a & 0x3f) << 8) + b;
  int temperature_data = ((c << 8) + (d & 0xe0)) >> 5;
  pressure = 1.0 * (bridge_data - OUTPUT_MIN) * (PRESSURE_MAX - PRESSURE_MIN) / (OUTPUT_MAX - OUTPUT_MIN) + PRESSURE_MIN;
  pressure_mmhg = 0.750062 * pressure;
  temperature = (temperature_data * 0.0977) - 50;
  return pressure_mmhg;
}

void setup()
{



  Wire.begin(); // wake up I2C bus
  delay (500);
  Serial.begin(9600);
  Serial.println ("Sketch has started");
  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(/*VERBOSE_MODE*/) )
  {
    Serial.println(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
    while (1);
  }
  Serial.println( F("OK!") );

  // Set module to COMMAND mode
  Serial.println( F("Switching to COMMAND mode!") );
  ble.setMode(BLUEFRUIT_MODE_COMMAND);

  while (! ble.isConnected()) {
    delay(500);
  }
  // Set module to DATA mode
  Serial.println( F("Switching to DATA mode!") );
  ble.setMode(BLUEFRUIT_MODE_DATA);



  pinMode(ButtonPin, INPUT_PULLUP);
  button.attach(ButtonPin);
  button.interval(20);//20 ms debounce interval

  pinMode(4, OUTPUT);

  if (rtc.lostPower())
  {
    Serial.println("RTC lost power,set the time");
    //rtc.adjust(DateTime(2016,8,16,14,16,00));
  }
  if (!SD.begin(10))
  {
    Serial.println(F("begin failed"));
    return;
  }

  while (SD.exists(filename)) {
    if (filename[BASE_NAME_SIZE + 1] != '9') {
      filename[BASE_NAME_SIZE + 1]++;
    }
    else if (filename[BASE_NAME_SIZE] != '9') {
      filename[BASE_NAME_SIZE + 1] = '0';
      filename[BASE_NAME_SIZE]++;
    }
    else {
      Serial.println(F("Can't create file name"));
      return;
    }
  }
  File file = SD.open(filename, FILE_WRITE);
  digitalWrite(LedPin, HIGH);//indicate file being written
  DateTime now = rtc.now();
  file.print(now.year(), DEC);
  file.print('/');
  file.print(now.month(), DEC);
  file.print('/');
  file.print(now.day(), DEC);
  file.print(',');
  file.print(now.hour(), DEC);
  file.print(':');
  file.print(now.minute(), DEC);
  file.print(':');
  file.print(now.second(), DEC);
  file.println();
  file.print("Time( ms)");
  file.print(',');
  file.print("Presuure (mmhg)");
  file.println();
  file.close();
  digitalWrite(LedPin, LOW);//file write finished
  delay(10);
  //DateTime now = rtc.now();
  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(',');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

 
}
void loop()
{

  float Pdelta;
  static bool foundMax = false;
  static bool foundMin = false;
  static bool solstate = false;
  static float max = 0;
  static float min = 0;
  static int peakcounter = 0;
  const long interval = 500;
  static unsigned long int startTime = millis();
  time = millis();
  if (count == 0)
  {
    senval[1] = getPressure();//pressure_mmhg;
    //delay(20);//??
    senval[1] = (senval[1] + getPressure()) / 2;
    ++count;
  }

  else
  {
    senval[2] = getPressure();//pressure_mmhg;
    //delay(20);//?
    senval[2] = (senval[2] + getPressure()) / 2;
    //++count;//never used but will overflow

    if (foundMax == false && (senval[1] > senval[0]) && (senval[1] > senval[2]))
    {
      foundMax = true;
      max = senval[1];
      Serial.print("max  ");
      Serial.println(max);
    }
    else if (foundMin == false && (senval[1] < senval[0]) && (senval[1] < senval[2]))
    {
      foundMin = true;
      min = senval[1];
      Serial.print("min  ");
      Serial.println(min);
    }

    if ( foundMax == true && foundMin == true)
    {
      foundMax = false;//enable finding of next max
      foundMin = false;

      Pdelta = max - min;
      Serial.print("Pdelta  ");
      Serial.println(Pdelta);

      if (solstate == false && Pdelta >= 20)
      {
        ++peakcounter ;
        Serial.print("peakcounter");
        Serial.print(peakcounter);
      }
      if (peakcounter == 5)
      {
        digitalWrite(4, HIGH);
        startTime = millis();
        solstate = true;
        peakcounter = 0;
      }

    }
    //keep solenoid triggered for period of time 500ms
    if (solstate == true && millis() - startTime >= interval)
    {
      digitalWrite(4, LOW);
      solstate = false;
      peakcounter = 0;
    }

    senval[0] = senval[1];
    senval[1] = senval[2];
    senval[2] = 0;

  }

  int solenoidvalue = digitalRead(4);

  buttonCheck();//update logFlag

  if (logFlag)//logFlag determines write enable
  {
    File file = SD.open(filename, FILE_WRITE);
    if (file)
    {
      digitalWrite(LedPin, HIGH);//indicate file being written
      file.print(time);
      file.print(',');
      file.print(getPressure());
      file.println();
      file.close();
      digitalWrite(LedPin, LOW);//file write finished
    }
    ble.print(time);
    ble.print(',');
    ble.println(getPressure());
  }
}



I am able to write data to sd card but the data to the app is being written very slowly!
Last edited by naley on Mon Dec 04, 2017 8:25 pm, edited 2 times in total.

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by naley on Mon Dec 04, 2017 7:20 pm

I have the microsd breakout board wired like this:

SD card breakout board-> Promini

3V ->3V
GND-> GND
CLK -> pin 13
DO -> pin 12
DI -> pin 11
CS -> pin 10

I have the BLE UART wired like this:

MOD to Pin 5 Arduino
CTS to Pin 8
TXO to Pin 7
RXI to Pin 6
VIN to 3V
RTS to Pin 9
GND to GND

What do I do to increase the data transfer rate to the bluetooth module. The data speed is very very slow!

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Wed Dec 06, 2017 5:44 pm

You are opening and closing your log file on every single iteration of the loop. This will make your sketch very slow.

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: sending data to adafruit App

by naley on Fri Dec 08, 2017 11:29 am

But I am able to send the pressure values without any problem and without losing any data.
It is only when I try to send the time along with the pressure ,the data is being lost.
Is it because of the "const long int" used to declare time ?
Is it possible to convert time to just int to send it to bluetooth ?

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Fri Dec 08, 2017 2:33 pm

Try constructing a data buffer and just sending that instead of doing three calls to ble.print:
Code: Select all | TOGGLE FULL SIZE
  if (logFlag)//logFlag determines write enable
  {
    File file = SD.open(filename, FILE_WRITE);
    if (file)
    {
      digitalWrite(LedPin, HIGH);//indicate file being written
      file.print(time);
      file.print(',');
      file.print(getPressure());
      file.println();
      file.close();
      digitalWrite(LedPin, LOW);//file write finished
    }
//    ble.print(time);
//    ble.print(',');
//    ble.println(getPressure());
    sendDataToBLE(time, getPressure());
  }


Add this function to your sketch
Code: Select all | TOGGLE FULL SIZE
void sendDataToBLE(uint32_t time, float pressure)
{
  char dataBuf[32];
  char pressBuf[16];
 
  dtostrf(pressure, 7, 4, pressBuf);
  snprintf(dataBuf, 31, "%ul,%s", time, pressBuf);
  ble.println(dataBuf);
}

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: sending data to adafruit App

by naley on Fri Dec 08, 2017 4:31 pm

Hello,

I modified the code as per your instructions. Only the time is being sent. The pressure values do not show up on the bluetooth.


Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <SD.h>
#include <Arduino.h>
#include <Wire.h>
#define FILE_BASE_NAME "Data"
#include <SoftwareSerial.h>
#include"Adafruit_BLE.h"
#include"Adafruit_BluefruitLE_SPI.h"
#include"Adafruit_BluefruitLE_UART.h"
#include"BluefruitConfig.h"

SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                              BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);

#include <RTClib.h>
#include <float.h>
#define DS3231_Address 0x68
#define HSCDRRN400MD2A3_I2C 0x28
#define OUTPUT_MIN 1638.4
#define OUTPUT_MAX 14745.6
#define PRESSURE_MIN -400
#define PRESSURE_MAX +400
unsigned long time;
RTC_DS3231 rtc;
int chipSelect = 10;
File file;
int BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
char filename[] = FILE_BASE_NAME "00.csv";


//added button library, variables and button function
#include <Bounce2.h>
Bounce button = Bounce(); //instantiate a Bounce object

const byte LedPin = 5;

const byte ButtonPin = 7;
bool logFlag = true;//default status to enable SD writes in Loop

int solenoidPin = 4;
int count = 0;
float senval[3] = {0, 0, 0};
float temperature;

void buttonCheck()//debounced function to check if button pressed
{
  button.update();
  if (button.fell())
  {
    if (logFlag == true)
    {
      logFlag = false;
      Serial.println();
      Serial.println("Data Logging in Loop Disabled");
      Serial.println("Press Reset to Enable");
      Serial.println();
    }
  }
}
void sendDataToBLE(uint32_t time, float pressure)
{
  char dataBuf[32];
  char pressBuf[16];
 
  dtostrf(pressure, 7, 4, pressBuf);
  snprintf(dataBuf, 31, "%ul,%s", time, pressBuf);
  ble.println(dataBuf);
}
float getPressure()
{
  float pressure;
  float pressure_mmhg;

  //send a request
  Wire.beginTransmission(HSCDRRN400MD2A3_I2C);
  Wire.write(1);
  Wire.endTransmission();
  // now get the data from the sensor
  delay (5);

  Wire.requestFrom(HSCDRRN400MD2A3_I2C, 4);

  byte a     = Wire.read();
  byte b     = Wire.read();
  byte c     = Wire.read();
  byte d     = Wire.read();
  byte status1 = (a & 0xc0) >> 6;
  int bridge_data = ((a & 0x3f) << 8) + b;
  int temperature_data = ((c << 8) + (d & 0xe0)) >> 5;
  pressure = 1.0 * (bridge_data - OUTPUT_MIN) * (PRESSURE_MAX - PRESSURE_MIN) / (OUTPUT_MAX - OUTPUT_MIN) + PRESSURE_MIN;
  pressure_mmhg = 0.750062 * pressure;
  temperature = (temperature_data * 0.0977) - 50;
  return pressure_mmhg;
}



void setup()
{



  Wire.begin(); // wake up I2C bus
  delay (500);
  Serial.begin(9600);
  Serial.println ("Sketch has started");
  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(/*VERBOSE_MODE*/) )
  {
    Serial.println(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
    while (1);
  }
  Serial.println( F("OK!") );

  // Set module to COMMAND mode
  Serial.println( F("Switching to COMMAND mode!") );
  ble.setMode(BLUEFRUIT_MODE_COMMAND);

  while (! ble.isConnected()) {
    delay(500);
  }
  // Set module to DATA mode
  Serial.println( F("Switching to DATA mode!") );
  ble.setMode(BLUEFRUIT_MODE_DATA);



  pinMode(ButtonPin, INPUT_PULLUP);
  button.attach(ButtonPin);
  button.interval(20);//20 ms debounce interval

  pinMode(4, OUTPUT);

  if (rtc.lostPower())
  {
    Serial.println("RTC lost power,set the time");
    //rtc.adjust(DateTime(2016,8,16,14,16,00));
  }
  if (!SD.begin(10))
  {
    Serial.println(F("begin failed"));
    return;
  }

  while (SD.exists(filename)) {
    if (filename[BASE_NAME_SIZE + 1] != '9') {
      filename[BASE_NAME_SIZE + 1]++;
    }
    else if (filename[BASE_NAME_SIZE] != '9') {
      filename[BASE_NAME_SIZE + 1] = '0';
      filename[BASE_NAME_SIZE]++;
    }
    else {
      Serial.println(F("Can't create file name"));
      return;
    }
  }
  File file = SD.open(filename, FILE_WRITE);
  digitalWrite(LedPin, HIGH);//indicate file being written
  DateTime now = rtc.now();
  file.print(now.year(), DEC);
  file.print('/');
  file.print(now.month(), DEC);
  file.print('/');
  file.print(now.day(), DEC);
  file.print(',');
  file.print(now.hour(), DEC);
  file.print(':');
  file.print(now.minute(), DEC);
  file.print(':');
  file.print(now.second(), DEC);
  file.println();
  file.print("Time( ms)");
  file.print(',');
  file.print("Presuure (mmhg)");
  file.println();
  file.close();
  digitalWrite(LedPin, LOW);//file write finished
  delay(10);
  //DateTime now = rtc.now();
  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(',');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

 
}
void loop()
{

  float Pdelta;
  static bool foundMax = false;
  static bool foundMin = false;
  static bool solstate = false;
  static float max = 0;
  static float min = 0;
  static int peakcounter = 0;
  const long interval = 500;
  static unsigned long int startTime = millis();
  time = millis();
  if (count == 0)
  {
    senval[1] = getPressure();//pressure_mmhg;
    //delay(20);//??
    senval[1] = (senval[1] + getPressure()) / 2;
    ++count;
  }

  else
  {
    senval[2] = getPressure();//pressure_mmhg;
    //delay(20);//?
    senval[2] = (senval[2] + getPressure()) / 2;
    //++count;//never used but will overflow

    if (foundMax == false && (senval[1] > senval[0]) && (senval[1] > senval[2]))
    {
      foundMax = true;
      max = senval[1];
      Serial.print("max  ");
      Serial.println(max);
    }
    else if (foundMin == false && (senval[1] < senval[0]) && (senval[1] < senval[2]))
    {
      foundMin = true;
      min = senval[1];
      Serial.print("min  ");
      Serial.println(min);
    }

    if ( foundMax == true && foundMin == true)
    {
      foundMax = false;//enable finding of next max
      foundMin = false;

      Pdelta = max - min;
      Serial.print("Pdelta  ");
      Serial.println(Pdelta);

      if (solstate == false && Pdelta >= 20)
      {
        ++peakcounter ;
        Serial.print("peakcounter");
        Serial.print(peakcounter);
      }
      if (peakcounter == 5)
      {
        digitalWrite(4, HIGH);
        startTime = millis();
        solstate = true;
        peakcounter = 0;
      }

    }
    //keep solenoid triggered for period of time 500ms
    if (solstate == true && millis() - startTime >= interval)
    {
      digitalWrite(4, LOW);
      solstate = false;
      peakcounter = 0;
    }

    senval[0] = senval[1];
    senval[1] = senval[2];
    senval[2] = 0;

  }

  int solenoidvalue = digitalRead(4);

  buttonCheck();//update logFlag

  if (logFlag)//logFlag determines write enable
  {
    File file = SD.open(filename, FILE_WRITE);
    if (file)
    {
      digitalWrite(LedPin, HIGH);//indicate file being written
      file.print(time);
      file.print(',');
      file.print(getPressure());
      file.println();
      file.close();
      digitalWrite(LedPin, LOW);//file write finished
    }
    sendDataToBLE(time, getPressure());
  }
}


This is what the sd card prints:
Capture.PNG
Capture.PNG (10.13 KiB) Viewed 52 times


The sd card prints every 90-92 ms and the bluetooth prints every 960 ms.
Attachments
IMG_0762.jpg
IMG_0762.jpg (224.31 KiB) Viewed 52 times

naley
 
Posts: 91
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

by adafruit_support_rick on Fri Dec 08, 2017 6:42 pm

Oops! Sorry. Swap the 'l' and the 'u':
Code: Select all | TOGGLE FULL SIZE
  snprintf(dataBuf, 31, "%lu,%s", time, pressBuf);

adafruit_support_rick
 
Posts: 34871
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Please be positive and constructive with your questions and comments.