Skip to content

Commit f41231e

Browse files
authored
Merge branch 'master' into master
2 parents 77122c8 + ff698d8 commit f41231e

File tree

84 files changed

+127339
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+127339
-33
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Sensor demo for Adafruit Feather Sense. Prints data from each of the sensors."""
2+
import time
3+
import array
4+
import math
5+
import board
6+
import audiobusio
7+
import adafruit_apds9960.apds9960
8+
import adafruit_bmp280
9+
import adafruit_lis3mdl
10+
import adafruit_lsm6ds
11+
import adafruit_sht31d
12+
13+
i2c = board.I2C()
14+
15+
apds9960 = adafruit_apds9960.apds9960.APDS9960(i2c)
16+
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)
17+
lis3mdl = adafruit_lis3mdl.LIS3MDL(i2c)
18+
lsm6ds33 = adafruit_lsm6ds.LSM6DS33(i2c)
19+
sht31d = adafruit_sht31d.SHT31D(i2c)
20+
microphone = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
21+
sample_rate=16000, bit_depth=16)
22+
23+
def normalized_rms(values):
24+
minbuf = int(sum(values) / len(values))
25+
return int(math.sqrt(sum(float(sample - minbuf) *
26+
(sample - minbuf) for sample in values) / len(values)))
27+
28+
apds9960.enable_proximity = True
29+
apds9960.enable_color = True
30+
31+
# Set this to sea level pressure in hectoPascals at your location for accurate altitude reading.
32+
bmp280.sea_level_pressure = 1013.25
33+
34+
while True:
35+
samples = array.array('H', [0] * 160)
36+
microphone.record(samples, len(samples))
37+
38+
print("\nFeather Sense Sensor Demo")
39+
print("---------------------------------------------")
40+
print("Proximity:", apds9960.proximity)
41+
print("Red: {}, Green: {}, Blue: {}, Clear: {}".format(*apds9960.color_data))
42+
print("Temperature: {:.1f} C".format(bmp280.temperature))
43+
print("Barometric pressure:", bmp280.pressure)
44+
print("Altitude: {:.1f} m".format(bmp280.altitude))
45+
print("Magnetic: {:.3f} {:.3f} {:.3f} uTesla".format(*lis3mdl.magnetic))
46+
print("Acceleration: {:.2f} {:.2f} {:.2f} m/s^2".format(*lsm6ds33.acceleration))
47+
print("Gyro: {:.2f} {:.2f} {:.2f} dps".format(*lsm6ds33.gyro))
48+
print("Humidity: {:.1f} %".format(sht31d.relative_humidity))
49+
print("Sound level:", normalized_rms(samples))
50+
time.sleep(0.3)

BLE_Heart_Rate_Trainer/ble_heart_rate_trainer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
# Seven Segment FeatherWing setup
3636
i2c = board.I2C()
3737
display_A = Seg7x4(i2c, address=0x70) # this will be the BPM display
38-
display_A.brightness = 15
3938
display_A.fill(0) # Clear the display
4039
# Second display has A0 address jumpered
4140
display_B = Seg7x4(i2c, address=0x71) # this will be the % target display
42-
display_B.brightness = 15
4341
display_B.fill(0) # Clear the display
4442

4543
# display_A "b.P.M."

BLE_Sensornet/clue_sensornet.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""This uses the CLUE as a Bluetooth LE sensor node."""
2+
3+
import time
4+
from adafruit_clue import clue
5+
import adafruit_ble_broadcastnet
6+
7+
print("This is BroadcastNet CLUE sensor:", adafruit_ble_broadcastnet.device_address)
8+
9+
while True:
10+
measurement = adafruit_ble_broadcastnet.AdafruitSensorMeasurement()
11+
12+
measurement.temperature = clue.temperature
13+
measurement.pressure = clue.pressure
14+
measurement.relative_humidity = clue.humidity
15+
measurement.acceleration = clue.acceleration
16+
measurement.magnetic = clue.magnetic
17+
18+
print(measurement)
19+
adafruit_ble_broadcastnet.broadcast(measurement)
20+
time.sleep(60)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""This uses the Feather Sense as a Bluetooth LE sensor node."""
2+
3+
import time
4+
import adafruit_ble_broadcastnet
5+
import board
6+
import adafruit_lsm6ds # accelerometer
7+
import adafruit_sht31d # humidity sensor
8+
import adafruit_bmp280 # barometric sensor
9+
import adafruit_lis3mdl # magnetic sensor
10+
11+
i2c = board.I2C()
12+
13+
sense_accel = adafruit_lsm6ds.LSM6DS33(i2c)
14+
sense_humid = adafruit_sht31d.SHT31D(i2c)
15+
sense_barometric = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)
16+
sense_magnet = adafruit_lis3mdl.LIS3MDL(i2c)
17+
18+
print("This is BroadcastNet Feather Sense sensor:", adafruit_ble_broadcastnet.device_address)
19+
20+
while True:
21+
measurement = adafruit_ble_broadcastnet.AdafruitSensorMeasurement()
22+
23+
measurement.temperature = sense_barometric.temperature
24+
measurement.pressure = sense_barometric.pressure
25+
measurement.relative_humidity = sense_humid.relative_humidity
26+
measurement.acceleration = sense_accel.acceleration
27+
measurement.magnetic = sense_magnet.magnetic
28+
29+
# print(measurement)
30+
adafruit_ble_broadcastnet.broadcast(measurement)
31+
time.sleep(60)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import time
2+
import board
3+
import digitalio
4+
import analogio
5+
from adafruit_clue import clue
6+
7+
# Turn off the NeoPixel
8+
clue.pixel.fill(0)
9+
10+
# Motor setup
11+
motor = digitalio.DigitalInOut(board.P2)
12+
motor.direction = digitalio.Direction.OUTPUT
13+
14+
# Soil sense setup
15+
analog = analogio.AnalogIn(board.P1)
16+
17+
def read_and_average(analog_in, times, wait):
18+
analog_sum = 0
19+
for _ in range(times):
20+
analog_sum += analog_in.value
21+
time.sleep(wait)
22+
return analog_sum / times
23+
24+
clue_display = clue.simple_text_display(title=" CLUE Plant", title_scale=1, text_scale=3)
25+
clue_display.show()
26+
27+
while True:
28+
# Take 100 readings and average them
29+
analog_value = read_and_average(analog, 100, 0.01)
30+
# Calculate a percentage (analog_value ranges from 0 to 65535)
31+
percentage = analog_value / 65535 * 100
32+
# Display the percentage
33+
clue_display[0].text = "Soil: {} %".format(int(percentage))
34+
# Print the values to the serial console
35+
print((analog_value, percentage))
36+
37+
if percentage < 50:
38+
motor.value = True
39+
clue_display[1].text = "Motor ON"
40+
clue_display[1].color = (0, 255, 0)
41+
time.sleep(0.5)
42+
43+
# always turn off quickly
44+
motor.value = False
45+
clue_display[1].text = "Motor OFF"
46+
clue_display[1].color = (255, 0, 0)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Bonsai Buckaroo + CLUE Plant Care Bot
2+
3+
import time
4+
import board
5+
from digitalio import DigitalInOut, Direction
6+
from analogio import AnalogIn
7+
from adafruit_clue import clue
8+
from adafruit_display_text import label
9+
import displayio
10+
import terminalio
11+
import pulseio
12+
13+
moist_level = 50 # adjust this value as needed for your plant
14+
15+
board.DISPLAY.brightness = 0.8
16+
clue.pixel.fill(0) # turn off NeoPixel
17+
18+
clue_display = displayio.Group(max_size=4)
19+
20+
# draw the dry plant
21+
dry_plant_file = open("dry.bmp", "rb")
22+
dry_plant_bmp = displayio.OnDiskBitmap(dry_plant_file)
23+
dry_plant_sprite = displayio.TileGrid(dry_plant_bmp, pixel_shader=displayio.ColorConverter())
24+
clue_display.append(dry_plant_sprite)
25+
26+
# draw the happy plant on top (so it can be moved out of the way when needed)
27+
happy_plant_file = open("happy.bmp", "rb")
28+
happy_plant_bmp = displayio.OnDiskBitmap(happy_plant_file)
29+
happy_plant_sprite = displayio.TileGrid(happy_plant_bmp, pixel_shader=displayio.ColorConverter())
30+
clue_display.append(happy_plant_sprite)
31+
32+
# Create text
33+
# first create the group
34+
text_group = displayio.Group(max_size=3, scale=3)
35+
# Make a label
36+
title_label = label.Label(terminalio.FONT, text="CLUE Plant", color=0x00FF22)
37+
# Position the label
38+
title_label.x = 10
39+
title_label.y = 4
40+
# Append label to group
41+
text_group.append(title_label)
42+
43+
soil_label = label.Label(terminalio.FONT, text="Soil: ", color=0xFFAA88, max_glyphs=10)
44+
soil_label.x = 4
45+
soil_label.y = 64
46+
text_group.append(soil_label)
47+
48+
motor_label = label.Label(terminalio.FONT, text="Motor off", color=0xFF0000, max_glyphs=9)
49+
motor_label.x = 4
50+
motor_label.y = 74
51+
text_group.append(motor_label)
52+
53+
clue_display.append(text_group)
54+
board.DISPLAY.show(clue_display)
55+
56+
motor = DigitalInOut(board.P2)
57+
motor.direction = Direction.OUTPUT
58+
59+
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
60+
buzzer.frequency = 1000
61+
62+
sense_pin = board.P1
63+
analog = AnalogIn(board.P1)
64+
65+
def read_and_average(ain, times, wait):
66+
asum = 0
67+
for _ in range(times):
68+
asum += ain.value
69+
time.sleep(wait)
70+
return asum / times
71+
72+
time.sleep(5)
73+
74+
while True:
75+
# take 100 readings and average them
76+
aval = read_and_average(analog, 100, 0.01)
77+
# calculate a percentage (aval ranges from 0 to 65535)
78+
aperc = aval / 65535 * 100
79+
# display the percentage
80+
soil_label.text = "Soil: {} %".format(int(aperc))
81+
print((aval, aperc))
82+
83+
if aperc < moist_level:
84+
happy_plant_sprite.x = 300 # move the happy sprite away
85+
time.sleep(1)
86+
motor.value = True
87+
motor_label.text = "Motor ON"
88+
motor_label.color = 0x00FF00
89+
buzzer.duty_cycle = 2**15
90+
time.sleep(0.5)
91+
92+
# always turn off quickly
93+
motor.value = False
94+
motor_label.text = "Motor off"
95+
motor_label.color = 0xFF0000
96+
buzzer.duty_cycle = 0
97+
98+
if aperc >= moist_level:
99+
happy_plant_sprite.x = 0 # bring back the happy sprite

Buckaroo_Plant_Care_Bot/dry.bmp

113 KB
Binary file not shown.

Buckaroo_Plant_Care_Bot/happy.bmp

113 KB
Binary file not shown.

Burning_Fire_Wizard_Staff/README.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Burning_Fire_Wizard_Staff
2+
3+
Code to accompany this tutorial:
4+
https://learn.adafruit.com/burning-fire-wizard-staff
5+
6+
Prop-Maker based Burning Wizard Staff
7+
Adafruit invests time and resources providing this open source code.
8+
Please support Adafruit and open source hardware by purchasing
9+
products from Adafruit!
10+
Written by Kattni Rembor, Erin St Blaine & Limor Fried for Adafruit Industries
11+
Copyright (c) 2020 Adafruit Industries
12+
Licensed under the MIT license.
13+
All text above must be included in any redistribution.

0 commit comments

Comments
 (0)