Skip to content

Commit 8fef025

Browse files
Silicon Labs CircuitPython Applications v1.3.0
1 parent 8e434d9 commit 8fef025

File tree

18 files changed

+181
-21
lines changed

18 files changed

+181
-21
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# Silicon Labs CircuitPython Applications #
1515

16-
[![Version Badge](https://img.shields.io/badge/-v1.2.1-green)](https://github.com/SiliconLabs/circuitpython_applications/releases)
16+
[![Version Badge](https://img.shields.io/badge/-v1.3.0-green)](https://github.com/SiliconLabs/circuitpython_applications/releases)
1717
[![CircuitPython](https://img.shields.io/badge/CircuitPython-v8.2.0+-green)](https://circuitpython.org/downloads?q=silabs)
1818
![License badge](https://img.shields.io/badge/License-Zlib-green)
1919

@@ -24,14 +24,16 @@ All examples in this repository are considered to be EXPERIMENTAL QUALITY, which
2424

2525
| No | Example name | Link to example |
2626
|:--:|:-------------|:---------------:|
27-
| 1 | CircuitPython - Bluetooth - Distance Monitor (VL53L1X) | [Click Here](./cp_bluetooth_distance_monitor)|
28-
| 2 | CircuitPython - Bluetooth - Environmental Sensing (CCS811/BME280) | [Click Here](./cp_bluetooth_environmental_sensing) |
29-
| 3 | CircuitPython - Bluetooth - Neopixel Humidity Gauge (SHTC3) | [Click Here](./cp_bluetooth_neopixel_humidity_gauge) |
30-
| 4 | CircuitPython - Bluetooth - Light Detector (AS7265x) | [Click Here](./cp_bluetooth_light_detector) |
31-
| 5 | CircuitPython - Non-Wireless Display Demo (IS31FL3741) | [Click Here](./cp_non_wireless_display_demo) |
32-
| 6 | CircuitPython - RGB Display Drawing (ILI9341) | [Click Here](./cp_rgb_display_drawing_ili9341) |
33-
| 7 | CircuitPython - Temperature and Humidity Monitor with LED Matrix Display (SI2071/IS31FL3741) | [Click Here](./cp_temperature_and_humidty_monitor) |
34-
| 8 | CircuitPython - xG24 Dev Kit Sensors (ILI9341) | [Click Here](./cp_xg24_dev_kit_sensors) |
27+
| 1 | CircuitPython - Bluetooth - SoC - Blinky | [Click Here](./cp_bluetooth_blinky) |
28+
| 2 | CircuitPython - Bluetooth - Distance Monitor (VL53L1X) | [Click Here](./cp_bluetooth_distance_monitor)|
29+
| 3 | CircuitPython - Bluetooth - Environmental Sensing (CCS811/BME280) | [Click Here](./cp_bluetooth_environmental_sensing) |
30+
| 4 | CircuitPython - Bluetooth - Neopixel Humidity Gauge (SHTC3) | [Click Here](./cp_bluetooth_neopixel_humidity_gauge) |
31+
| 5 | CircuitPython - Bluetooth - Light Detector (AS7265x) | [Click Here](./cp_bluetooth_light_detector) |
32+
| 6 | CircuitPython - Non-Wireless Display Demo (IS31FL3741) | [Click Here](./cp_non_wireless_display_demo) |
33+
| 7 | CircuitPython - RGB Display Drawing (ILI9341) | [Click Here](./cp_rgb_display_drawing_ili9341) |
34+
| 8 | CircuitPython - Temperature and Humidity Monitor with LED Matrix Display (SI2071/IS31FL3741) | [Click Here](./cp_temperature_and_humidty_monitor) |
35+
| 9 | CircuitPython - xG24 Dev Kit Sensors (ILI9341) | [Click Here](./cp_xg24_dev_kit_sensors) |
36+
3537

3638

3739
## Get CircuitPython firmware ##

cp_bluetooth_blinky/README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# CircuitPython - Bluetooth - SoC - Blinky #
2+
3+
![Type badge](https://img.shields.io/badge/dynamic/json?url=https://raw.githubusercontent.com/SiliconLabs/application_examples_ci/master/circuitpython/cp_bluetooth_blinky_common.json&label=Type&query=type&color=green)
4+
![Technology badge](https://img.shields.io/badge/dynamic/json?url=https://raw.githubusercontent.com/SiliconLabs/application_examples_ci/master/circuitpython/cp_bluetooth_blinky_common.json&label=Technology&query=technology&color=green)
5+
![License badge](https://img.shields.io/badge/dynamic/json?url=https://raw.githubusercontent.com/SiliconLabs/application_examples_ci/master/circuitpython/cp_bluetooth_blinky_common.json&label=License&query=license&color=green)
6+
## Overview ##
7+
8+
This example application is the "Hello World" of Bluetooth Low Energy (BLE). It allows a BLE central device to control the LED on the mainboard and receive button press notifications.
9+
10+
## Hardware Required ##
11+
12+
- [EFR32xG24 Dev Kit](https://www.silabs.com/development-tools/wireless/efr32xg24-dev-kit?tab=overview)
13+
14+
## Connections Required ##
15+
16+
Power the EFR32xG24 Dev Kit with a micro-usb cable connected to a usb port on a laptop or an USB Charger
17+
18+
## Prerequisites ##
19+
20+
Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpython.md).
21+
22+
## Setup ##
23+
24+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
25+
26+
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
27+
28+
> **_NOTE:_** The examples in this repository require CircuitPython v8.2.0 or higher.
29+
30+
2. Upload all the files and folders from the device_root folder to the CircuitPython device. The files and folders should be copied into the root of the file system on the target device.
31+
32+
3. Run the scripts on the board.
33+
34+
## How it Works ##
35+
36+
### Getting started ###
37+
38+
This example implements a simple custom GATT service with two characteristics. One characteristic controls the state of the LED (ON/OFF) via write operations from a GATT client, and the second characteristic sends notifications to subscribed clients when the button state changes (pressed or released).
39+
40+
To test this demo, install EFR Connect for [Android](https://play.google.com/store/apps/details?id=com.siliconlabs.bledemo&hl=en&gl=US) or [iOS](https://apps.apple.com/us/app/efr-connect/id1030932759). Source code for the mobile app is available on [Github](https://github.com/SiliconLabs?q=efrconnect&type=&language=&sort=).
41+
42+
After launching the app go to the demo view and select the Blinky demo. A pop-up will show all the devices around you that are running the SoC-Blinky firmware. Tap on the device to go into the demo view.
43+
44+
![Demo view](docs/efr_connect1.jpg) ![Pop up](docs/efr_connect2.jpg)
45+
46+
Tap the light on the mobile app to toggle the LED on the mainboard. When you press/release the button on the mainboard the state changes for the virtual button on the app as well.
47+
48+
![Blinky all off](docs/efr_connect3.jpg) ![Blinky all on](docs/efr_connect4.jpg)
49+
50+
### GATT database ###
51+
52+
- [Service] Blinky Example
53+
- [Char] LED Control - led_control
54+
- [R] Get LED status
55+
- [W] Set LED on/off
56+
- [Char] Report Button - report_button
57+
- [R, N] Get button status
58+
59+
## Output ##
60+
61+
The animation below showcases the demo running on a EFR32xG24 Dev Kit (BRD2601B) with the mobile app running on an Android device.
62+
63+
![Radio board power supply switch](docs/result.gif)
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import digitalio
2+
import board
3+
from adafruit_ble import BLERadio
4+
from BlinkyApp import BlinkyApp
5+
from BlinkyService import BlinkyService
6+
7+
DEVICE_NAME = 'Blinky Example'
8+
9+
10+
# application init
11+
app = BlinkyApp(
12+
BlinkyService(),
13+
BLERadio(),
14+
board.LEDG,
15+
board.BTN0
16+
)
17+
18+
# config the advertisement
19+
app.configure_advertisement(DEVICE_NAME)
20+
21+
# start looping the main function
22+
while True:
23+
app.main_function()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from adafruit_ble.advertising.standard import Advertisement
2+
from adafruit_ble import BLERadio
3+
import digitalio
4+
import board
5+
6+
7+
class BlinkyApp():
8+
def __init__(self,
9+
service: BlinkyService,
10+
ble: BLERadio,
11+
led_pin: microcontroller.Pin,
12+
button_pin: microcontroller.Pin) -> None:
13+
self.service = service
14+
self.adv = Advertisement()
15+
self.ble = ble
16+
self.button = digitalio.DigitalInOut(button_pin)
17+
self.button.direction = digitalio.Direction.INPUT
18+
self.led = digitalio.DigitalInOut(led_pin)
19+
self.led.direction = digitalio.Direction.OUTPUT
20+
21+
22+
def configure_advertisement(self,
23+
device_name,
24+
connectable = True) -> None:
25+
self.adv.short_name = device_name
26+
self.adv.connectable = connectable
27+
28+
def main_function(self):
29+
if not self.ble.connected and not self.ble.advertising:
30+
print('>>> Start advertising')
31+
self.ble.start_advertising(self.adv)
32+
33+
if self.ble.connected:
34+
if self.ble.advertising:
35+
self.ble.stop_advertising()
36+
print('>>> Connected, stop advertising')
37+
38+
if self.service.report_button != int(self.button.value):
39+
self.service.report_button = int(self.button.value)
40+
print("Button: {0}".format(int(self.button.value)))
41+
42+
if self.service.led_control == 0 and self.led.value == False:
43+
self.led.value = True
44+
print("LED on.");
45+
elif self.service.led_control == 1 and self.led.value == True:
46+
self.led.value = False
47+
print("LED off.");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from adafruit_ble.services import Service
2+
from adafruit_ble.uuid import VendorUUID
3+
from adafruit_ble.attributes import Attribute
4+
from adafruit_ble.characteristics import Characteristic
5+
from adafruit_ble.characteristics.int import Uint8Characteristic
6+
7+
class BlinkyService(Service):
8+
uuid = VendorUUID('de8a5aac-a99b-c315-0c80-60d4cbb51224')
9+
10+
led_control = Uint8Characteristic(
11+
uuid = VendorUUID('5b026510-4088-c297-46d8-be6c736a087a'),
12+
properties = (Characteristic.READ | Characteristic.WRITE),
13+
write_perm = Attribute.NO_ACCESS,
14+
)
15+
16+
report_button = Uint8Characteristic(
17+
uuid = VendorUUID('61a885a4-41c3-60d0-9a53-6d652a70d29c'),
18+
properties = (Characteristic.READ | Characteristic.NOTIFY),
19+
write_perm = Attribute.NO_ACCESS,
20+
)
21+
22+
23+
def __init__(self, service=None):
24+
super().__init__(service=service)
25+
self.connectable = True
46 KB
Loading
32.2 KB
Loading
23.6 KB
Loading
28.5 KB
Loading

cp_bluetooth_blinky/docs/result.gif

1.42 MB
Loading

cp_bluetooth_distance_monitor/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
2929

3030
## Setup ##
3131

32-
To run the example you need to install **Thonny** editor and then follow the steps below:
32+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
3333

3434
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
3535

@@ -81,4 +81,4 @@ To run the example you need to install **Thonny** editor and then follow the ste
8181

8282
Run the **code.py** file, monitor the OLED, and try to place your hand beyond the sensor you will see the result below.
8383

84-
![result](docs/result.GIF)
84+
![result](docs/result.GIF)

cp_bluetooth_environmental_sensing/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
4545

4646
## Setup ##
4747

48-
To run the example you need to install **Thonny** editor and then follow the steps below:
48+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
4949

5050
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
5151

cp_bluetooth_light_detector/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
5151

5252
## Setup ##
5353

54-
To run the example you need to install **Thonny** editor and then follow the steps below:
54+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
5555

5656
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
5757

@@ -130,4 +130,4 @@ Sensor Shell
130130

131131
![sensor_result](docs/sensor_result.png)
132132

133-
From the log and picture, you can see that value of the violet channel is the highest so the brightness of the violet LEDs group is also the highest, the red channel has the lowest value so the red LEDs group also has the lowest brightness, similar to other channels.
133+
From the log and picture, you can see that value of the violet channel is the highest so the brightness of the violet LEDs group is also the highest, the red channel has the lowest value so the red LEDs group also has the lowest brightness, similar to other channels.

cp_bluetooth_neopixel_humidity_gauge/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The gathered humidity data is displayed on the connected NeoPixel Ring.
3939

4040
## Setup ##
4141

42-
To run the example you need to install **Thonny** editor and then follow the steps below:
42+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
4343

4444
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
4545

cp_non_wireless_display_demo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
2828

2929
## Setup ##
3030

31-
To run the example you need to install **Thonny** editor and then follow the steps below:
31+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
3232

3333
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
3434

cp_rgb_display_drawing_ili9341/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
4545

4646
## Setup ##
4747

48-
To run the example you need to install **Thonny** editor and then follow the steps below:
48+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
4949

5050
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
5151

@@ -81,4 +81,4 @@ Run the **code.py** file.
8181
- You can start to draw or pick color by tab the color you want in color pallete and the present pen color will show in small rectangle at the top left of screen.
8282
- Or you can clear all the screen by tab the Silabs logo.
8383

84-
![result](docs/result.gif)
84+
![result](docs/result.gif)

cp_temperature_and_humidty_monitor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
2929

3030
## Setup ##
3131

32-
To run the example you need to install **Thonny** editor and then follow the steps below:
32+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
3333

3434
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
3535

cp_xg24_dev_kit_sensors/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Getting started with [CircuitPython on EFR32 boards](../doc/running_circuitpytho
3838

3939
## Setup ##
4040

41-
To run the example you need to install **Thonny** editor and then follow the steps below:
41+
To run the example you need to install **[Thonny](https://thonny.org/)** editor and then follow the steps below:
4242

4343
1. Flash the corresponding CircuitPython binary for your board. You can visit [circuitpython.org/downloads](https://circuitpython.org/downloads?q=silabs) to download the binary.
4444

@@ -77,4 +77,4 @@ After you powered the devices, the boot screen is visible for 5 seconds. Then th
7777

7878
You can run the code.py file or press the Reset button. On the display, you will see the result below:
7979

80-
![demo](docs/demo.gif)
80+
![demo](docs/demo.gif)

0 commit comments

Comments
 (0)