indoor air quality monitoring with rak wisblock and the things network

Building your indoor air quality (IAQ) monitoring system is easier with the RAK WisBlock modular platform and a LoRaWAN® gateway. With just a few plug-and-play components, you can create a DIY device that measures key environmental metrics like temperature, humidity, VOCs, and estimated CO₂, then transmits the data wirelessly to the cloud.

Monitoring these parameters is critical as they directly affect cognitive performance, comfort, and overall health. High levels of CO₂ can cause drowsiness and reduced concentration. Poor humidity and elevated VOCs often lead to headaches, fatigue, or eye strain.

If you work from home or spend long hours in an enclosed space, it’s time to pay attention to your indoor air quality.

In this two-part tutorial, you’ll learn how to assemble the hardware, connect it to The Things Network (TTN), and verify real-time data transmission.

  • Part 1 focuses on the build and network setup
  • Part 2 will cover cloud visualization

What You’ll Build

This project creates an IAQ monitor that collects real-time readings for:

  • Temperature
  • Humidity
  • Barometric Pressure
  • VOC (Volatile Organic Compounds)
  • Estimated CO₂ (eCO₂)
  • Indoor Air Quality (IAQ) Index

The device sends this data wirelessly over LoRaWAN to TTN, where you can view live updates in the console.

Figure 1: IAQ device setup

 

🗒️
NOTE

No battery is used in this project. The WisBlock enclosure needs to be drilled with a hole for the port. Or, you can print and modify with the available

  • RAKBox-UO100x75x38 3D model
  •  

    Why Air Quality Matters

    Here's a quick guide to interpreting the sensor readings and how they relate to your health and productivity.

    PARAMETER OPTIMAL RANGE IMPACT WHEN OUT OF RANGE
    eCO₂ < 800–1000 ppm Causes mental fatigue, reduced focus, and poor decision-making
    VOC < 0.5 ppm (ideal) Can trigger headaches, drowsiness, or eye strain
    Temperature 22° C–26° C Too hot or too cold affects comfort and alertness
    Humidity 40%–60%

    Too low = dryness

    too high = mold risk

    Pressure 990–1025 hPa Mostly for reference, can relate to weather changes

    The Indoor Air Quality (IAQ) Index simplifies all this into a single score:

    IAQ SCORE AIR QUALITY
    0–50 Excellent
    51–100 Good
    101–150 Poor
    > 150 Unhealthy

    System Overview: How It All Works

    This IAQ system continuously collects environmental data from the RAK1906 sensor, processes it via the RAK4631 core, and transmits it over LoRaWAN through the RAK7268V2 gateway. The data is forwarded to The Things Network (TTN), where you can inspect each uplink.

    MAIN COMPONENT DESCRIPTION
    RAK1906 Sensor module with BME680 (temp, humidity, pressure, eCO₂)
    RAK19007 Connects the sensor and manages power
    RAK4631 Acts as the device’s brain; collects data and sends it via LoRa
    RAK7268V2 Receives the data and sends it to the internet through The Things Network (TTN)

     

    Figure  2: Sensor data flow summary

    Step-by-Step Guide on How to Build a Smart IAQ Monitoring Device

    Step 1: Set Up the RAK7268V2 Gateway

    1. Attach the LoRa antenna first before you power on the gateway.

    2. After powering on, connect to the gateway’s Wi-Fi. Default name: <Gateway Model Name>XXXX (RAK7268CV2_XXXX).

    Figure  3: Connect to the gateway’s Wi-Fi

    3. Then open a web browser and enter the default IP address: 192.168.230.1

    4. Set the password on the first login, with a username: root

    5. Go to Network > WAN > Wi-Fi, then click Settings.

    6. Choose Enabled and select Scan to view the available Wi-Fi networks.

    Figure  4: Configure the gateway’s Wi-Fi settings


    7. Make sure that your gateway’s firmware is updated. If not, download the RAK7268V2 latest firmware.

    8. Once the gateway is connected to the same Wi-Fi network, configure the selected LoRaWAN network server to link the gateway.

    🗒️
    NOTE

    For more details on how to connect the RAK7268V2 gateway through LTE and ETH, refer to its quick start guide documentation.

     

    Step 2: Register the Gateway on TTN

    For this project, The Things Network is selected as the LNS. Make sure you have a TTNv3 account. Otherwise, sign up and create one. 

    1. In the Dashboard, click the Register gateway button to start adding details.

    Figure  5: Register the gateway

     

    2. Check the Gateway EUI and enter it in the field. For RAK7268CV2, it’s printed on the back of the gateway. Other fields will only be visible once the EUI has been entered.

    3. Fill out the details and then click Register gateway.

    🗒️
    NOTE

    Make sure to select the correct frequency plan that matches your gateway.

     

    Figure 6: List of gateways registered in the network server

    Step 3: Link the Gateway with TTN

    The previous steps registered the gateway in the LNS but did not link it yet. There’s no sending or receiving data yet since the gateway must be linked to the server first. To do so, the gateway must be linked with API keys.

    1. In the gateway list, select the newly registered gateway to start generating a token.

    2. Click the API keys, then click the + Add API key button.

    Figure 7: API keys dashboard

    3. Enter the name, select the rights, and click Create API key.

    Figure 8: Create the gateway’s API key

    4. Upon clicking, a new window will prompt with the API key. Make sure to copy the key and store it elsewhere since it will not be accessible after this. Then click the I have copied the key button.

    Figure  9: Copy the generated API key

    5. Go back to the WisGateOS 2 web UI and click LoRa® in the sidebar.

    6. Connect to the Basics station, select LNS Server, and fill out the fields:

    • Server URL: Select a network cluster based on your device or gateway location.
      • wss://eu1.cloud.thethings.network
      • wss://nam1.cloud.thethings.network
      • wss://au1.cloud.thethings.network
    • Server Port: 887
    • Authentication Mode: Select TLS Server & Client Token Authentication
    • CA Certificate: Download the certificate first and then upload it in this field.
    • Client Token: Paste the generated API key from TTN.

    Figure 10: Configure the Basics Station server setup

    • Return to TTN, and you will see a Connected status in the gateway overview. However, the uplink message notification is not visible yet. You still need to connect the end device to the network.

    Step 4: Register the IAQ Device in TTN

    Before registering an end device, first create an application where you will add the device. 

    1. Click the Applications tab in the sidebar, then click the + Add application button.

    Figure 11: Adding an application to the TTN network server

     

    2. Fill out the details in the window, then click Create application.

    Figure 12: Create an application 

    3. Now that you have created an application, register the end device by clicking the + Register end device button.

    Figure 13: Application overview

    4. Manually enter the end device frequency and protocol stack. 

    • Make sure the frequency plan matches the gateway.
    • Check the protocol stack in the RAK4631 datasheet

    5. After entering the end device specifics, the Show advanced activation, LoRaWAN class and cluster settings dropdown will appear. Click it, select the Activation mode, and choose Additional LoRaWAN class capabilities.

    Figure 14: Advanced activation mode

    6. In the Provisioning information, enter the following and click Register end device:

    • JoinEUI: Can be set to all zeros, but make sure that it will be used in the device.
    • DevEUI: Printed in the core module label.
    • AppKey: Click the generate button.

    Figure 15: Enter the provisioning information

    7. You will be redirected to the end device overview, with an indicator of No activity yet, since the device must be flashed with firmware and with the same provisioning information configured in the previous step.

    Figure 16: End device dashboard overview

    Step 5: Flash the Firmware to RAK4631

    The WisBlock product line takes inspiration from a LEGO-style concept, offering a plug-and-play solution.

    Figure 17: Assembly diagram of the WisBlock system

    1. Before anything else, attach the antennas (LoRa & BLE) to the RAK4631.

    2. Plug the core into the base board’s CPU SLOT and the sensor into SLOT A.

    3. Code the device firmware and load it into the device. The firmware utilizes the existing LoRaWAN_OTAA_ABP example code available in the Arduino IDE. You may refer to the BSP installation guide.

    Figure 18: Example code for LoRaWAN OTAA and ABP

    Here are the key parameters to ensure that the device will join the network:

    • Activation Mode: By default, the LoRaWAN example code uses the OTAA mode, which matches the set activation mode in the TTN
    • Frequency Plan: The region LoRaMacRegion_t  must be set to the same frequency plan set in both the gateway and TTN.
    • Device Class: Should also be the same as the class set in TTN.
    DeviceClass_t g_CurrentClass  = CLASS_A;
    LoRaMacRegion_t g_CurrentRegion = LORAMAC_REGION_AS923_3;
    
     
    • Provisioning Keys: Add the keys (DevEUI, AppEUI, AppKey) you’ve entered and generated in the TTN console.
     
    // OTAA keys (MSB)
    uint8_t nodeDeviceEUI[8] = {0x00, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    uint8_t nodeAppEUI[8]    = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    uint8_t nodeAppKey[16]   = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

     

    4. Compile and check if the device successfully connected to the network. Then start configuring the sensor.

    5. The sensor is initialized using the BSEC library bsec.h and is configured to output:

    • Temperature
    • Humidity
    • Pressure
    • CO₂ Equivalent
    • VOC Equivalent
    • Indoor Air Quality (IAQ) index
    🗒️
    NOTE

    The RAK1906 provides estimated CO₂ based on gas resistance only. For accurate CO₂ or VOC monitoring, additional sensors (e.g., RAK12037 or RAK12047 may be considered in future iterations.

    If multiple sensors are involved, check first if the sensors’ pinouts are compatible with the WisBlock Pin Mapper.

     

    Since the end device has been connected to the network, you can see in the TTN Live Data that the device started sending frames.

    Figure 19: TTN live data updates

    Step 6: Set Up the Payload Formatter

    After flashing the firmware and connecting the device to the network, decode the sensor data:

    1. Go to the Payload formatters > Uplink and set the Formatter type to Custom Javascript formatter.

    Figure  20: Set up the Formatter type and the code

    2. Copy and paste the code into the Formatter code field, then click Save changes.

    function decodeUplink(input) {
      if (input.bytes.length < 12) {
        return {
          errors: ["Payload too short"]
        };
      }
    
    
      function getInt16(high, low) {
        let value = (high << 8) | low;
        // Convert to signed 16-bit
        if (value & 0x8000) value = value - 0x10000;
        return value;
      }
    
      let i = 0;
    
      let temperature = getInt16(input.bytes[i++], input.bytes[i++]) / 100;
      let humidity    = ((input.bytes[i++] << 8) | input.bytes[i++]) / 100;
      let pressure    = (input.bytes[i++] << 8) | input.bytes[i++];
      let iaq         = ((input.bytes[i++] << 8) | input.bytes[i++]) / 100;
      let co2         = ((input.bytes[i++] << 8) | input.bytes[i++]) / 100;
      let voc         = ((input.bytes[i++] << 8) | input.bytes[i++]) / 100;
    
    
      return {
        data: {
          temperature: temperature.toFixed(2),
          humidity: humidity.toFixed(2),
          pressure: pressure,
          iaq: iaq.toFixed(2),
          co2_equivalent: co2.toFixed(2),
          voc_equivalent: voc.toFixed(2)
        }
      };
    }
    

     

    3. Return to the Live data tab. You should now see the sensor data values.

    Figure 21: Live data updates with decoded payload

    4. In the Device Overview, you’ll see the last activity and the latest decoded payload.

    Figure 22: Latest decoded payload

    🟢 A green LED will stay on to indicate successful connection.

    Figure  23: End device starts sending sensor data, with the green LED as an indicator
     

    Final Thoughts

    This guide covered the full setup of a smart IAQ monitoring device, from hardware assembly to LoRaWAN network integration using TTN. You can use this as a foundation for:

    • Smart home automation
    • Air quality alerts via email/SMS
    • Integrating with Home Assistant or Node-RED

    Up next:

    • How to monitor IAQ data and set up alerts using Datacake
    • How to connect to custom dashboards with Grafana

       


     

    caryl-enanor.jpg

    Caryl Enanor

    Caryl is an Electronics Engineer with a passion for writing and a growing interest in software QA. As Documentation Lead at RAKwireless, she ensures technical content is clear and easy to understand. Off the clock, she paints, reads books, and lets Alexa play rain sounds with jazz.

     


    Changelog
    • Version 1 - LoRaWAN-Based Motion Detector with Battery Monitoring on WisBlock
      • Author:Caryl Enanor
      • Reviewer: Karla Jimenez
      • Date Published: 07/03/2025

     

     

     

     

    Updated