The Circuit Playground Bluefruit has a built in light sensor that returns a light value and a temperature sensor that returns the temperature in degrees Celsius. The Adafruit Bluefruit LE Connect mobile app has a built in plotter function that you can use to plot any numerical information. This page will show you how to plot the light and temperature data from the Circuit Playground Bluefruit in the Bluefruit LE Connect app!
The Code
Plug your Circuit Playground Bluefruit into your computer, and save the following as code.py on the CIRCUITPY drive:
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT # CircuitPython Bluefruit LE Connect Plotter Example import time import board import analogio import adafruit_thermistor from adafruit_ble import BLERadio from adafruit_ble.advertising.standard import ProvideServicesAdvertisement from adafruit_ble.services.nordic import UARTService ble = BLERadio() uart_server = UARTService() advertisement = ProvideServicesAdvertisement(uart_server) thermistor = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950) light = analogio.AnalogIn(board.LIGHT) def scale(value): """Scale the light sensor values from 0-65535 (AnalogIn range) to 0-50 (arbitrarily chosen to plot well with temperature)""" return value / 65535 * 50 while True: # Advertise when not connected. ble.start_advertising(advertisement) while not ble.connected: pass ble.stop_advertising() while ble.connected: print((scale(light.value), thermistor.temperature)) uart_server.write("{},{}\n".format(scale(light.value), thermistor.temperature)) time.sleep(0.1)
Connect to your board through the Adafruit Bluefruit LE Connect mobile app. If you need assistance, check out the Bluefruit LE Connect Basics page in the Getting Started guide.
Once connected, tap Plotter.
Your data should start plotting automatically. Try shining a light towards your Circuit Playground Bluefruit to see the light value line change. Try placing your finger over the thermistor (towards the top-right, labeled A9, next to the picture of a thermometer) to see the temperature value line change.
That's all there is to plotting numerical data with the Circuit Playground Bluefruit and the Adafruit Bluefruit LE Connect mobile app!