0

Adafruti Bluefruit code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruti Bluefruit code

by anini119 on Mon Apr 08, 2019 12:04 am

Code: Select all | TOGGLE FULL SIZE
/*********************************************************************
  Adapted from Bluefruit LE Connect Plotter
  for Feather Bluefruit -> Bluefruit LE Connect app
  (MIT License)
*********************************************************************/
#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"

#define FACTORYRESET_ENABLE         1
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"
#define MODE_LED_BEHAVIOUR          "MODE"
/*=========================================================================*/

// Data to plot
#define NUMBER 960
int data[NUMBER] = {792, 785, 779, 783, 780, 774, 774, 768, 760, 753, 751, 746, 744, 743, 739, 732, 737, 730, 723, 721, 721, 713, 713, 705, 699, 696, 699, 699, 686, 690, 678, 684, 673, 670, 667, 666, 664, 649, 658, 644, 650, 637, 633, 633, 631, 623, 619, 621, 616, 615, 608, 604, 602, 601, 600, 597, 570, 580, 578, 579, 577, 567, 566, 560, 560, 555, 554, 552, 539, 538, 533, 531, 530, 523, 526, 510, 520, 507, 512, 504, 499, 497, 489, 486, 488, 480, 479, 478, 486, 467, 462, 465, 456, 452, 450, 441, 447, 440, 439, 439, 432, 423, 417, 422, 419, 409, 404, 397, 400, 391, 389, 387, 388, 378, 381, 373, 368, 374, 368, 362, 353, 360, 354, 364, 368, 368, 377, 380, 378, 390, 382, 395, 399, 396, 400, 407, 414, 416, 412, 426, 425, 426, 432, 441, 437, 443, 443, 446, 456, 459, 461, 460, 472, 473, 471, 478, 485, 491, 487, 495, 492, 502, 505, 509, 512, 513, 516, 519, 526, 528, 532, 533, 536, 547, 550, 554, 562, 555, 566, 565, 570, 569, 574, 576, 586, 593, 587, 591, 601, 600, 602, 613, 618, 623, 621, 622, 632, 635, 639, 638, 647, 650, 647, 650, 658, 663, 661, 670, 668, 678, 685, 681, 691, 692, 692, 694, 690, 708, 707, 683, 712, 722, 722, 724, 729, 735, 731, 739, 742, 747, 754, 748, 756, 767, 765, 765, 771, 780, 778, 776, 788, 788, 793, 786, 782, 785, 774, 774, 764, 761, 760, 753, 756, 750, 745, 745, 742, 734, 732, 733, 724, 721, 718, 716, 713, 708, 706, 699, 700, 692, 685, 684, 677, 677, 674, 672, 666, 663, 662, 656, 658, 644, 651, 642, 641, 635, 636, 634, 625, 626, 615, 612, 608, 609, 607, 600, 597, 598, 588, 581, 585, 580, 571, 568, 579, 565, 564, 557, 554, 548, 548, 540, 538, 535, 530, 527, 526, 517, 517, 513, 512, 512, 498, 501, 493, 487, 488, 485, 481, 478, 474, 472, 472, 459, 464, 451, 492, 444, 442, 443, 436, 435, 427, 463, 427, 421, 418, 416, 404, 405, 395, 402, 390, 384, 389, 378, 377, 371, 367, 363, 362, 356, 356, 360, 358, 364, 369, 374, 370, 375, 379, 385, 388, 395, 392, 394, 399, 412, 405, 414, 417, 427, 422, 425, 434, 433, 437, 443, 443, 447, 460, 457, 458, 468, 471, 475, 480, 474, 483, 485, 485, 492, 502, 500, 504, 512, 508, 511, 517, 522, 524, 527, 538, 542, 545, 542, 593, 549, 563, 569, 560, 571, 572, 578, 580, 582, 608, 590, 596, 595, 597, 599, 609, 611, 615, 618, 619, 623, 632, 633, 636, 638, 638, 645, 667, 647, 660, 651, 661, 667, 674, 678, 678, 677, 623, 693, 690, 700, 699, 709, 711, 708, 712, 714, 724, 730, 722, 729, 733, 736, 743, 747, 753, 758, 753, 765, 770, 767, 773, 779, 776, 790, 790, 791, 450, 535, 571, 592, 607, 619, 628, 635, 644, 650, 653, 660, 666, 666, 671, 674, 684, 684, 686, 689, 681, 681, 684, 688, 690, 692, 697, 697, 703, 702, 704, 706, 711, 710, 708, 717, 714, 715, 715, 716, 718, 715, 719, 720, 721, 726, 719, 726, 727, 722, 724, 723, 727, 726, 727, 725, 729, 731, 727, 729, 731, 730, 730, 728, 729, 732, 730, 731, 729, 735, 731, 734, 733, 734, 733, 733, 737, 734, 732, 735, 737, 734, 739, 729, 734, 740, 735, 734, 735, 737, 736, 735, 738, 735, 742, 738, 742, 740, 736, 738, 739, 739, 738, 737, 739, 740, 741, 741, 743, 741, 739, 742, 739, 744, 744, 743, 742, 743, 744, 751, 743, 744, 739, 742, 743, 739, 739, 740, 739, 740, 738, 738, 737, 739, 741, 736, 735, 738, 734, 734, 736, 721, 734, 735, 735, 737, 732, 735, 736, 736, 739, 736, 738, 734, 737, 734, 736, 735, 735, 734, 734, 738, 736, 733, 734, 738, 733, 737, 754, 745, 736, 737, 736, 734, 737, 736, 735, 734, 736, 734, 734, 735, 736, 736, 736, 740, 736, 735, 736, 738, 743, 738, 734, 736, 737, 734, 733, 733, 736, 736, 734, 736, 734, 733, 732, 734, 730, 732, 730, 728, 731, 728, 727, 723, 725, 723, 719, 724, 718, 722, 705, 715, 713, 716, 716, 716, 710, 713, 712, 710, 711, 709, 710, 709, 711, 710, 711, 711, 709, 709, 709, 710, 424, 530, 570, 595, 612, 624, 638, 645, 654, 656, 664, 669, 695, 678, 681, 687, 685, 693, 695, 694, 691, 700, 702, 707, 703, 706, 710, 715, 713, 713, 712, 721, 720, 720, 723, 723, 729, 725, 725, 730, 731, 730, 733, 737, 733, 736, 731, 739, 742, 736, 736, 737, 726, 733, 738, 737, 737, 739, 738, 738, 741, 738, 743, 740, 741, 739, 741, 741, 741, 743, 741, 747, 748, 745, 745, 743, 745, 750, 749, 745, 749, 744, 749, 750, 742, 744, 748, 752, 748, 745, 743, 750, 750, 747, 748, 747, 742, 740, 742, 754, 749, 749, 748, 749, 748, 751, 750, 752, 747, 754, 756, 753, 753, 750, 754, 752, 753, 755, 756, 754, 755, 755, 748, 748, 748, 749, 749, 747, 750, 745, 745, 744, 746, 747, 742, 750, 743, 740, 738, 746, 744, 743, 744, 744, 744, 742, 744, 741, 750, 742, 743, 739, 739, 742, 743, 741, 744, 743, 740, 741, 739, 742, 742, 740, 745, 742, 741, 740, 741, 743, 742, 740, 735, 740, 739, 739, 742, 739, 740, 742, 740, 739, 742, 745, 742, 739, 739, 742, 741, 741, 741, 744, 742, 741, 739, 738, 764, 738, 739, 739, 737, 737, 739, 739, 737, 735, 734, 731, 731, 729, 730, 727, 726, 725, 724, 727, 725, 722, 722, 721, 721, 719, 718, 718, 717, 718, 716, 717, 720, 715, 717, 713, 711, 713};


// Create the Bluefruit Object
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


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

/*=========================================================================
 * Setup
 */
void setup(void)
{
  // Set up Serial output
  Serial.begin(115200);
  Serial.println(F("Adafruit Bluefruit Data Plotting"));
  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(500);
  }

  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);
 
 delay(1000);                  //wait 1 second

  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String(i).c_str());
    if (i < NUMBER-1) {
      ble.println();
         } 
  }
  // plot the values
 

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






void loop(void)
{
  }


The above code for the adafruit bluefruit feather prints all the values from 0 to 960
Errors:

1. I need only the values in the String to be plotted only once.
2. Command to plot the data in plotter mode.
3. How do I plot the values one after the other?

Thank you,
AK
Attachments
Bluefruit_LE_Connect_Plotter.ino
(7.83 KiB) Downloaded 23 times

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Mon Apr 08, 2019 1:54 am

If you want to use the values in the array, you have to include the array in your code.

This just prints the numbers 0 to NUMBER-1.
Code: Select all | TOGGLE FULL SIZE
  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String(i).c_str());
    if (i < NUMBER-1) {
      ble.println();
         } 
  }
To get the values in the array, you'd use this:

Code: Select all | TOGGLE FULL SIZE
  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String( data[ i ] ).c_str());
    if (i < NUMBER-1) {
      ble.println();
         } 
  }

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Mon Apr 08, 2019 9:41 am

Can I write this code in the Void loop and make it Repeat only once?
The above code displays the data in UART mode.
How can I make it to plot in the plotter mode?

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Mon Apr 08, 2019 11:42 pm

The Feather doesn't control whether your phone plots the data, it just sends the values. You need to select the BLE Connect app's 'Plot' screen to have it plot the input as a graph.

If you only want to transmit the numbers once, it's easiest to leave the for() in setup(). To get the same effect from loop(), you'd need to use an external counter:

Code: Select all | TOGGLE FULL SIZE
int counter = 0;

void loop () {
    if ( counter >= NUMBER ) {
        return;
    }
    ble.print(String( data[ counter ] ).c_str());
    counter++;
}

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Thu Apr 11, 2019 10:45 am

Thank you, This works.

Question out of the box.
Consider I have a sensor that plots this data. How would I configure this Ada fruit such that it plots the data on a continuous mode?

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Fri Apr 12, 2019 12:50 am

Use ble.print() to transmit each value as you collect it.

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Mon Apr 22, 2019 12:06 pm

Code: Select all | TOGGLE FULL SIZE
/*********************************************************************
  Adapted from Bluefruit LE Connect Plotter
  for Feather Bluefruit -> Bluefruit LE Connect app
  (MIT License)
*********************************************************************/
#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"

#define FACTORYRESET_ENABLE         1
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"
#define MODE_LED_BEHAVIOUR          "MODE"
/*=========================================================================*/

// Data to plot
#define NUMBER 143
int data[NUMBER] = {-1.00627745,-1.00064115,-0.9947667,-0.98881285,-0.982859,-0.9767464,-0.9707132,-0.96491815,-0.95920245,-0.9534868,-0.9479299,-0.9422936,-0.9365779,-0.931021,-0.9253847,-0.91966905,-0.9139534,-0.9083171,-0.9026014,-0.8969651,-0.8912494,-0.8855337,-0.879818,-0.8741817,-0.86846605,-0.86298855,-0.85743165,-0.85179535,-0.84607965,-0.84036395,-0.83464825,-0.82885315,-0.8231375,-0.81734245,-0.8116268,-0.80606985,-0.80035415,-0.79463845,-0.78892275,-0.7831277,-0.77741205,-0.77177575,-0.76613945,-0.7604238,-0.7547875,-0.7491512,-0.7434355,-0.7377198,-0.7320835,-0.7264472,-0.7208109,-0.7151746,-0.7095383,-0.703902,-0.6982657,-0.6926294,-0.6869931,-0.6813568,-0.67572055,-0.6701636,-0.6645273,-0.658891,-0.65317535,-0.64745965,-0.64182335,-0.63610765,-0.63047135,-0.62475565,-0.61911935,-0.61348305,-0.60784675,-0.60221045,-0.59649475,-0.59077905,-0.58514275,-0.5794271,-0.57363205,-0.56799575,-0.56228005,-0.5565644,-0.5509281,-0.54513305,-0.53949675,-0.53393985,-0.52830355,-0.52266725,-0.51711035,-0.51155345,-0.50591715,-0.50028085,-0.4945652,-0.48892895,-0.48337205,-0.47781515,-0.47209945,-0.46646315,-0.4609062,-0.4552699,-0.449713,-0.4441561,-0.4385992,-0.4330423,-0.427406,-0.4216903,-0.4158952,-0.4101795,-0.40438445,-0.3986688,-0.39295315,-0.3872375,-0.3815218,-0.3757267,-0.370011,-0.3642953,-0.358659,-0.3529433,-0.34730705,-0.3415914,-0.3358757,-0.33016,-0.3244443,-0.318808,-0.3131717,-0.3075354,-0.304752789,-0.301925611,-0.299139353,-0.2963025,-0.2935108,-0.2906605,-0.287860231,-0.2851225,-0.28232,-0.2795921,-0.276787222,-0.2738765,-0.271041286,-0.2683195,-0.2657792,-0.2631595,-0.260381,-0.2572055,-0.25403};
int counter = 0;

// Create the Bluefruit Object
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


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

/*=========================================================================
 * Setup
 */
void setup(void)
{
  // Set up Serial output
  Serial.begin(115200);
  Serial.println(F("Adafruit Bluefruit Data Plotting"));
  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(500);
  }

  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);
 
 delay(5000);                  //wait 1 second

  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String( data[ i ] ).c_str());
    if (i < NUMBER-1) {
      ble.println();
         } 
  }
  // plot the values

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

void loop () {
   
}

I wanted to plot the data values, I guess I have to change the Category of the numbers Since I have negative numbers to plot.
I'm trying to use FLOAT for the data but I'm not able to plot the data?

What should be my initialization for this?

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Tue Apr 23, 2019 12:49 am

If you're using the plotting screen from our BLE Connect app, the format is 'C strings'.

You can use the Arduino String class to convert the floating point numbers to strings, then get the C strings from that.

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Tue Apr 23, 2019 3:36 am

Yes, I'm using the Adafruit BLE app.
How will I code for this Command?

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Wed Apr 24, 2019 12:05 am

Use ble.print().

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Wed Apr 24, 2019 10:55 am

Code: Select all | TOGGLE FULL SIZE
/*********************************************************************
  Adapted from Bluefruit LE Connect Plotter
  for Feather Bluefruit -> Bluefruit LE Connect app
  (MIT License)
*********************************************************************/
#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"

#define FACTORYRESET_ENABLE         1
#define MINIMUM_FIRMWARE_VERSION    "0.6.6"
#define MODE_LED_BEHAVIOUR          "MODE"
/*=========================================================================*/

// Data to plot
#define NUMBER 143
int data[NUMBER] = {-1.00627745,-1.00064115,-0.9947667,-0.98881285,-0.982859,-0.9767464,-0.9707132,-0.96491815,-0.95920245,-0.9534868,-0.9479299,-0.9422936,-0.9365779,-0.931021,-0.9253847,-0.91966905,-0.9139534,-0.9083171,-0.9026014,-0.8969651,-0.8912494,-0.8855337,-0.879818,-0.8741817,-0.86846605,-0.86298855,-0.85743165,-0.85179535,-0.84607965,-0.84036395,-0.83464825,-0.82885315,-0.8231375,-0.81734245,-0.8116268,-0.80606985,-0.80035415,-0.79463845,-0.78892275,-0.7831277,-0.77741205,-0.77177575,-0.76613945,-0.7604238,-0.7547875,-0.7491512,-0.7434355,-0.7377198,-0.7320835,-0.7264472,-0.7208109,-0.7151746,-0.7095383,-0.703902,-0.6982657,-0.6926294,-0.6869931,-0.6813568,-0.67572055,-0.6701636,-0.6645273,-0.658891,-0.65317535,-0.64745965,-0.64182335,-0.63610765,-0.63047135,-0.62475565,-0.61911935,-0.61348305,-0.60784675,-0.60221045,-0.59649475,-0.59077905,-0.58514275,-0.5794271,-0.57363205,-0.56799575,-0.56228005,-0.5565644,-0.5509281,-0.54513305,-0.53949675,-0.53393985,-0.52830355,-0.52266725,-0.51711035,-0.51155345,-0.50591715,-0.50028085,-0.4945652,-0.48892895,-0.48337205,-0.47781515,-0.47209945,-0.46646315,-0.4609062,-0.4552699,-0.449713,-0.4441561,-0.4385992,-0.4330423,-0.427406,-0.4216903,-0.4158952,-0.4101795,-0.40438445,-0.3986688,-0.39295315,-0.3872375,-0.3815218,-0.3757267,-0.370011,-0.3642953,-0.358659,-0.3529433,-0.34730705,-0.3415914,-0.3358757,-0.33016,-0.3244443,-0.318808,-0.3131717,-0.3075354,-0.304752789,-0.301925611,-0.299139353,-0.2963025,-0.2935108,-0.2906605,-0.287860231,-0.2851225,-0.28232,-0.2795921,-0.276787222,-0.2738765,-0.271041286,-0.2683195,-0.2657792,-0.2631595,-0.260381,-0.2572055,-0.25403};
int counter = 0;

// Create the Bluefruit Object
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


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

/*=========================================================================
 * Setup
 */
void setup(void)
{
  // Set up Serial output
  Serial.begin(115200);
  Serial.println(F("Adafruit Bluefruit Data Plotting"));
  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(500);
  }

  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);
 
 delay(5000);                  //wait 1 second

  // Plot values in data array
  for (int i=0; i<NUMBER; i++) {
    ble.print(String( data[ i ] ).c_str());
    if (i < NUMBER-1) {
      ble.print()
         } 
  }
  // plot the values

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

void loop () {
   
}


Find an attached error after the change in the code?

Can you help me write with the exact code?
Attachments
Error.JPG
Error.JPG (70.91 KiB) Viewed 77 times

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Re: Adafruti Bluefruit code

by adafruit_support_mike on Wed Apr 24, 2019 12:29 pm

We don’t do on-demand software development. We’ll help if we can when someone gets stuck, but we operate on a show-your-work policy.

The problems you’re trying to solve fall under in the category of general programming. Take a look at the example sketches that come with the BLE library, and play with them until you’re comfortable with the way they work.

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruti Bluefruit code

by anini119 on Wed Apr 24, 2019 12:55 pm

I understand.
But I don't find any examples that are close to my project.
Would appreciate your time and effort if you can help me find an example for this kind of Error obtained.

Thank you,
AK

anini119
 
Posts: 21
Joined: Fri Oct 12, 2018 1:06 pm

Please be positive and constructive with your questions and comments.