Hello everyone, here I am again, but this time with a complete project entry to SensorTile contest! Ohaaaay!
But as usual, due to Brazilian logistics to deliver a simple hardware in my home, again it arrived to me with only 5 days remaining to the contest's deadline.
So, what I've built here? Simple my goal is to provide a sensor node which helps the Beekeepers to perform his Bee culture tasks more safe, more than that I want to reduce Bee mortality which basically impacts in two points:
- Reducing mortality means more Bees working on flower pollination, so more fruits and positive impact in food supply for everyone;
- Helps the beekeepers to avoid losing his beehives due to high Bee mortality and keeping the honey extraction productivity stable or maximize it.
The result of the work? Well this will you get if you read and perform the steps described below, don't worry! The project is not over complex! And I'm certain you will have a lot of fun with this sensor:
So, how it works?Before entering in details of this project, we need to understand the fundamentals of monitoring sound of Bees, the first aspect, the Bees perform different sound emission, with different means, the interest for us is the Hissing sound, which basically translates it's aggressiveness level.
According to some references (placed in the end) the hissing level is placed around the 3K audible band, in some cases with +- 200Hz of bandwidth. So the idea, monitor the hissing and tell to BeeKeeper through some UI, or a Android App how aggressive that Beehive currently is. Where the SensorTile cames into play the combination of low power microphone, a Cortex M4F CPU and a easy to use BlueNRG module performed the trick like a charm!
The signal flow is simple, the SensorTile microphone outputs the audio captured, through a PDM mechanism, the on board MCU, capture it and send to DFSDM, which is a kind of sigma-delta demodulator which extracts the RAW 16-bit PCM formatted audio signal, with this samples set the firmware send the buffer to a real Fast-Fourier-Transform block followed by a magnitude computing block, this can be possible with the hardware enabled float point unit of the Microcontroller (a popular STM32L4 family), with the magnitude a simple search on 3KHz frequency range is made and RMS is obtained, this is the continuous behavior of the called BeeDSP firmware module.
The communication module uses the Bluetooth Low Energy to transmit the measured result, to perform it, the BlueNRG ACI stack is used to setup the BLE and add a service called Bee service which has a 4 byte sized characteristic, which notify the peer device (a Android Phone) about a new hissing level measured.
The phone application, scans for a LittleBee device, and only connects to LittleBee devices, after to discover a available device it immediately will accept notifications on Bee service, then takes the read values and plot on a graph created with Graph View widget. See some pictures of the system running:
The application uses a real time chart which is updated periodically (which a 100ms refresh rate), the purpose of the UI is to have the primary monitoring of hissing level, so no custom UI was provided, of course the source code of the app is open and free to use as own!
Cool! Help me to build one!?So, now is the time to instruct how you can deploy this powerful sensor intended (but not limited to) Bee environments. The first instruction, is to get the both development enviroments, the attolic true studio to develop the firmware, it was chosen because it is free and is a professional grade and stable IDE to program the devices. The android studio was selected for obvious reasons to develop the mobile app.
Opening the True Studio you will see a screen like this below:
The first task to deploy the firmware component is to obtain the source code, you can find it on my github, the project is complete with dependences resolved in relative path, so you only need to navigate the True Studio then File->Import, in the popup select the: Existing projects on workspace, untick the option copy the project on workspace, the find the root project folder where you downloaded from Github.
Now you're asking yourself: "Hey, whats is the purpose of the Núcleo Board on the components list?"
The short anwser, have you noted the SensorTile kit does not come with a flasher or debugger? Yes, it doesn't! You need a external tool to flash the firmware, another option is to use the USB port located on expansion audio board of the kit and flash firmware through DFU tools, but it seems a complicated and unecessary step since the Nucleo boards are extremely cheap and easy to find. So pick one, connects it to USB, don't worry about the debug settings this was already configured on project settings (Let's follow the KISS philosophy - Keep It Simple, Stupid!). Now go back to the SensorTile kit. As you noted, it is composed by some items, 4 are very important here:
- The SensorTile itself (Really, Felipe? XD );
- The battery expansion cradle;
- The plastic case (I'm serious the full assembled sensor becomes very charming in the case);
- The battery, we don't want wires.
We now will assemble the only hardware demanding step, in all you will have something like this:
So, bring the soldering Iron and the:
Note it's edges, this is a castellation like pads, it is very simple to solder, bring the expansion battery cradle below:
Note the header on the edges, this one is used to program or debug the firmware through microcontroller's SWD port, this is another reason that I indicated the NucleoBoards, it has a pin compatible header for external devices, this will eases the firmware deploying!
Now with a soldering iron, and some soldering, carefully solder the castellation pads on cradle pads, WARNING! Take care with the SensorTile position, make sure the pin 1 of the cradle matches with the pin 1 of the sensor, otherwise the things will get hot!
After performing the solder will you get the following:
Check carefully the soldering to find open and short circuits, make use of a multimeter using the lowest resistance measurement range to help you. Now just pick the battery and plug it on the connector, and in the last step pick the plastic case and put the sensor board with battery into it, use a screw to close the plastic case.
This is the only hardware step required now we will perform the deploy, so pick two USB cable, one mini to Nucleo board and a micro one to SensorTile board, also pick the programming cable:
Then connect all the USB and the programming cable on Nucleo external debuggers, WARNING! Don't forget to open the CN2 jumper, it will allow to use the STLINK debugger with external targets. The connections will be like this:
Mind the pin 1 of the sensor node, it is marked as a squared pad on bottom of header connector! match it with the pin 1 of the Nucleo board, then turn-on the on-off switch. Go back to True Studio, with the project imported, just hit CTRL+B to build the workspace, you will see a couple of warnings, don't worry about them, it related to cmsis SIMD functions which is not used, only the FFT and magnitude was used from CMSIS DSP Lib to perform the calculations. Upon a successful build, then hit F11 to debug and download the firmware, now let's celebrate, the firmware seems to be running, if you want to see BLE traffic just obatain some BLE scan tool app, you will be able to connect to LittleBee sensor!
For the application part, the steps are even simpler, first obtain the source code here on my github, after open the Android Studio, use the import option below and search where project was downloaded:
And that's it the project will be in the workspace, so just connect you Android device, go to Build->Rebuild project. Wait a bit, it seems a successful build as same the firmware, now deploy the application to device using Run->Run App, this will download the application using the Android Debug Bridge, for mobile developers very known as ADB and will start immediately.
...and that's it! Your LittleBee is ready to use! So go to a apiary, leave the sensor and start to explore the Bee emitted sound and it means. As a hacking suggestion you can go on firmware and modify the frequency bin data picks to another value and will sendo to App another type of sound emitted! Just go back on firmware open the file bee_dsp.c , then go to line 70 and select a new index each index corresponds to frequency in steps of 92Hz.
Some conclusionsThis project was submitted originally to ST SensorTile contest, my main challenge in this project was to put my hands on hardware on time of contest's deadline, but I only received it with some days remaining, the solution was to keep the scope simpler and show a good deliver ready to be a commercial or even a open source mass production device. The application has a simple and intuitive interface and it is scalable to be integrated on cloud! The firmware in other hand is even more powerful, today only a simple searching on frequency bins is performed, but the current spectrum is always retained on RAM to perform more complex analysis, as a future improvements, we want to add the swarm audio, which indicates how many work the Bees are doing on the beehive. I hope you enjoyed reading this or reproducing it, contributions are always welcome, and we released the stuff of project under MIT contents to incentive all the BeeKeepers to install this system and help to perform Bee culture a more sustainable activity!
Comments