This device was designed to perform several different functions, namely reading sensor values, sending them to a client over BLE, and show the current sound level.
General view | BLE interface | |
Because the project is based on the Thunderboard Sense 2, most of the hardware is already on the kit, including:
I also created a shield that fits onto the pin headers, and its 74HC595 shift register is responsible for taking a serial signal and outputting it to the 8 LEDs on top.
Schematic | Assembly | |
The software was developed using Simplicity Studio 5. The program begins by initializing the BLE stack, along with all the needed sensors and pins. In the main loop, the sound level is retrieved from the microphone, converted to an integer, and sent to the set_led_sound_level() function that sends 8 total signals to the shield's shift register. When a 1 is to be set, the data pin is set high, the clock pin is toggled, and then the data pin is set to low. For a 0, the data pin is low, and the clock is repeatedly toggled. Finally, the latch pin is toggled to display the result.
Once a Bluetooth device connects to the BLE GATT server, its connection handle is saved, and a timer is started that causes the sensor values to be updated once every second. The temperature characteristic has a descriptor that lets clients set if indications are enabled, and if they are, the temperature is indicated at this time as well.
This was a fun project to build, as I got to explore in more detail about how BLE GATT works and what it does to communicate with client devices. One issue I encountered was that the LEDs would not show anything even though I had tested the shield on a different platform previously. I was able to solve it by looking more closely at the datasheet and seeing that the 74HC595 can run at a maximum of 25MHz, yet the EFR32MG12 was outputting signals at around 40MHz, so a simple microsecond delay fixed this. Overall, this project taught me more about BLE and how to read data from various sensors.
Last modified:Mon, Jan 23, 2023.