Accurately identify and monitor the presence of methane gas to prevent potential hazards such as explosions, fires, and environmental damage
A
A
Hardware Overview
How does it work?
Methane Click is based on the MQ-4 methane (CH4) sensor from Zhengzhou Winsen Electronics Technology, which detects methane's presence and concentration in the air. The gas sensing layer on the MQ-4 sensor unit is made of Tin dioxide (SnO2), which has lower conductivity in clean air. The conductivity increases as the levels of methane rise. It has a high sensitivity to methane in a wide range suitable for detecting it in concentrations from 200 to 10.000ppm. Besides a binary indication of the presence of methane, the
MQ-4 also provides an analog representation of its concentration in the air sent directly to an analog pin of the mikroBUS™ socket labeled OUT. The analog output voltage the sensor provides varies in proportion to the methane concentration; the higher the methane concentration in the air, the higher the output voltage. Methane Click has a small potentiometer that allows you to adjust the load resistance of the sensor circuit, to calibrate the sensor for the environment in which you'll be using it. For precise calibration, the sensor must preheat
(once powered up, it takes 24h to reach the right temperature). This Click board™ can be operated only with a 5V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.
Features overview
Development board
UNI Clicker is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It supports a wide range of microcontrollers, such as different ARM, PIC32, dsPIC, PIC, and AVR from various vendors like Microchip, ST, NXP, and TI (regardless of their number of pins), four mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a debugger/programmer connector, and two 26-pin headers for interfacing with external electronics. Thanks to innovative manufacturing technology, it allows you to build
gadgets with unique functionalities and features quickly. Each part of the UNI Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the UNI Clicker programming method, using a third-party programmer or CODEGRIP/mikroProg connected to onboard JTAG/SWD header, the UNI Clicker board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Type-C (USB-C) connector, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or using a Li-Po/Li
Ion battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board (plus USB HOST/DEVICE), including the well-established mikroBUS™ socket, a standardized socket for the MCU card (SiBRAIN standard), and several user-configurable buttons and LED indicators. UNI Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Type
8th Generation
Architecture
ARM Cortex-M4
MCU Memory (KB)
160
Silicon Vendor
NXP
Pin count
32
RAM (Bytes)
16384
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.
After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.
Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.
Software Support
Library Description
This library contains API for Methane Click driver.
Key functions:
methane_read_an_pin_value
- Methane read AN pin value function.methane_read_an_pin_voltage
- Methane read AN pin voltage level function.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief Methane Click Example.
*
* # Description
* The demo application shows the reading of the adc
* values given by the sensors.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configuring clicks and log objects.
*
* ## Application Task
* Reads the adc value and prints in two forms adc value and voltage.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "methane.h"
static methane_t methane; /**< Methane Click driver object. */
static log_t logger; /**< Logger object. */
void application_init ( void ) {
log_cfg_t log_cfg; /**< Logger config object. */
methane_cfg_t methane_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
methane_cfg_setup( &methane_cfg );
METHANE_MAP_MIKROBUS( methane_cfg, MIKROBUS_1 );
if ( methane_init( &methane, &methane_cfg ) == ADC_ERROR ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void ) {
uint16_t methane_an_value = 0;
if ( methane_read_an_pin_value ( &methane, &methane_an_value ) != ADC_ERROR ) {
log_printf( &logger, " ADC Value : %u\r\n", methane_an_value );
}
float methane_an_voltage = 0;
if ( methane_read_an_pin_voltage ( &methane, &methane_an_voltage ) != ADC_ERROR ) {
log_printf( &logger, " AN Voltage : %.3f[V]\r\n\n", methane_an_voltage );
}
Delay_ms( 1000 );
}
void main ( void ) {
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END