I am using the Flora v3 https://www.adafruit.com/product/659?gc ... lPEALw_wcB and the Flora Wearable Bluefruit LE Module https://www.adafruit.com/product/2487
I am also using the Flora accelerometer. The purpose of this code is to calculate the number of steps that the user is taking. As the step count is calculated/updated, I want to send it to the Adafruit Bluefruit Android app over UART using the Bluefruit LE Module. Below I have provided the code I am working with:
Code: Select all
#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>
#define BUFSIZE 128 // Size of the read buffer for incoming data
#define VERBOSE_MODE true // If set to 'true' enables debug output
#define BLUEFRUIT_UART_CTS_PIN -1 // Not required for Flora
#define BLUEFRUIT_UART_RTS_PIN -1 // Optional, set to -1 if unused
#define BLUEFRUIT_UART_MODE_PIN -1 // Not required for Flora
#define BLUEFRUIT_HWSERIAL_NAME Serial1
Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN);
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
int steps = 0;
/* Assign a unique ID to this sensor at the same time */
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321);
void setup(void)
{
#ifndef ESP8266
while (!Serial); // will pause Zero, Leonardo, etc until serial console opens
#endif
Serial.begin(9600);
/* Initialise the sensor */
if(!accel.begin())
{
/* There was a problem detecting the ADXL345 ... check your connections */
//Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
while(1);
}
}
void loop(void)
{
//if (millis() >= 30000) exit(0); //end in half a minute
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
float average;
average = sqrt(pow(event.acceleration.x, 2) + pow(event.acceleration.y, 2) + pow(event.acceleration.z, 2));
if (average > 9.00)
{
steps = steps + 1;
}
char *myChar;
char str[10];
myChar = itoa(steps,str,10);
//Serial.write("steps:");
//Serial.write(" ");
Serial.write(myChar);
//Serial.write("\n");
delay(1000);
}
I am assuming that the issue is the configuration of the Bluetooth for the Flora but I am not sure what I am lacking as I have followed the tutorials provided in regard to setting up hardware UART for the Flora: https://learn.adafruit.com/adafruit-flo ... ample-code
Any advice or suggestions would be appreciated. I've also tried other Adafruit wearable boards and I've run into similar issues.