With all the various sensors out there to choose from, it is nice to be able to get one that is configured in such a way that you can evaluate its performance. MikroE Click Boards offer just that opportunity and on several development boards that Avnet distributes, MicroBUS host sockets are included. These sockets allow MikroE Click Boards to be attached and driven using the development boards processor. To review the variety of click boards that are available, please see MikoE Click Boad Catalog.
Of course the hardware for sensor evaluation is just one part of the problem, the other is the software that is needed to drive the sensor. To assist with the software needed to evaluate the various MikroE Click Boards, Avnet offers a github repository of reusable software along with demonstration programs showing how the library is utilized. In following blog, I go through the software that is available in the github repository and in subsequent blogs, I show several example programs that use the repository and discuss how you can replicate them.
The current repository at https://github.com/Avnet/clickmodules (release v1.0) contains support for the following Click Boards. This repository can be replicated into your own project by using the command
git clone -b v1.0 https://github.com/Avnet/clickmodules
This command will retrieve release 1 of the click module repository which includes support for:
1. Barometer Click Barometer Click
2. FLAME ClickFLAME Click
3. HEART RATE 4 ClickHEART RATE 4 Click
4. LIGHTRANGER Click LIGHTRANGER Click
5. OLED-B ClickOLED-B Click
6. RELAY ClickRELAY Click
7. Temp&Hum Temp&Hum
The software is written in ANSI standard C (to maximize the ability to reuse the software) but a few C++ solutions are also provided (C++ support exits for BAROMETER, TEMP_HUM, and FLAME click boards).
The basic approach for all sensors is to implement a framework to create and remove sensor objects. This framework provides functions to:
- Abstract all I/O with the sensor. When the sensor is created, the user provides functions that write to the sensor, read from the sensor, and (if necessary) initialize the sensor I/O. The currently supported sensors require a variety of I/O methods, shown in Table 1.
- Create a sensor object, typically ‘<xxx>_open’. This function will allocate needed memory and capture the user supplied function address(s) to be called for sensor input and output. The function returns a pointer to a unique object that is used in subsequent sensor function calls.
For example, the BAROMETER sensor contains the following function:
BAROMETER* open_barometer(uint8_t (*rb)(uint8_t a), void (*wb)(uint8_t a, uint8_t v ))
The user provides a read-byte and write-byte function for the sensor. The read-byte function needs a register address to write to and returns the byte that was read. The write-byte function expects a register address and a value to write to the register.
- Delete a sensor object, ‘close_<xxx>’. - This function eleases allocated memory from when the sensor was opened. For example, using the BAROMETER sensor example from above:
close_barometer(BAROMETER* b)
So when called, the function free’s the memory allocated for the BAROMETER object. It is important to note that the close function simply releases the BAROMETER object memory so if If any sensor settings need resetting when closing, the user to perform these actions separately.
Support functionality/functions are dependent on the Click board/Sensor being supported to reference the associated header file for specifics.
Table 1: Click Modules Currently Supported
Click Board Name | Sensor Utilized | Source Code Included | I/O utilized |
---|---|---|---|
barometer.c; barometer.h; barometer.hpp | I2C | ||
hts221.c; hts221.h; hts221.hpp | I2C | ||
All under LIGHTRANGER | I2C | ||
flame.c; flame.h; flame.hpp | GPIO | ||
algorithm_by_RF.c; algorithm_by_RF.h; max30102.c; max30102.h | I2C | ||
relay.c; relay.h | GPIO | ||
Avnet_GFX.c; Avnet_GFX.h; glcdfont.c; oledb.hpp; oledb_ssd1306.c; oledb_ssd1306.h | SPI |
[1] see https://www.instructables.com/id/Pulse-Oximeter-With-Much-Improved-Precision/ for a description of the HR4 algorithm
To demonstrate the usage of the Click module library, it has been ported and used across three different hardware platforms:
Board | Click Modules Tested |
---|---|
FLAME, RELAY, OLED-B, BAROMETER, TEMP&HUMI, LightRanger2, HEARTRATE4 | |
FLAME[2], RELAY, OLED-B, BAROMETER, TEMP&HUMI, LightRanger2, HEARTRATE4 | |
FLAME[2], RELAY[2], BAROMETER, TEMP&HUMI, LightRanger2, HEARTRATE4 |
[2] Partially implementation on this platform
Avnet has Incorporated the Click Board footprints into their evaluation boards so users can easily add a variety of sensors using publicly available platforms. Additionally, Avnet has made available open-source software for the click-board sensors which compile with both open-source and proprietary tool chains. Leveraging these development boards and software, you can expedite implementing/evaluating sensors in your designs while not being locked into a particular development environment or platform. Please provide feedback on how we can continue to assist in your next project.
In the next blog, implementing example sensor collection systems on these three platforms is discussed as well as any limitations that were encountered.