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 FieldsStart
Steps to Add a Mapping Field
1. Access the Device Configuration
Log in to your Datacake account.
Navigate to the device you want to configure (e.g., LHT 65).
Go to the Configuration section of the device.
2. Locate the Payload Decoder and Fields
Scroll down to the Payload Decoder section. Note that while mapping can be done here, we'll use the Fields section for this tutorial.
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
Identify the field you want to map (e.g., battery voltage).
At the end of the field row, click on the three dots.
Select Add Mapping Field.
4. Configure the Mapping Field
Choose the field type (String, Integer, or Float). For battery status, select String.
Name the field (e.g., "Battery Status"). The identifier will be generated automatically but can be overridden.
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"
Add these mappings and save the field.
5. Simulate Data to Verify Mapping
Enter the original field (e.g., battery voltage).
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
Go to the Dashboard for the device.
Enter Edit Mode.
Add a new widget:
Select Value Widget.
Choose the device and the newly created mapping field (e.g., "Battery Status").
Save and place the widget on the dashboard.
Exit Edit Mode to see the live status.
7. Mapping CO2 Levels to Determine Presence
Identify the CO2 field that is fed by the sensor output.
Add a mapping field for CO2 detection.
Choose the field type Boolean.
Name the field (e.g., "Person Detected").
Define the mapping logic:
Above 800 ppm: True (Person Detected)
Below 800 ppm: False (Person Not Detected)
Add this mapping and save the field.
8. Display the Boolean Field on the Dashboard
Go to the Dashboard for the device.
Enter Edit Mode.
Add a new widget:
Select Value Widget or Status Widget.
Choose the device and the newly created mapping field (e.g., "Person Detected").
Save and place the widget on the dashboard.
Exit Edit Mode to see the live status.
9. Additional Examples and Uses
You can apply similar steps to other fields such as temperature:
Add a mapping field for temperature.
Define breakpoints (e.g., below 15°C: "Too Cold", 15-25°C: "OK", above 25°C: "Too Hot").
Display this status on the dashboard.
10. Using Linear Scaling for Percentage Display
Add a new mapping field and select Linear Scale.
Configure the scaling (e.g., for battery percentage from 2.5V to 4V).
Name the field (e.g., "Battery Percentage") and set the unit to %.
Define the source range (e.g., 2.5V = 0%, 4V = 100%).
Add boundaries to restrict values between 0% and 100%.
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