RAK WisBlock RAK12004 User manual

Documentation Center
RAK12004 Quick Start Guide
Prerequisite
What Do You Need?
Before going through each and every step on using RAK12004 WisBlock MQ2 module, make sure to prepare the
necessary items listed below:
Hardware
RAK12004 WisBlock MQ2 Gas Sensor Module
Your choice of WisBlock Base with IO slot
Your choice of WisBlock Core
USB Cable
Li-Ion/LiPo battery (required)
Solar charger (optional)
Software
Download and install Arduino IDE .
To add the RAKwireless Core boards on your Arduino project, install the RAKwireless Arduino BSP. Follow the
steps in the RAKwireless Arduino BSP .
Product Configuration
Hardware Setup
RAK12004 module is part of the WisBlock Sensor category and extends the WisBlock system with a gas sensor
alert system. The RAK12004 connects to the WisBlock Base Board through the IO slot. The Figure 1 shows the
assembly of a WisBlock Core highlighted in green and the module RAK12004 highlighted in red. Also, always
secure the connection of the WisBlock module by using the compatible screws. For more information about
RAK12004, refer to the Datasheet.
Figure 1: RAK12004 connection to WisBlock Base Board

Documentation Center
Assembling and Disassembling of WisBlock Modules
Assembling
As shown in Figure 2, the location for the IO slot is properly marked by silkscreen. Follow carefully the procedure
defined in WisBlock Base board assembly/disassembly instructions to attach a WisBlock module. Once
attached, carefully fix the module with one or more pieces of M1.2 x 3 mm screws depending on the module.
Figure 2: RAK12004 connection to WisBlock Base Board
Disassembling
The procedure in disassembling any type of WisBlock modules is the same.
1. First, remove the screws.
Figure 3: Removing screws from the WisBlock module
2. Once the screws are removed, check the silkscreen of the module to find the correct location where force can
be applied.
Figure 4: Detaching silkscreen on the WisBlock module

Documentation Center
3. Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the
baseboard.
Figure 5: Applying even forces on the proper location of a WisBlock module
📝
NOTE
If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin
Mapper tool for possible conflicts. RAK12004 uses I2C and IO pins it can cause possible conflict
especially on some IO modules.
After all this setup, you can now connect the battery and USB cable to start programming your WisBlock Core.
⚠
WARNING
Batteries can cause harm if not handled properly.
Only 3.7-4.2 V Rechargeable LiPo batteries are supported. It is highly recommended not to use other
types of batteries with the system unless you know what you are doing.
If a non-rechargeable battery is used, it has to be unplugged first before connecting the USB cable to
the USB port of the board to configure the device. Not doing so might damage the battery or cause a
fire.
Only 5 V solar panels are supported. Do not use 12 V solar panels. It will destroy the charging unit and
eventually other electronic parts.
Make sure the battery wires match the polarity on the WisBlock Base board. Not all batteries have the
same wiring.
Software Configuration and Example
The RAK12004 has an electronic sensor used for sensing the concentration of gases in the air. It contains a
sensing material whose resistance changes when it comes in contact with the gas. Concentrations of gas is
measured using a voltage divider network present in the sensor. The output of the sensing element is connected to
a 12-bit ADC (ADC121C021) which communicates through I2C to the application.
Initial Test of the RAK12004 WisBlock Module
1. Install the RAKwireless Arduino BSP for WisBlock by using the package_rakwireless_index.json board
installation package. The WisBlock Core should now be available on the Arduino IDE.
2. You need to select first the WisBlock Core you have.
RAK4631 Board

Documentation Center
Figure 6: Selecting RAK4631 as WisBlock Core
RAK11200 Board
Figure 7: Selecting RAK11200 as WisBlock Core

Documentation Center
RAK11310 Board
Figure 8: Selecting RAK11310 as WisBlock Core
3. Install the RAKwireless MQx Library using Arduino Library Manager.
4. On the Arduino IDE, select Sketch -> Include Library -> Manage Libraries, as shown in Figure 9.
5. On the Library Manager text area, type RAKwireless MQx.
Figure 9: Arduino Library Manager
6. To finish the installation, click on the Install button, as shown in Figure 10.

Documentation Center
Figure 10: Finish RAK-MQx library Installation
7. Once the library is installed, open the RAK12004_MQ2_Sampling example.
8. On the Arduino IDE, select File -> Examples -> RAKWireless MQx Libraries -> RAK12004_MQ2_Sampling,
as shown in Figure 11.
Figure 11: Open RAK12004 MQ2 Sampling Sketch
📝
NOTE
If you experience any error in compiling the example sketch, check the updated code for the RAK12004
WisBlock MQ2 Gas Sensor Module that can be found on the RAK12004 WisBlock Example Code
Repository .
9. You can now select the right serial port and upload the code, as shown in Figure 12 and Figure 13.

Documentation Center
Figure 12: Selecting the correct Serial Port
Figure 13: Uploading the RAK12004 example code on RAK4631
To extend the use of the RAK-MQx library, check the link RAK-MQx Library methods
Build RAK12004 Example on PlatformIO IDE (optional)
📝
NOTE:
This procedure was tested only on Windows 10 and Ubuntu.
1. Install the original PlatformIO platform, as shown in PlatformIO First Install section.
For WisBlock Core RAK4631, install Nordic nRF52 platform.
For WisBlock Core RAK11200, install Espressif 32 platform.
For WisBlock Core RAK11310, install Raspberry Pi RP2040 platform.
2. Open a project example that uses the new installed platform.

Documentation Center
3. Launch Visual Studio Code and select PlatformIO PIO Home.
4. On PIO Home, click on Project Examples.
5. Choose arduino-blink project, then click on Import button.
Figure 14: Import arduino-blink project
6. Click the Yes button on the trust window.
Figure 15: PlatformIO trust authors
7. Build the project and ignore warnings and errors.
8. Download and install the RAK Patch script .
9. Unzip the contents of RAK_PATCH.zip into the folder RAK_PATCH in your PlatformIO installation folder.
The table below shows the PlatformIO installation directory for each operating system:
Figure 16 shows the PlatformIO installation directory on Windows 10.
PlatformIO path on different OS
Windows 10 %UserProfile%\.platformio\
Linux ~/.platformio/
MacOS /Users/{Your_User_id}/.platformio/

Documentation Center
Figure 16: RAK patch folder on Windows
10. Open a command prompt in %UserProfile%.platformio\RAK_PATCH folder and execute python
./rak_patch.py .
Figure 17: RAK patch installed on Windows
⚠
WARNING
In case of any platform update on PlatformIO, the RAK_PATH script must be executed again after the
platform update.
11. Import the RAK12004 Arduino Project to PlatformIO.
12. Open PlatformIO PIO Home and select Import Arduino Project, as shown in Figure 18.

Documentation Center
Figure 18: Import RAK12004 Arduino Project
13. Select your preferred WisBlock Core and check "Use Libraries installed by the Arduino IDE" option, as
shown in Figure 19.
14. Then choose the directory of the original RAK12004 Arduino Project.
Figure 19: Select Board and check Import Libraries
15. To finish the import, click on the Import button, as shown in Figure 20.

Documentation Center
Figure 20: Select Board and check Import libraries
16. Build the imported project on the PlatformIO.
Now, you can build the project by clicking on the highlighted icon, as shown in Figure 21.
Figure 21: Build Arduino imported project
17. Upload the imported project on the PlatformIO.
18. To upload the project on the target board, click on the highlighted icon, as shown in Figure 22.

Documentation Center
Figure 22: Upload Arduino imported project
Last Updated: 7/29/2022, 10:17:19 PM

Documentation Center
RAK12004 WisBlock MQ2 Gas Sensor Module
Datasheet
Overview
Description
The RAK12004 is a gas sensor module, part of the RAKWireless WisBlock Sensor series. The sensor used is the
MQ-2 from Zhengzhou Winsen Electronics.
Features
MQ-2 gas sensor
Sensitivity to LPG, butane, propane, methane, alcohol, hydrogen, smoke, and other flammable steam
I2C Interface
Alert function
Detection Range: 300~10000 ppm (flammable gas)
3.3 V Power Supply
Chipset: Winsen MQ-2
Module size: 25 x 35 mm
Specifications
Overview
Mounting
The RAK12004 WisBlock MQ2 Gas Sensor Module can be mounted to the IO slot of the WisBlock Base board.
Figure 1 shows the mounting mechanism of the RAK12005 on a WisBlock Base module.
Figure 1: RAK12004 WisBlock MQ2 Gas Sensor Mounting
Hardware
The hardware specification is categorized into five (5) parts. It shows the chipset of the module and discusses the
pinouts and their corresponding functions and diagrams. It also covers the electrical and mechanical
characteristics that include the tabular data of the functionalities and standard values of the RAK12004 WisBlock
MQ2 Gas Sensor Module.
Chipset
Vendor Part number
Winsen MQ-2

Documentation Center
Pin Definition
The RAK12004 WisBlock MQ2 Gas Sensor Module comprises a standard 40-pin WisConnector. The
WisConnector allows the RAK12004 module to mounted to a WisBlock Base Board. The pin order of the
connector and the pinout definition is shown in Figure 2.
📝
NOTE:
I2C related pin, ALERT, EN, VBAT, 3V3, and GND are connected to 40-pin WisConnector.
Figure 2: RAK12004 WisBlock MQ2 Gas Sensor Pinout
Electrical Characteristics
Recommended Operating Conditions
Mechanical Characteristics
Board Dimensions
Figure 3 shows the dimensions and the mechanic drawing of the RAK12004 module.
Symbol Description Min. Nom. Max. Unit
VBAT Supply Voltage 2.8 - 4.2 V
VCCIO Digital IO Power Supply - 3.3 - V
VCC ADC to I2C Chip Power Supply - 5 - V

Documentation Center
Figure 3: RAK12004 WisBlock MQ2 Gas Sensor Module Mechanic Drawing
WisConnector PCB Layout
Figure 4: WisConnector PCB Footprint and Recommendations
Schematic Diagram
Power Supply Circuit
Figure 5 shows RAK12004 step-up power supply circuit.
VBAT Battery voltage (max voltage is 4.2 V)
EN Power enable pin (active high). This pin is connected to IO6 of WisBlock Core.

Documentation Center
Figure 5: RAK12004 WisBlock MQ2 Gas Sensor Module Power Supply
Gas Detector Circuit
Figure 6 shows the gas detector circuit.
U2 Gas sensor
The heater voltage requires a 5 V supply which is provided by the 5 V step-up converter. This is needed to achieve
the standard working temperature of the sensor. The pins 1 and 3 voltage (5 V) supply the detect voltage to load
resistance R12. The AOUT pin is the voltage of load resistance R12 which represents the reading of the U2
sensor.
U3 ADC121C021 12-Bit Analog-to-Digital converter with alert function. The U3 power supply is 5 V.
Figure 6: RAK12004 WisBlock MQ2 Gas Detector Circuit
Voltage Level Shifter Circuit
The 40-pin WisConnector voltage has a voltage level of 3.3 V while U2 and U3 have 5 V. To interface the different
voltage level between 40-pin Wisconnector and gas sensor, the RAK12004 has a built-in voltage level shifter
circuit.

Documentation Center
Figure 7: Voltage Level Shifter Circuit
I2C Address
The I2C address of the Analog-to-Digital converter chip of RAK12004 can be configured via resistor jumpers as
shown in Figure 8.
Figure 8: RAK12004 I2C Address
J2 Connector Pinout
RAK12004 has an additional connector to provide an extra interface to the module. The pinout of J2 connector is
shown in Figure 9.
Figure 9: J2 Connector Pinout
WisConnector

Documentation Center
Figure 10 shows 40-pin WisConnector pinout.
VBAT battery voltage
I2C1_SDA and I2C1_SCL are I2C related pins
EN is power chip enable pin
ALERT is analog-to-digital converter alert pin
Figure 10: RAK12004 MQ2 Gas Sensor Module 40-pin WisConnector
Last Updated: 7/29/2022, 10:17:19 PM
Table of contents
Other RAK Control Unit manuals

RAK
RAK WisLink-Cellular RAK2011 User manual

RAK
RAK WisDuo Series User manual

RAK
RAK 3172 WisDuo LPWAN User manual

RAK
RAK WisCore-LoRa RAK3401 User manual

RAK
RAK RAK477 User manual

RAK
RAK WisBlock RAK13005 User manual

RAK
RAK WisBlock RAK13007 User manual

RAK
RAK WisBlock RAK19012 User manual

RAK
RAK WisBlock RAK19010 User manual

RAK
RAK RAK815 User manual
Popular Control Unit manuals by other brands

Honeywell
Honeywell FF-SRM200P2 Instructions for use

Lucent
Lucent PacketStar 23N41 user guide

Sentiotec
Sentiotec A1 Instructions for installation and use

Hudson Reed
Hudson Reed Ignite Square CPB3311 Important information

Burkert
Burkert 5470 operating instructions

Sierra Wireless
Sierra Wireless MC5720 Hardware integration guide