Difference between revisions of "Template:MQ-2 Gas Sensor STM32 Guide"

From Waveshare Wiki
Jump to: navigation, search
(Created page with "The examples provided are based on the STM32F103RBT6 and the STM32H743, the connection provided is based on the STM32F103RB. <br /> If you want to use other STM32 boards, plea...")
 
 
Line 1: Line 1:
 
The examples provided are based on the STM32F103RBT6 and the STM32H743, the connection provided is based on the STM32F103RB. <br />
 
The examples provided are based on the STM32F103RBT6 and the STM32H743, the connection provided is based on the STM32F103RB. <br />
 
If you want to use other STM32 boards, please change the connection and you may need to port the codes yourself.<br />
 
If you want to use other STM32 boards, please change the connection and you may need to port the codes yourself.<br />
 +
=STM32=
 
==Hardware connection==
 
==Hardware connection==
 
[[File:MQ STM32 1.jpg|400px|thumb|right|Hardware connection-STM32]]
 
[[File:MQ STM32 1.jpg|400px|thumb|right|Hardware connection-STM32]]

Latest revision as of 01:59, 19 July 2022

The examples provided are based on the STM32F103RBT6 and the STM32H743, the connection provided is based on the STM32F103RB.
If you want to use other STM32 boards, please change the connection and you may need to port the codes yourself.

STM32

Hardware connection

Hardware connection-STM32
Connect to STM32F103RBT6
MQ2 STM32 Description
VCC 3.3V Power input
GND GND Ground
AOUT PA6 Analog data output
DOUT PA4 Digital data output

Examples

The examples are based on the HAL library. Please download the demo codes, unzip them and find the STM32 examples.

  • Open the project from MQ-2-Gas-Sensor-code\STM32\STM32F103RB\MDK-ARM by Keil.
  • Build the project and program it to the STM32 board.
  • connect the UART1 of the STM32 board to the PC and check the serial data by SCCOM software.
MQ5 STM32 3.jpg

Expected result

  • The sensor needs to preheat for about a minute to heat the internal sensitive materials of the sensor.
  • Put the sensor inside the device containing sensitive gas, and the indicator on the module lights up. The indicator goes off when the sensor is removed from the device.