sending data to adafruit App

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

sending data to adafruit App

Post by naley »

Hello,

How do I send sensor data connected to arduino to the adafruit app on ios and store the data?
I am using BLEuart as the bluetooth module to do so.
Is there any example that I can refer to?

Thank you!
Last edited by naley on Thu Jun 22, 2017 4:17 pm, edited 1 time in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending and storing data on adafruit App

Post by adafruit_support_rick »

You can send the data in any serial format you choose. You will need to write an iOS app to receive and store the data. We have some sample applications that may help you with this.
https://github.com/adafruit/Bluefruit_LE_Connect_v2
https://github.com/adafruit/Bluefruit_L ... ct_Android
https://github.com/adafruit/adafruit-bl ... le-desktop
https://github.com/adafruit/Adafruit_BluefruitLE_OSX
https://github.com/adafruit/Adafruit_Python_BluefruitLE

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending and storing data on adafruit App

Post by naley »

Is it possible to just send the data to the app :

https://learn.adafruit.com/bluefruit-le ... s/settings

Also, is it possible to send the data to the PC (which has bluetooth)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending and storing data on adafruit App

Post by adafruit_support_rick »

You can send UART or IMU data to the app, but the app has no data storage capability.

You can also send data to a PC, but you need an app on the PC to receive and store the data.

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending and storing data on adafruit App

Post by naley »

I tried sending the data to adafruit app.
I connected the BLEuart in data mode. It blinks 2 times as mentioned on the adafruit page.
However, this does not send any data to the app. The app doesnt show any data.
The blue light on BLEuart glows blue which means it is connected.

Are there any mistakes in the code?
Last edited by naley on Thu Jun 29, 2017 4:10 pm, edited 2 times in total.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending data to adafruit App

Post by adafruit_support_rick »

Well, you need a ble.begin:

Code: Select all

 /* 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!") );
You also should wait for a connection:

Code: Select all

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

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

Post by naley »

This is my modified code:

Code: Select all

#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);

#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;



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


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 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!") );

 while (! ble.isConnected()) {
      delay(500);
  }
 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));
  }
  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();
 
  ble.print(now.year(), DEC);
  ble.print('/');
  ble.print(now.month(), DEC);
  ble.print('/');
  ble.print(now.day(), DEC);
  ble.print(',');
  ble.print(now.hour(), DEC);
  ble.print(':');
  ble.print(now.minute(), DEC);
  ble.print(':');
  ble.print(now.second(), DEC);
  ble.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;


  



It does not print anything to the serial monitor nor to the app. Where am I going wrong?
Last edited by naley on Thu Jun 29, 2017 4:10 pm, edited 1 time in total.

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

Post by naley »

I changed the RTS pin to 8 and Mode to -1 in the BluefruitConfig.h file and this is what my serial monitor shows.( Attached picture) but it does not show any sensor data.
The app prints AT+GAPGETCONN continously but does not print the sensor data and suddenly says "Peripheral disconnected"
Attachments
Capture.PNG
Capture.PNG (6.98 KiB) Viewed 820 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending data to adafruit App

Post by adafruit_support_rick »

Ah! Sorry. You need to be in COMMAND mode for this to work:

Code: Select all

 while (! ble.isConnected()) {
      delay(500);
  }
To get what you're looking for, I think you want to turn verbose mode off, and switch into command mode before calling ble.isConnected:

Code: Select all

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);

  . . . etc . . .

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

Post by naley »

Thank you!
That worked.
It prints the data but does not print the max, min and Pdelta .
Have attached the picture of my serial monitor and app data:

How do I get it to print the max min values.
Also how to use the plotter in the app?
Attachments
FullSizeRender.jpg
FullSizeRender.jpg (136.75 KiB) Viewed 781 times
xyz.PNG
xyz.PNG (6.95 KiB) Viewed 781 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending data to adafruit App

Post by adafruit_support_rick »

You're not writing PDelta, min, and max to ble. You're only writing them to Serial.

If you want to use the plotter, you don't want PDelta, min , and max anyway. You want a csv stream, like you already have. The plotter works with your data, although I don't think you want the time in there.

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

Post by naley »

The plotter works with your data,although I don't think you want the time in there
This means I would only be able to print the pressure readings and not the time?

Is it possible to have pressure readings against the time ? Like have an x-axis and a y axis?
Is it possible to set axis? (Double Y, etc)

To get the data to the serial plotter,
Am using :

Ble.print(getPressure());
Ble.print("\\n\n");
Ble.print(time);
Ble.print("\\n\n");

Is this the right way to do so? Will this take x axis and y axis automatically ?

Thank you !

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending data to adafruit App

Post by adafruit_support_rick »

If you send the time, it will just show up as a rising line on the graph. The plotter automatically increments the time along the x axis.

Just do this, and you'll get a chart. Try it.

Code: Select all

      ble.println(getPressure());

User avatar
naley
 
Posts: 95
Joined: Fri Apr 28, 2017 4:26 pm

Re: sending data to adafruit App

Post by naley »

This is the image I get in the serial plotter:

My values do not vary much . They are all between 0.60-0.73. But the graph shows huge variations.There should not be much variation in the graph (???)

I dont understand the graph. Which axis is showing the time? and which one is showing the pressure?

The vertical axis in 1000,2000...6000 shows the time . But am not able to decipher the pressure values from the graph.

What are the 10,20...50 values on the horizontal axis ?


Thank you!
Attachments
Capture3.PNG
Capture3.PNG (3.64 KiB) Viewed 753 times
FullSizeRender1.jpg
FullSizeRender1.jpg (109.06 KiB) Viewed 753 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: sending data to adafruit App

Post by adafruit_support_rick »

You're still sending the time. Don't do that. Also don't send PDelta, min and max. ONLY send the pressure.

The values 10, 20, 30, etc. along the x axis is the time in seconds. The vertical axis shows the values you send, so you're plotting time AND pressure on the Y axis. Look at the time values you're sending. They're all at 65,000+, matching the plotted data. That's why you don't want to send the time.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”