Skip to content

Commit 5b4b741

Browse files
authored
Merge pull request #25 from kattni/plotter-code
Adding plotter code.
2 parents 471db7b + b41ce50 commit 5b4b741

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CircuitPython Bluefruit LE Connect Plotter Example
2+
3+
import board
4+
import analogio
5+
import adafruit_thermistor
6+
from adafruit_ble.uart_server import UARTServer
7+
8+
uart_server = UARTServer()
9+
10+
thermistor = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950)
11+
light = analogio.AnalogIn(board.LIGHT)
12+
13+
14+
def scale(value):
15+
"""Scale the light sensor values from 0-65535 (AnalogIn range)
16+
to 0-50 (arbitrarily chosen to plot well with temperature)"""
17+
return value / 65535 * 50
18+
19+
20+
while True:
21+
# Advertise when not connected.
22+
uart_server.start_advertising()
23+
while not uart_server.connected:
24+
pass
25+
26+
while uart_server.connected:
27+
print(scale(light.value), thermistor.temperature)
28+
uart_server.write('{},{}\n'.format(scale(light.value), thermistor.temperature))

0 commit comments

Comments
 (0)