๐ŸŽ„โ›„โ„๏ธ๐ŸŽ It's beginning to look a lot like ADABOX-mas! The next ADABOX from Adafruit ships soon! Get yours now, or give as a gift! ๐ŸŽ„โ›„โ„๏ธ๐ŸŽ
0

Bluefruit app crashes after streaming data
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Bluefruit app crashes after streaming data

by mrsmith13 on Thu Jun 13, 2019 2:48 pm

Hello,

I am sending data from electrodes via my Feather M0 board to the Bluefruit app.

If i send a 500 Hz sampling rate, the app crashes immediately when I try to use the plotter function.

If I send a 50 Hz sampling rate, the app is able to plot the incoming data....for about 10-15s before it crashes.

Does the app only work for so long until its memory is filled with data? Is there a way to prevent crashing? (for the record I am able to use an IMU 6050 and plot 3 accelerations for an indefinite amount of time; it is only the electrode data that crashes the app).

Thank you!

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by siddacious on Mon Jun 17, 2019 11:32 am

Sorry for the delay in getting back to you. I will get this to someone who can help.

We appreciate your patience!

siddacious
 
Posts: 161
Joined: Fri Apr 21, 2017 3:09 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Mon Jun 17, 2019 2:46 pm

Hello,

I have noticed the crashing has gotten worse so that even when I try to plot one acceleration from a 6DOF IMU at a delay rate of 1000ms, the Bluefruit app crashes immediately. A week ago I was able to plot 3 accelerations at a rate of 500 Hz indefinitely (for at least 10 minutes or so), but something has happened in the past week that now the plotter feature crashes the app immediately.

My Arduino code has not changed in 2 weeks, I have deleted and redownloaded the app, used the app on my friends phone, I have tried firmware Versions 0.8.1, 0.8.0, and 0.7.7, and I have replaced my Adafruit Feather M0 with a new Adafruit Feather M0.

I am out of ideas for fixing the plotter. Any suggestions?

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Mon Jun 17, 2019 3:24 pm

Update:

Both iphone 7 and iPhone 8 crash immediately whenever the plotter feature is used. A Samsung phone works when the plotter feature is used..

Can somebody help with getting it to work on iPhone?

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by collinmel on Mon Jun 17, 2019 8:22 pm

mrsmith13 wrote:Update:

Both iphone 7 and iPhone 8 crash immediately whenever the plotter feature is used. A Samsung phone works when the plotter feature is used..

Can somebody help with getting it to work on iPhone?


Sorry to hear about the crashes - it does sounds like a memory related issue. I just did some testing with the latest version of the app (v3.4.0) on iOS 12.3.1 and haven't been able to recreate the issue yet.

What type of data are you sending when the app crashes - int/float/etc?

Can you try limiting the sampling rate to 10Hz?

collinmel
 
Posts: 53
Joined: Thu Aug 07, 2008 12:16 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Tue Jun 18, 2019 1:56 pm

Hi Collinmel,

I am using Version 3.4.0 with iOS 12.3.1 as well. The type of data I send (int, float, short...) all cause the app to crash when the plotter feature is used.

Even the Bluefruit_LE_Connect_Plotter Arduino code for the Feather Bluefruit will crash the app.

By limiting sampling rate to 10Hz does that mean I change the delay after Serial.println() in the void loop? If I make the delay 50 ms the plotter crashes the app within 1-2 minutes.


Here is the Bluefruit_LE_Connect_Plotter code I am using:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_ATParser.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BLEBattery.h>
#include <Adafruit_BLEEddystone.h>
#include <Adafruit_BLEGatt.h>
#include <Adafruit_BLEMIDI.h>
#include <Adafruit_BluefruitLE_SPI.h>
#include <Adafruit_BluefruitLE_UART.h>

/*********************************************************************
  Bluefruit LE Connect Plotter
  for Feather Bluefruit -> Bluefruit LE Connect app
 
  outputs dummy values for demo use with BLuefruit LE Connect app
  change SEND_SECOND_PLOT define to 1 to output second plot using sine wave table

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  MIT license, check LICENSE for more information
  All text above, and the splash screen below must be included in
  any redistribution
*********************************************************************/


#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined (_VARIANT_ARDUINO_ZERO_)
#include <SoftwareSerial.h>
#endif

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"
#include "sine.h"
int adcin    = A5;
int adcvalue = 0;
float mv_per_lsb = 3000.0F/4096.0F; // 12-bit ADC with 3.0V input range

/*=========================================================================
    APPLICATION SETTINGS

  โ€‚ โ€‚ FACTORYRESET_ENABLEโ€‚   โ€‚  Perform a factory reset when running this sketch
  โ€‚ โ€‚
  โ€‚ โ€‚                           Enabling this will put your Bluefruit LE module
                              in a 'known good' state and clear any config
                              data set in previous sketches or projects, so
  โ€‚ โ€‚                           running this at least once is a good idea.
  โ€‚ โ€‚
  โ€‚ โ€‚                           When deploying your project, however, you will
                              want to disable factory reset by setting this
                              value to 0.โ€‚ If you are making changes to your
  โ€‚ โ€‚                           Bluefruit LE device via AT commands, and those
                              changes aren't persisting across resets, this
                              is the reason why.โ€‚ Factory reset will erase
                              the non-volatile memory where config data is
                              stored, setting it back to factory default
                              values.
  โ€‚ โ€‚ โ€‚ โ€‚
  โ€‚ โ€‚                           Some sketches that require you to bond to a
                              central device (HID mouse, keyboard, etc.)
                              won't work at all with this feature enabled
                              since the factory reset will clear all of the
                              bonding data stored on the chip, meaning the
                              central device won't be able to reconnect.
    MINIMUM_FIRMWARE_VERSION  Minimum firmware version to have some new features
    MODE_LED_BEHAVIOUR        LED activity, valid options are
                              "DISABLE" or "MODE" or "BLEUART" or
                              "HWUART"  or "SPI"  or "MANUAL"
    -----------------------------------------------------------------------*/
#define FACTORYRESET_ENABLE         1
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"
#define MODE_LED_BEHAVIOUR          "MODE"
#define SEND_SECOND_PLOT            1
/*=========================================================================*/

// Create the bluefruit object, either software serial...uncomment these lines
/*
  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);
*/

/* ...or hardware serial, which does not need the RTS/CTS pins. Uncomment this line */
// Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN);

/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

/* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */
//Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO,
//                             BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS,
//                             BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


// A small helper
void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}

/**************************************************************************/
/*!
    @brief  Sets up the HW an the BLE module (this function is called
            automatically on startup)
*/
/**************************************************************************/
void setup(void)
{
  //  while (!Serial);  // required for Flora & Micro
  delay(2);

  Serial.begin(115200);
  // Set the resolution to 12-bit (0..4095)
  analogReadResolution(12); // Can be 8, 10, 12 or 14
 
 
  Serial.println(F("Adafruit Bluefruit Command <-> Data Mode Example"));
  Serial.println(F("------------------------------------------------"));

  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

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

  if ( FACTORYRESET_ENABLE )
  {
    /* Perform a factory reset to make sure everything is in a known state */
    Serial.println(F("Performing a factory reset: "));
    if ( ! ble.factoryReset() ) {
      error(F("Couldn't factory reset"));
    }
  }

  /* Disable command echo from Bluefruit */
  ble.echo(false);

  Serial.println("Requesting Bluefruit info:");
  /* Print Bluefruit information */
  ble.info();

  Serial.println(F("Please use Adafruit Bluefruit LE app to connect in UART mode"));
  Serial.println(F("Then Enter characters to send to Bluefruit"));
  Serial.println();

  ble.verbose(false);  // debug info is a little annoying after this point!

  /* Wait for connection */
  while (! ble.isConnected()) {
    delay(2);
  }

  Serial.println(F("******************************"));

  // LED Activity command is only supported from 0.6.6
  if ( ble.isVersionAtLeast(MINIMUM_FIRMWARE_VERSION) )
  {
    // Change Mode LED Activity
    Serial.println(F("Change LED activity to " MODE_LED_BEHAVIOUR));
    ble.sendCommandCheckOK("AT+HWModeLED=" MODE_LED_BEHAVIOUR);
  }

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

  Serial.println(F("******************************"));
}


void loop(void) {

  delay(2);                  //wait 1 second
  // Get a fresh ADC value
  adcvalue = analogRead(adcin);



 
  uint8_t val = adcvalue; //find random value
  ble.print(val);               //send value to bluefruit uart
  Serial.print(val);
 
  if (SEND_SECOND_PLOT) {               //change SEND_SECOND_PLOT to 1 for add'l sine plot
    if (sineIndex > 255) sineIndex = 0; //stay within bounds of sine table
    ble.print(",");                     //print delimiter for second plot
    ble.print(sine_wave[sineIndex]);    //print value from sine table
    Serial.print(",");
    Serial.print(sine_wave[sineIndex]);
    sineIndex++;                        //increment index
  }

  ble.println();  //print newline so app knows to plot the values
  Serial.println();
  delay(50); //Try 2 for a freq of 500Hz

}

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Tue Jun 18, 2019 2:17 pm

If I make the delay 30ms (for a 33Hz sampling rate), the plotter crashes within 10s. It does appear to be a memory issue. Does the app save all the data it receives?
My plan is to have the plotter plot indefinitely, and I only care about the immediate data that is streamed at that point in time, and not the old data. Is there a way to delete old data as newer data is streamed in?

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by collinmel on Tue Jun 18, 2019 4:52 pm

mrsmith13 wrote:If I make the delay 30ms (for a 33Hz sampling rate), the plotter crashes within 10s. It does appear to be a memory issue. Does the app save all the data it receives?
My plan is to have the plotter plot indefinitely, and I only care about the immediate data that is streamed at that point in time, and not the old data. Is there a way to delete old data as newer data is streamed in?


Currently, there's no way to manually delete the old data. For now I suggest using a delay of 100ms or greater. We're working on an update to the plotter right now that will address this issue.

collinmel
 
Posts: 53
Joined: Thu Aug 07, 2008 12:16 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Tue Jun 18, 2019 5:35 pm

Awesome thank you for your help!

Do you have an estimated time for this new update to become available?

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by collinmel on Wed Jun 19, 2019 3:51 pm

mrsmith13 wrote:Do you have an estimated time for this new update to become available?


Rough estimate = 1-2 weeks, depending on outside factors. We'll try to get it out for you asap :)

collinmel
 
Posts: 53
Joined: Thu Aug 07, 2008 12:16 pm

Re: Bluefruit app crashes after streaming data

by collinmel on Thu Jun 27, 2019 12:40 pm

Bluefruit LE Connect v3.4.1 is now live on the App Store. This version includes stability fixes for the Plotter module. Please update the app and let us know if this remedies your issue.
Last edited by collinmel on Thu Jun 27, 2019 1:01 pm, edited 1 time in total.

collinmel
 
Posts: 53
Joined: Thu Aug 07, 2008 12:16 pm

Re: Bluefruit app crashes after streaming data

by jps2000 on Thu Jun 27, 2019 12:53 pm

you may consider this:
viewtopic.php?f=57&t=148625
for your code

jps2000
 
Posts: 468
Joined: Fri Jun 02, 2017 4:12 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Thu Jun 27, 2019 5:14 pm

Hi Collinmel,

On the iPhone the app does not crash anymore, but unfortunately the plotter feature is very laggy; the app appears to freeze, and a frame will move every second to couple of seconds or so. This will not work for my project, sadly.

I am looking for alternate ways to wirelessly display data. I have tried unsuccessfully with MATLAB (when installing MATLAB support package for Arduino Hardware, the only boards compatible with connecting are a preselected list of Arduino boards (Uno, Nano, Leonardo etc).

I have also looked for ways to connect to Arduino IDE wirelessly, but it looks like I will need extra components (like an Adafruit Bluetooth/Wifi combo USB, or Bluefruit EZ link).

Do you have any recommendations?

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Re: Bluefruit app crashes after streaming data

by collinmel on Thu Jun 27, 2019 6:16 pm

Sorry to hear about the freezing - this doesn't occur when I test the code you posted. A couple questions come to mind:
What model iPhone are you using? What version of iOS?
Do you have any other processor intensive apps running in the background?
Is the iPhone connected to any other Bluetooth devices besides the Feather M0?
How fast do you need the Plotter to update the display?

collinmel
 
Posts: 53
Joined: Thu Aug 07, 2008 12:16 pm

Re: Bluefruit app crashes after streaming data

by mrsmith13 on Mon Jul 08, 2019 7:43 pm

Hi Collin,

Sorry for the late reply, and thank you for all your help. I am using an iPhone 7+ with 15GB of free storage, and using iOS 12.3.1. I removed Bluetooth connections and other processor intensive apps running in the background. I would ideally like 500Hz plotter display speed. It hasn't worked, unfortunately.

I now have purchased the Bluefruit LE Friend v3.0.

This is a silly question, but how do I get my desktop Arduino to recognize the Bluefruit LE Friend port? I would like to use my code so that IMU data is sent from the Feather M0 Bluefruit, to the Friend, which is then displayed by Serial Plotter on Arduino.

Thank you again.

mrsmith13
 
Posts: 19
Joined: Mon Jun 03, 2019 2:03 pm

Please be positive and constructive with your questions and comments.