How to Map Sensor Values to Ranges or Booleans, Strings using Mapping Fields

Learn how to use Datacake IoT Platform to map numerical values like CO2 levels to string or boolean statuses for enhanced data monitoring and visualization.

Introduction

Welcome to this tutorial. In this guide, we will demonstrate how to use the Datacake IoT platform to map numerical values to meaningful representations. This includes converting numerical readings such as temperature, humidity, or CO2 levels into string statuses (e.g., "OK", "Too High", "Too Low") or boolean values (e.g., "Person Detected"). These mappings are useful for monitoring various metrics and displaying them effectively on your dashboard.

What is a Mapping Field?

Read more here:

Mapping Fields

Start

Steps to Add a Mapping Field

1. Access the Device Configuration

  1. Log in to your Datacake account.

  2. Navigate to the device you want to configure (e.g., LHT 65).

  3. Go to the Configuration section of the device.

2. Locate the Payload Decoder and Fields

  1. Scroll down to the Payload Decoder section. Note that while mapping can be done here, we'll use the Fields section for this tutorial.

  2. Scroll to the Fields section to see the existing fields like battery, temperature (internal and external), humidity, and CO2.

3. Add a Mapping Field for Battery Status

  1. Identify the field you want to map (e.g., battery voltage).

  2. At the end of the field row, click on the three dots.

  3. Select Add Mapping Field.

4. Configure the Mapping Field

  1. Choose the field type (String, Integer, or Float). For battery status, select String.

  2. Name the field (e.g., "Battery Status"). The identifier will be generated automatically but can be overridden.

  3. Define the mapping logic using a lookup table:

    • Below or equal to 2.5V: "Battery Low"

    • Below or equal to 3.5V: "Battery Moderate"

    • Above 3.5V: "Battery OK"

  4. Add these mappings and save the field.

5. Simulate Data to Verify Mapping

  1. Enter the original field (e.g., battery voltage).

  2. Manually input a value to see the mapping in action. For example, input 2.998V to check if it maps to "Battery Moderate".

6. Display the Mapped Field on the Dashboard

  1. Go to the Dashboard for the device.

  2. Enter Edit Mode.

  3. Add a new widget:

    • Select Value Widget.

    • Choose the device and the newly created mapping field (e.g., "Battery Status").

  4. Save and place the widget on the dashboard.

  5. Exit Edit Mode to see the live status.

7. Mapping CO2 Levels to Determine Presence

  1. Identify the CO2 field that is fed by the sensor output.

  2. Add a mapping field for CO2 detection.

  3. Choose the field type Boolean.

  4. Name the field (e.g., "Person Detected").

  5. Define the mapping logic:

    • Above 800 ppm: True (Person Detected)

    • Below 800 ppm: False (Person Not Detected)

  6. Add this mapping and save the field.

8. Display the Boolean Field on the Dashboard

  1. Go to the Dashboard for the device.

  2. Enter Edit Mode.

  3. Add a new widget:

    • Select Value Widget or Status Widget.

    • Choose the device and the newly created mapping field (e.g., "Person Detected").

  4. Save and place the widget on the dashboard.

  5. Exit Edit Mode to see the live status.

9. Additional Examples and Uses

You can apply similar steps to other fields such as temperature:

  1. Add a mapping field for temperature.

  2. Define breakpoints (e.g., below 15°C: "Too Cold", 15-25°C: "OK", above 25°C: "Too Hot").

  3. Display this status on the dashboard.

10. Using Linear Scaling for Percentage Display

  1. Add a new mapping field and select Linear Scale.

  2. Configure the scaling (e.g., for battery percentage from 2.5V to 4V).

  3. Name the field (e.g., "Battery Percentage") and set the unit to %.

  4. Define the source range (e.g., 2.5V = 0%, 4V = 100%).

  5. Add boundaries to restrict values between 0% and 100%.

  6. Display this field as a gauge on the dashboard.

Conclusion

Mapping fields in Datacake IoT Platform allows you to create meaningful representations of your data, improving monitoring and alerting capabilities. By following this guide, you can map numerical values to string statuses or boolean values and display them effectively on your dashboard.

Thank you for following this tutorial. Stay tuned for more updates and tutorials on using Datacake IoT Platform.

Last updated