Quantcast
Jump to content


Recommended Posts

Posted

2024-9-10-01-banner.png

A sensor's maximum and minimum values are crucial for calibration, data interpretation, threshold setting, user interface, error handling, sensor selection, and performance optimization.

Understanding the expected range of values helps identify and handle sensor errors or anomalies, and selecting the right sensor for the intended use case is essential. Efficient use of sensor data, especially in resource-constrained environments like mobile devices, can optimize data processing algorithms.

The maximum and minimum values of sensors play a crucial role in the accurate and efficient functioning of sensor-based applications across various domains. In this tutorial, a wearable application is developed to collect the maximum and minimum ranges of sensors from a Galaxy Watch running Wear OS powered by Samsung. This tutorial shows how to retrieve all sensor ranges together, as well as from one specific sensor separately.

Environment

Android Studio IDE is used for developing the Wear OS application. In this tutorial, Java is used, but Kotlin can also be used.

Let’s get started

The SensorManager library is used here to collect sensor data from a Galaxy Watch running Wear OS powered by Samsung.

Retrieve the maximum range of a sensor

To get access and retrieve the maximum ranges from the sensor:

  1. In Android Studio, create a wearable application project by selecting New Project > Wear OS > Blank Activity > Finish.
  2. To access the sensor, add the body sensor in the application’s “manifests” file.

    <uses-permission android:name="android.permission.BODY_SENSORS" />
    
  3. To run the application on devices with Android version 6 (API level 23) or later, you need runtime permission from the user to use the BODY_SENSORS APIs.

    Add the following code snippet to the onCreate() method before calling any sensor operations:

    if (checkSelfPermission(Manifest.permission.BODY_SENSORS) != PackageManager.PERMISSION_GRANTED) {
       requestPermissions(new String[]{Manifest.permission.BODY_SENSORS}, 1);
    } else {
       Log.d("TAG___", "ALREADY GRANTED");
    }
    

    After this code executes, a pop-up window appears and requests permission from the user. The sensor APIs return values only if the user grants permission. The application asks for permission only the first time it is run. Once the user grants permission, the application can access the sensors.

    undefined
    undefined
    undefined
    undefined

    Figure 1: Permission screen

    undefined

    More details about runtime permissions can be found here.

  4. Create an instance of the SensorManager library before using it in the code.

    private SensorManager sensorManager;
    sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
    
  5. To retrieve the maximum range of all sensors, create a sensor list using API Sensor.TYPE_ALL.

    List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
    ArrayList<String> arrayList = new ArrayList<String>();
    for (Sensor sensor : sensors) {
       if (sensor != null) {
          arrayList.add(sensor.getName());
          arrayList.add(sensor.getMaximumRange() + "");
          arrayList.add(sensor.getResolution() + "");
       }
    }
    arrayList.forEach((n) -> System.*out*.println(n));
    

    The above code shows the sensor name, maximum range, and resolution. You can get all the available data from the sensors, such as type, vendor, version, resolution, maximum range, and power consumption, by applying this same approach.

Remember, sensor information may vary from device to device.

Additionally, not every sensor that appears in the logcat view is accessible. Third-party applications are still not allowed to access Samsung's private sensors using the Android SensorManager. You get a “null” value if you try to access the private sensors.

Moreover, there are no plans to make these sensors available to the public in the near future.

You can check my blog Check Which Sensor You Can Use in Galaxy Watch Running Wear OS Powered by Samsung to find out which sensors are accessible on your Galaxy Watch and which are not.

Retrieve the minimum range of a sensor

The minimum range is the complement of maximum range.

If the maximum range is x, then the minimum range can be calculated like this: x*(-1) = -x.

If a specific sensor value should always be absolute, then the minimum range is zero (0).

There is no direct API available to retrieve the minimum range of sensors from Galaxy Watch.

Get a specific sensor value

  1. To get specific sensor values from a Galaxy Watch, you can filter the sensor list or use the getDefaultSensor() method. Here is an example that demonstrates how to do this. Add the necessary permission in the “manifests” file for the accelerometer sensor:

    <uses-feature android:name="android.hardware.sensor.accelerometer" />
    
  2. Use the following code in your Activity or Fragment to retrieve the accelerometer data:

    sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (sensor != null) {
       textView_maxV.setText(textView_maxV.getText() + "" + sensor.getMaximumRange() + "");
       textView_resolution.setText(textView_resolution.getText() + "" + sensor.getResolution() + "");
    }
    
  3. Ensure you have added the TextView element to your XML file.

Output of the above code:

undefined
undefined
undefined
undefined

Figure 2: Maximum range and resolution of the accelerometer

undefined

Remember, sensor ranges may vary from device to device. You may get different values for different Galaxy Watch models.

Download the example from this blog:

SensorMinxMax
(313.2KB) Sep 10, 2024

Summary

This article demonstrates how you can retrieve the maximum and minimum ranges of sensors from your Galaxy Watch running Wear OS powered by Samsung. You can also use the above approaches to get other necessary available information from the watch that can be used for the precise and effective operation of sensor-based applications in a variety of fields.

If you have any questions about or need help with the information in this article, you can reach out to us on the Samsung Developers Forum or contact us through Developer Support.

View the full blog at its source



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Similar Topics

    • By Samsung Newsroom
      In a fashion industry driven by rapid production and short product cycles, Korean brand PLEATSMAMA has made sustainability part of its approach to innovation. Known for its pleated bags, the brand was the first in Korea to introduce a 3D knitting technique using recycled yarn made from discarded plastic bottles, embedding sustainability throughout its materials and production process.
      Recently, PLEATSMAMA expanded that approach to its retail spaces by introducing Samsung Electronics’ Color E-Paper, a next-generation signage solution designed to reduce paper point-of-purchase (POP) materials and printed guides.
      “Samsung Color E-Paper is a solution that can transform the retail environment.”
      – Jong-mi Wang, founder and CEO of PLEATSMAMA
      ▲ PLEATSMAMA uses Samsung Color E-Paper to display promotions and brand stories. In Seoul’s Samcheong-dong neighborhood, traditional Korean hanok buildings stand alongside contemporary galleries, cafés and boutiques. The area’s blend of heritage and modern creativity makes it a fitting home for PLEATSMAMA’s flagship store and its philosophy of thoughtful design and responsible living.
      Samsung Newsroom met with Jong-mi Wang, founder and CEO of PLEATSMAMA and Min-kyung Lee, manager of the Samcheong store, to learn how Color E-Paper is extending the brand’s sustainability efforts into its retail space.

      Turning Sustainability Into Everyday Practice
      PLEATSMAMA uses 3D knitting technology to form each bag with minimal cutting and sewing, helping reduce fabric waste. The brand wanted to bring the same approach to store operations, where printed POP materials are frequently replaced with new product launches and promotions.
      ▲ PLEATSMAMA uses recycled yarn and 3D knitting technology to reduce fabric waste. (Photo courtesy of PLEATSMAMA) Color E-Paper emerged as a solution. The ultra-low-power digital signage features a paper-like texture that blends naturally with store interiors while allowing content to be easily updated after installation. The product also aligns with PLEATSMAMA’s focus on resource circulation, with 55% of its housing materials consisting of recycled plastic.
      Launched earlier this year, the 13-inch model is the world’s first display to use bio-resin derived from plankton oil1 — reducing carbon emissions during material production by more than 40% compared with conventional petroleum-based plastics.2
      “What matters most is that sustainability is no longer limited to one-time campaigns
      — it has become a part of everyday operations.”
      ▲ Wang discusses why PLEATSMAMA introduced Samsung Color E-Paper. “Operating a store means constantly producing seasonal POP materials and guides, many of which are used only briefly,” said Wang. “As we looked for ways to communicate our brand message while reducing unnecessary resource use, we came across Samsung Color E-Paper and realized it could be a meaningful solution.”
      Retail spaces use more paper posters than many might expect. With Color E-Paper, store staff can easily update promotional images, product information and brand content without repeatedly printing new materials. Wang described the shift as an important step toward making sustainability part of everyday operations rather than a one-time campaign.
      ▲ A visitor explores product Q&A content on Samsung Color E-Paper, which supports playlist creation and scheduled content updates. Unlike printed signage, Color E-Paper allows content to be updated automatically through preset playlists and schedules. At its Samcheong store, PLEATSMAMA uses the 32-inch display to share “PLEATSMAMA Q&A” content in Korean, English and Japanese, helping local and international visitors better understand the brand.
      “Japanese customers tend to spend more time in the store and carefully read the Japanese-language content,” said Lee. “Color E-Paper has made it easier to share product care instructions and the brand’s philosophy.”

      Flexible, Efficient and Designed for Retail Spaces
      Color E-Paper has also changed how PLEATSMAMA manages store operations. Previously, promotional materials had to be printed and replaced for every campaign and product launch. Now, store staff can update content in real time through the Samsung E-Paper App while managing playlists and schedules.
      ▲ Lee updates Color E-Paper content through the Samsung E-Paper App. “Eliminating the process of printing, installing and disposing of paper signage has made
      store management much more efficient.”
      – Min-kyung Lee, manager of PLEATSMAMA Samcheong store
      “In the past, the headquarters or operations team had to deliver POP materials whenever we launched a new product or campaign,” said Lee. “With Color E-Paper, store managers can remotely download and apply content immediately.”
      “Promotions used to mean printing and manually replacing paper signage throughout the store,” she added. “Now, we can simply upload new content, significantly reducing waste.”
      ▲ Lee discusses how Color E-Paper has improved store operations. Color E-Paper supports PLEATSMAMA’s sustainability efforts through ultra-low power consumption, operating at zero watts power while displaying static content and consuming power only when content is updated.3
      Available in a range of sizes and easy to install, the display can adapt to different spaces and uses.4 At PLEATSMAMA’s Samcheong store, the 13-inch model is often placed on tables or shelves for close-up viewing, while the larger 32-inch model displays more detailed content such as brand Q&As. Their lightweight, slim design makes the displays easy to move and reposition as the store layout changes.
      “It was impressive to see the brand’s message reflected in the technology
      used throughout the store.”
      PLEATSMAMA also values how the signage fits naturally into the store environment. Color E-Paper’s paper-like surface and slim profile help it blend seamlessly into the space while showcasing the brand’s signature knit textures and colorful designs.
      Color E-Paper uses a color imaging algorithm to deliver more natural colors and smoother image quality. As a result, the display feels less like a digital screen and more like part of the brand space.
      ▲ Color E-Paper’s paper-like texture and rich colors blend naturally into the store environment. “In the past, store staff often had to introduce products to customers, but now many discover items through the images on Color E-Paper and ask about them directly,” said Lee. “It has been exciting to see customers engage more actively with the content.”
      “At first, I thought it was just a regular paper poster,” said one visitor. “I’m impressed by how naturally the brand’s sustainability message is reflected in the store’s technology.”

      The Future of Sustainable Retail
      For PLEATSMAMA, a sustainable lifestyle is less about dramatic changes and more about everyday choices — using products longer and minimizing unnecessary waste. This philosophy aligns closely with Samsung Color E-Paper’s focus on reducing paper and power consumption in everyday spaces.
      ▲ (From left) Min-kyung Lee and Jong-mi Wang “Samsung’s approach to innovation for a more sustainable future
      closely aligns with our philosophy.”
      “We are doing our best for the environment where we can make a difference, but there are limits to what a single brand can achieve alone,” said Wang. “That is why collaboration with companies like Samsung Electronics, which develop sustainable technology solutions, is meaningful. I believe retail will increasingly connect design, technology and sustainability.”
      The collaboration between Samsung and PLEATSMAMA shows how sustainability can extend beyond products into the retail experience itself. When brand philosophy and technology align naturally, retail spaces can more clearly express a brand’s identity.
      The 13-inch Color E-Paper (model: EM13DX) cover incorporates 45% recycled plastic and 10% bio-resin derived from plankton oil. ︎ Carbon emissions were calculated using product carbon footprint (PCF) data for resin production in accordance with ISO 14067, 14040 and 14044 standards and compared with petroleum-based resin (PC+ABS) of the same weight. Emissions from distribution, use and disposal were excluded. All figures are estimates based on specific test conditions and may vary depending on actual usage environments. ︎ Power may be consumed when refreshing or changing content or when controlling the device. When connected to a power cable or battery, content refreshes occur automatically as required. ︎ Two rear holders and two brackets are included in the standard package. The 13-inch model also includes two display stands. Additional accessories are sold separately. ︎ View the full article
    • By Samsung Newsroom
      The Workout app was created to show how to implement a fully working application that supports running on wearable devices with Tizen.
      Workout is written in C# and uses the Xamarin.Forms and Tizen.CircularUI frameworks.

      Text
      Workout
      Overview
      This version of the application allows you to measure the following parameters while running:
      Running time Distance traveled Heart rate Pace Present effort In the summary of the training, the application also shows the most common range of effort.
      Read more
      In a series of blogs publishing this week, we will describe and show how key functionalities of the application are implemented, such as:
      Distance traveled Heart rate (intensity) Workout summary A detailed tutorial describing the application can be found on TizenSchool.org

      Distance
      Intensity You can download and test the app from the link below:
      https://github.com/Samsung/Tizen-CSharp-Samples/tree/master/Wearable/Workout
      In the next release of the application, it will collect workout data and give an insight into the history. It will also allow you to edit user profile settings such as age or the distance measurement unit.
      If you have an idea for functionality or have any comments about the application, let us know!
      View the full blog at its source
    • Government UFO Files
    • By Samsung Newsroom
      This is part of a 2 hour Tizen workshop that you can find here: https://youtu.be/5xp8jFpXOm8
      In this video, you will learn to use the wearable device sensors and modify a project to detect the user's heart rate.
      You can also connect with me, Diego, a Sr. Developer Evangelist, on Twitter: https://twitter.com/hielo777
      Have questions? Post them in our forums: https://forum.developer.samsung.com/
      Check out other videos, blog posts, and tips to improve your Tizen app development.
      Check out the Tizen Tidbits playlist on our YouTube channel, and learn more about the wide selection of Samsung technologies on our developer portal.
      View the full blog at its source





×
×
  • Create New...