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
EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development 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
Architecture
PIC
MCU Memory (KB)
48
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
3328
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via UART Mode
1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.
2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.
3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.
4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
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