# Datalogging Hat with FLORA BLE

## Overview

https://www.youtube.com/watch?v=Md7UDqD3qOE

Log your wearables data to the cloud! Using the Bluefruit LE Connect app and Adafruit IO, you can display the changing values of a FLORA light sensor in realtime on a webpage.

This is a great upgrade to make to your [Sunscreen Reminder Hat](../../../sunscreen-reminder-hat)&nbsp;or&nbsp;[Sparkle Skirt.](../../../sparkle-skirt)

This guide focuses on getting your data from the Bluefruit LE Connect app to the Adafruit IO servers, so if you're a beginner with FLORA, try a few basic projects first! Here are some prerequisite guides to check out:

- [Getting Started with FLORA](../../../getting-started-with-flora)
- [FLORA Bluefruit LE module](../../../adafruit-flora-bluefruit-le)
- [FLORA Lux Sensor](../../../flora-lux-sensor)&nbsp;(or [FLORA Sensors](../../../flora-sensors)&nbsp;if you want to swap to a different one)
- [Adafruit IO Basics: Feeds](../../../adafruit-io-basics-feeds)
- [Adafruit IO Basics: Dashboards](../../../adafruit-io-basics-dashboards)

For this example, you will need:

- [FLORA microcontroller](http://www.adafruit.com/product/659)
- [FLORA Bluefruit LE Module](http://www.adafruit.com/product/2487)
- [FLORA Lux Sensor](http://www.adafruit.com/product/1246)

# Datalogging Hat with FLORA BLE

## Circuit and Arduino code

The FLORA, FLORA BLE module, and FLORA light sensor are wired up as pictured:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/931/medium800/flora_diagram.jpg?1443648652)

Required Arduino libraries:

- [Adafruit Unified Sensor Library](https://github.com/adafruit/Adafruit_Sensor)
- [Adafruit TSL2561 Light Sensor Library](https://github.com/adafruit/Adafruit_TSL2561)
- [Adafruit Bluefruit LE nRF51 Library](https://github.com/adafruit/Adafruit_BluefruitLE_nRF51)

Download and unzip the following file, then open up light-logging-hat.ino in your Arduino IDE:

[light-logging-hat.zip](https://learn.adafruit.com/system/assets/assets/000/027/930/original/light-logging-hat.zip?1443644910)
The main loop of the code reads the light sensor and sends the value out over the bluetooth connection:

```auto
void loop(void)
{
   /* Get a new sensor event */ 
  sensors_event_t event;
  tsl.getEvent(&event);
 
  /* Display the results (light is measured in lux) */
  if (event.light)
  {
    ble.println(event.light);
  }
  else
  {
    /* If event.light = 0 lux the sensor is probably saturated
       and no reliable data could be generated! */
    Serial.println("Sensor overload");
  }
  
  delay(1000);

}
```

# Datalogging Hat with FLORA BLE

## Bluefruit LE Connect settings

![](https://cdn-learn.adafruit.com/assets/assets/000/027/944/medium800/flora_Screenshot_2015-09-30-22-16-55.png?1443666579)

Launch the Bluefruit LE Connect app on your Android or iOS device. Below screenshots are from an Android phone, iOS app may vary slightly.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/947/medium800/flora_Screenshot_2015-09-30-22-17-06.jpg?1443666837)

A list of available bluetooth devices will appear. Select the one labeled **Adafruit Bluefruit LE**.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/948/medium800/flora_uart.jpg?1443666932)

A prompt appears asking you to choose a mode to connect-- select **UART** mode.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/949/medium800/flora_Screenshot_2015-09-30-22-17-19.png?1443666969)

![](https://cdn-learn.adafruit.com/assets/assets/000/027/950/medium800/flora_Screenshot_2015-09-30-22-23-16.jpg?1443667016)

If your connection is successful, you should see sensor values update on the screen. If your connection failed, try restarting both the FLORA circuit and the Bluefruit LE app and attempt to connect again.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/954/medium800/flora_Screenshot_2015-09-30-22-23-38.jpg?1443667356)

Configure your first two boxes&nbsp;as follows:

**Server**

Address: io.adafruit.com

Port: 1833

**Publish**

UART RX: **username** /feeds/ **feedname**

Under "Advanced," enter your username and AIO key, which can be found by clicking the key button in the upper right of any of your Dashboards.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/955/medium800/flora_Screen_Shot_2015-09-30_at_10.30.28_PM.png?1443667389)

Copy your AIO key into an email, file on dropbox, or other easy way to paste it into your device-- copying it from the screen is no fun (unless you love memorizing)!

![](https://cdn-learn.adafruit.com/assets/assets/000/027/956/medium800/flora_Screen_Shot_2015-09-30_at_10.30.38_PM.png?1443667406)

After you've configured your settings, go ahead and click ENABLE at the top of the page.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/953/medium800/flora_Screenshot_2015-09-30-22-23-42.jpg?1443667238)

![](https://cdn-learn.adafruit.com/assets/assets/000/027/957/medium800/flora_Screenshot_2015-09-30-22-23-50.jpg?1443667435)

![](https://cdn-learn.adafruit.com/assets/assets/000/027/958/medium800/flora_Screenshot_2015-09-30-22-45-35.png?1443667600)

If the connection isn't successful, double check your settings including your username, UART/RX path, and AIO key.

If you're connected, you can now refresh your Feeds page on io.adafruit.com to see your new data steam. Hurray! Now let's&nbsp;learn how to display that incoming data.

![](https://cdn-learn.adafruit.com/assets/assets/000/027/945/medium800/flora_Screen_Shot_2015-09-30_at_10.25.18_PM.png?1443666616)

# Datalogging Hat with FLORA BLE

## Adafruit IO Dashboard display

Once the Bluefruit LE Connect application is sending data to Adafruit IO then you're ready to build a dashboard to display the results.

I you're new to using Adafruit IO&nbsp;be sure to first read the [Adafriot IO Basics: Dashboards](../../../../adafruit-io-basics-dashboards/overview)&nbsp;guide for an overview of creating a dashboard.

To create the dashboard for the light sensor feed first log in to [Adafruit IO](https://io.adafruit.com)&nbsp;([https://io.adafruit.com](https://io.adafruit.com))&nbsp;and click the **My Dashboards** button in the upper left:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/932/medium800/flora_Screen_Shot_2015-09-30_at_2.31.31_PM.png?1443649743)

Once on the **Your Dashboards** page click the **Create Dashboard** button in the upper right to build a new dashboard:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/933/medium800/flora_Screen_Shot_2015-09-30_at_2.31.58_PM.png?1443649764)

In the dialog box that pops up give the dashboard a good name, like Hat Light, then click **Create Dashboard** :

![](https://cdn-learn.adafruit.com/assets/assets/000/027/934/medium800/flora_Screen_Shot_2015-09-30_at_2.32.50_PM.png?1443649789)

Now the new Hat Light dashboard is displayed, but it doesn't have any blocks that show sensor&nbsp;data. &nbsp;You can add a line chart&nbsp;block to see the light sensor value over time by clicking the **New Block** button in the upper right corner:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/935/medium800/flora_Screen_Shot_2015-09-30_at_2.33.14_PM.png?1443649931)

Scroll down to the line chart component and click **Create** :

![](https://cdn-learn.adafruit.com/assets/assets/000/027/936/medium800/flora_Screen_Shot_2015-09-30_at_2.34.06_PM.png?1443649952)

Now find the hatlight feed that was created by the Bluefruit LE Connect application. &nbsp;You can scroll through the feed list or type in the name to the search box. &nbsp;Once you find the feed click the **Choose** &nbsp;button next to it, then click **Next Step** :

![](https://cdn-learn.adafruit.com/assets/assets/000/027/937/medium800/flora_Screen_Shot_2015-09-30_at_2.37.59_PM.png?1443649998)

Finally make the block easy to understand by filling in details about how it should be displayed:

- **Block Title** : Put in a descriptive title for the block, like **Hat Light Graph**.
- **Hours of History** : Stick with the default of 1 hour, or change to a larger/smaller range.
- **X-Axis Label** : Stick with the default **Time** since the X axis (left to right axis of the graph) is based on the time of each sensor reading.
- **Y-Axis Label** : Label this axis (top to bottom axis) **Lux** since it's the axis for the light sensor reading.
- **Y-Axis Minimum** : Use a value like **0** as a good minimum range for the graph values (since you know there are no negative lux values).
- **Y-Axis Maximum** : Use a large value like **2000** as a starting point, you can always edit the block and change this later to 'zoom in' on a range of data.

Once you've filled in the details click **Create Block** :

![](https://cdn-learn.adafruit.com/assets/assets/000/027/938/medium800/flora_Screen_Shot_2015-09-30_at_2.39.49_PM.png?1443650020)

Awesome, the chart block should now be displayed!

![](https://cdn-learn.adafruit.com/assets/assets/000/027/939/medium800/flora_Screen_Shot_2015-09-30_at_2.40.28_PM.png?1443650043)

You can change the size, location, and details of the chart block by clicking the **Edit** button in the top left:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/941/medium800/flora_Screen_Shot_2015-09-30_at_3.08.43_PM.png?1443651220)

Once you're in edit mode you can move the mouse over a block to make changes to it:

- To change the block's settings click the **gear icon** in the upper right of the block.
- To delete the block click the **trash can icon** in the upper right of the block.
- To move the block click and drag it anywhere on the dashboard.
- To resize the block click and hold the **resize arrows** in the lower right of the block as shown below:

![](https://cdn-learn.adafruit.com/assets/assets/000/027/943/medium800/flora_screenshot.png?1443651282)

Drag&nbsp;the mouse while holding the resize arrows to change the size of the chart block.

Once you're done editing blocks be sure to click **Done Editing** to save the changes!

Let your creativity flow as you design cool dashboards to display sensor data! &nbsp;For example here's what you can do if you change the size of the chart and add a gauge block next to it (remember click **New Block** to add a new block, then follow the steps for customizing it):

![](https://cdn-learn.adafruit.com/assets/assets/000/027/940/medium800/flora_Screen_Shot_2015-09-30_at_2.42.17_PM.png?1443650079)


## Featured Products

### FLORA - Wearable electronic platform: Arduino-compatible

[FLORA - Wearable electronic platform: Arduino-compatible](https://www.adafruit.com/product/659)
FLORA is Adafruit's fully-featured wearable electronics platform. It's a round, sewable, Arduino-compatible microcontroller designed to empower amazing wearables projects.FLORA comes with Adafruit's support, [tutorials and...](http://learn.adafruit.com/category/flora)

In Stock
[Buy Now](https://www.adafruit.com/product/659)
[Related Guides to the Product](https://learn.adafruit.com/products/659/guides)
### Flora Wearable Bluefruit LE Module

[Flora Wearable Bluefruit LE Module](https://www.adafruit.com/product/2487)
Would you like to add powerful and easy-to-use Bluetooth Low Energy to your wearable FLORA project? Heck yeah! With BLE now included in modern smart phones and tablets, its fun to add wireless connectivity. So what you really need is the new Adafruit Flora Bluefruit LE!

The Flora...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2487)
[Related Guides to the Product](https://learn.adafruit.com/products/2487/guides)
### Flora Lux Sensor - TSL2561 Light Sensor

[Flora Lux Sensor - TSL2561 Light Sensor](https://www.adafruit.com/product/1246)
Add light-reactive sensing to your wearable Flora project with this high precision Lux sensor. The TSL2561 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing for exact...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1246)
[Related Guides to the Product](https://learn.adafruit.com/products/1246/guides)

## Related Guides

- [FLORA NeoGeo Watch](https://learn.adafruit.com/flora-geo-watch.md)
- [Plush Game Controller](https://learn.adafruit.com/plush-game-controller.md)
- [Flora MIDI Drum Glove](https://learn.adafruit.com/midi-drum-glove.md)
- [Zipper Switch](https://learn.adafruit.com/zipper-switch.md)
- [Flora+NeoPixel LED Skateboard Upgrade](https://learn.adafruit.com/flora-neopixel-led-skateboard-upgrade.md)
- [Light-Up Angler Fish Embroidery](https://learn.adafruit.com/light-up-angler-fish-embroidery.md)
- [Experimenting with NeverWet + Electronics](https://learn.adafruit.com/neverwet-electronics.md)
- [Adding Third Party Boards to the Arduino v1.6.4+ IDE](https://learn.adafruit.com/add-boards-arduino-v164.md)
- [Fiber Optic Pixie Skirt](https://learn.adafruit.com/fiber-optic-pixie-princess-skirt.md)
- [Flora Snaps](https://learn.adafruit.com/flora-snaps.md)
- [VU Meter Baseball Hat](https://learn.adafruit.com/vu-meter-baseball-hat.md)
- [Let’s Put LEDs in Things!](https://learn.adafruit.com/lets-put-leds-in-things.md)
- [Flora Brake Light Backpack](https://learn.adafruit.com/flora-brakelight-backpack.md)
- [3D Printed Wireless MIDI Controller Guitar](https://learn.adafruit.com/ez-key-wireless-midi-controller-guitar.md)
- [Wearable Piezo Tones with Flora](https://learn.adafruit.com/wearable-piezo-tones-with-flora.md)
