Materials (see google drive folder for spreadsheets with cost information):
Arduino files are in google drive folder.
3.3 v → 3.3 v (red) gnd → gnd (black) Tx → Rx (blue) Rx → Tx (white)
2. Connection from Flora to accelerometer:
3.3 v → 3.3 v (red) gnd → gnd (black) SCL → SCL SDA → SDA
*When testing each code separately, I found it easiest to work with just those components. In other words, to get rid of the clutter, when working on the the accelerometer test, disconnect the Bluefruit, which reduces the number of alligator clips from eight to four.
3. Download Arduino IDE (software)
4. Add the Adafruit Flora board to the Arduino's board manager. Do this by first opening the software, opening "preferences", scrolling down to "additional boards manager URLs", and pasting this link: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json. Click "OK" and then click on tools at the top of the screen. Go to "Board" → "Boards Manager", type "Adafruit AVR Boards" in the search box, and click "Install". Finally, go back to the "tools" tab and underneath a section labelled "Adafruit boards", select "Adafruit Flora"
5. Add the example code libraries from GitHub. There are three libraries that need to be downloaded: Adafruit Bluefruit nRF51, Adafruit LSM303DLHC, and Adafruit Unified Sensor. On the GitHub pages, there should be a green button that reads "Clone or Download". Click it and then click on "Download ZIP". Reopen Arduino and go to the "sketch" tab, click "Include Library", and "Add ZIP Library". Under downloads, the ZIP file that was downloaded from GitHub should be an option. Select the master ZIP file and click "choose". The libraries should now be downloaded.
6. Test code for accelerometer: open up Arduino, go to file -> examples -> Adafruit LSM303DLHC library (downloaded in step 5) -> accelsensor. This should open up an example sketch that should run without modifications. Make sure Adafruit Flora is selected under tools -> board and that the correct USB port is selected under tools -> port (name of microcontroller should be in parenthesis next to the occupied port). As mentioned above, nothing needed to be changed in the code, but Mr. Proffitt did add the line:
else {Serial.println ("accelerometer connected");}
Thus, the serial monitor would display the message that the accelerometer was connected as long as there was no problems in the wiring, in which case it would display the message "Ooops, no LSM303 detected ... Check your wiring!"
Message received when there was a loose alligator clip connection:
7. Bluetooth example code (bleuart_cmdmode): open a new Arduino window and go to file -> examples -> Adafruit Bluefruit LE nRF51 library -> bleuart_cmdmode. This should open an example sketch that has two tabs, the code and the configuration page. Under the configuration page, BLUEFRUIT_HWSERIAL_NAME should be "Serial1" and BLUEFRUIT_UART_MODE_PIN should be set to -1 since mode pad is not used (switch set to CMD). Because we are not using SPI nor Software Serial, we don't have to worry about defining those pins. More information about the configuration settings here and here. In the code, only the hardware serial line should be uncommented:
Adafruit_BluefruitLE_UART ble(Serial1, BLUEFRUIT_UART_MODE_PIN);
8. Make sure the Adafruit app is downloaded and hardware is set up between the Flora and the Bluefruit. Open up the serial monitor on your computer (top right corner of code), and as soon as you do, it should automatically go through initializing steps and factory rest and when it's ready it will say "Please use Adafruit Bluefruit LE app to connect in UART mode. Then Enter characters to send to Bluefruit". After verifying and uploading the code in step 7, open up app and press the connect button to a listing named "Adafruit Bluefruit LE". Blue light should be lit on Bluefruit once it is connected. Go to the UART tab on your phone and try to type something in the text box. What you type in the text box should appear in the serial monitor and visa versa.
8.5. If you just want to make sure the code in the sketch can send commands to the serial monitor, run the ATCommand code under the Adafruit Bluefruit LE nRF51 examples. Although this step isn't mandatory, it can be a good indication as to whether you're on the right track or not.
9. Combining the codes: since the ultimate goal is to get the accelerometer values appear on the phone, you have to copy and paste some of the accelsensor code into the bleuart_cmdmode code. Under my December 4 journal entry, there are more detailed instructions, but I have listed the key steps below:
if(!accel.begin())
{
/* There was a problem detecting the ADXL345 ... check your connections */
Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
while(1);
} else {
Serial.println ("accelerometer connected");
}
{
sensors_event_t event;
accel.getEvent(&event);
ble.print("AT+BLEUARTTX=");
ble.println(event.acceleration.x);
ble.print("AT+BLEUARTTX=");
ble.println(event.acceleration.y);
ble.print("AT+BLEUARTTX=");
ble.println(event.acceleration.z);
ble.waitForOK();
}
10. Using conductive thread and sewing components onto compression sock: workflow taken directly from Maxine's google site:
Materials: