A recap of the previous session
Last time, I created a new smartphone app, set up a data flow to retrieve information from Google HealthConnect, and wrote it to a Google Spreadsheet via Google Apps Script. This is the red route shown below.

However, the data currently available is shown in the table below; the step count is significantly higher than the actual number, and other fields are left blank. This is likely because the collected data was skewed toward “steps” or included extra numbers.

Improvements to Health DX Tools
In this update, we will resolve the aforementioned issues and ensure that step count, weight, body fat percentage, and sleep duration are correctly collected from HealthConnect and recorded in the spreadsheet. We will also implement the following improvements:
- Identifying and Resolving Issues with Measurement Data
- UI Development
Ultimately, as shown in the figure below, I had been manually entering data into the two apps on the left (Appsheet and Google Fit)—specifically, I had been manually entering every single field in Appsheet. I also entered my weight and body fat percentage separately into Google Fit and Fitbit, using each app for its respective purpose. To address this, I aim to streamline the process by consolidating data retrieval from HealthConnect and inputting it directly within the app, thereby reducing the burden of data entry.

Step 1: Identifying the Cause of the Problem
Problem: I was aggregating data from multiple data sources (Origins).
The issue with the previous data—where the step count exceeded my actual experience—was that it had combined data from multiple sources (Origins).
In my setup, step counts are tracked by both my smartwatch (Fitbit) and my smartphone, and in this case, the data is recorded on HealthConnect separately by source (Origin). The previous result was inflated compared to reality because it had summed the data from multiple sources (Origins).
When I connected my smartphone to Android Studio and used the debugging feature, I discovered that there are three types of data sources (Origins): Fitbit, android.apps.fitness, and android. I assume that the two starting with “android” both represent the same value and correspond to HealthConnect and the Android OS, respectively.

If you have smartwatches, pedometers, or other devices with write permissions for HealthConnect, the number of data sources (Origins) increases, so you’ll need to select one as needed. In this case, I’d like to use Fitbit as the priority device, but there was another issue. Please take a look at the data from a different day below.

The Fitbit reading for this day looks quite low, but that’s actually because there were times when my smartwatch ran out of battery and couldn’t track my activity. Since my device needs to be charged every few days, if I forget to charge it, the battery dies during the day and it stops tracking. Also, since I leave it on the charger while it’s charging, it’s unable to track during that time as well. During those periods, I tend to rely on the step count from my smartphone instead.
However, even these 6,108 steps feel significantly lower than I actually felt. In fact, when I walk or run on a treadmill, I tend to set my smartphone aside, so some steps may not be counted—that’s another issue I need to address.
Solution: Set the priority for Origin and provide a manual adjustment screen.
We will address these issues in accordance with the following specifications.
- (Specification 1) Generally, among multiple Origins, the Origin with the highest daily value is selected.
- (Specification 2) This app also allows direct data entry into HealthConnect to add data to a new Origin. *This is intended to correct data when the data from any of the Origins appears abnormal.
As for other issues, we will first clarify the specifications and proceed with development by adding them to the backlog to ensure nothing is overlooked.
Tips: Have ChatGPT manage your chat history
I use ChatGPT to manage the backlog of tasks that need to be addressed. In my case, I use prompts like the one below to manage the backlog and check on its status.
Add to Backlog
Please manage this item as a backlog.
・Among multiple Origins, select the Origin that recorded the highest daily value.
・Enable direct data entry into HealthConnect within this app and add data to a new Origin.
Check the backlog status
Please provide a breakdown of the current backlog by status.
Consider the next steps
Which task should I tackle next?
The prompt I’m still using is designed to sound like a simple conversation, but it’s generally performing as expected.
Step 2: How to Import Values
In the first stage, we confirmed that there is a value for “Steps” for each Origin, so we will review the values for the other items and consider how to import them.
Problem: Characteristics by Category and Issues to Be Addressed
| Item | Origin | Session Tracking | Issue |
| Steps | Fitbit, Device | Yes | Multiple sources, manual entry |
| Sleep times | Fitbit | Yes | Daily boundaries, multiple sessions |
| Weight | Google Fit (manual entry) | No | Manual entry |
| Body Fat% | Google Fit (manual entry) | No | Manual entry, decimal input |
As with the step count mentioned earlier, when reviewing the debug logs, I noticed the characteristics described above, and it was particularly necessary to address the “session status” and the issues outlined in the assignment. Below are some additional notes regarding the assignment.
- Session Status: Step count and sleep duration are recorded not only as values but also with start and end times (e.g., 07:00–09:00); these are referred to as sessions. Throughout the day, there are frequent breaks—such as walking, resting, sleeping, waking up (e.g., to use the restroom), or taking a nap. You need to combine the values from multiple sessions. Weight and body fat can be recorded multiple times a day by specifying the date and time, but for the purpose of compiling daily results, it is simple because you only need to collect the latest values.
- Multiple Origins: Since values are recorded for each data source (Origin) mentioned in the section on step count above, you need to select which values to use.
- Manual Entry: In my setup, I need a way to manually enter weight and body fat percentage—which aren’t recorded automatically—as well as steps and sleep duration, since these can’t be recorded when the battery is dead or the device is charging.
- Daily Boundaries: Where should sleep duration be divided? For example, how should we handle a scenario where someone goes to bed at 10:00 PM and wakes up at 6:00 AM? Should we count it as 8 hours of sleep for the previous day, or split it at midnight to record 2 hours and 6 hours on separate days?
- Decimal Input: While weight and body fat percentage can be manually entered in Google Fit and recorded in HealthConnect, body fat percentage can only be entered as an integer (e.g., 22%). Since I wanted to enter values with decimals (e.g., 21.8%), I need a way to input them.
Solution: Consider how to import the data based on the characteristics of each value
We have also included specifications 1 and 2 mentioned earlier.
- (Specification 1) Generally, among multiple Origins, the Origin with the highest daily value is selected.
- (Specification 2) This app also allows direct data entry into HealthConnect, adding data to a new Origin.
- (Specification 3) Step count and sleep data are summed across multiple sessions.
- (Specification 4) Sleep duration is calculated by setting a cutoff time to aggregate values from the previous day. Example: 6:00 cutoff, etc.
- (Specification 5) When entering data manually, allow the input of body fat percentage values that include decimals.
- (Specification 6) To prioritize manually entered values, review the priority of Origins.
- (Specification 7) When entering sleep and step counts, do not create session information or upload data to HealthConnect; instead, manage the data as temporary data on the device.
Regarding Specification 7, since creating session-based data would be too complex, and since we only need to know how many steps were taken and how many hours of sleep were recorded each day, we have decided not to create session data.
The actual development process involved reviewing debug logs in Android Studio to understand the specifications, generating source code using ChatGPT, modifying the source code in Android Studio, rebuilding the app, connecting it to a smartphone, and debugging—repeating this cycle to gradually improve the code. Eventually, I managed to get it to the point where values are recorded in a spreadsheet, as shown below.

I found that the approach of managing the backlog with ChatGPT and building it incrementally helped me understand the current state of affairs and clarify what needed to be done, making the process much smoother. However, I’ve noticed that as the volume of information increases—such as pasting source code or logs into the conversation or having ChatGPT generate code—the dialogue becomes increasingly sluggish, which is a challenge. I’d like to try using modern AI agents in the future to see if there’s a more efficient way to handle this.
Step 3: UI and GAS Development
The user interface (UI) was developed primarily with the following features. It is the result of continuous improvements made by adding necessary features as needed, starting with a version created for functional testing.
| Screen | Features |
| Initial Screen | GAS Communication Settings and Operation Check |
| Main Screen | Daily main screen, synchronization feature, access to input and settings |
| Input Screen | Function for entering weight, body fat percentage, step count, and sleep duration as needed |
| Setting Screen | GAS communication settings, sleep duration cutoff times, etc. |
The main screen currently looks like this. Immediately after launching, settings for reading and writing data on HealthConnect appear, followed by the initial screen where you configure the items required for GAS communication. These items are as follows:
・GAS URL
・Secret (Password)
・Spreadsheet ID
・Sheet Name
A corresponding GAS script is also generated, and you configure the settings within GAS. If the connection test is successful, the main screen on the right will appear, displaying data based on the selected display period (3, 7, or 14 days).
Clicking the “Correct” button opens an input screen for four fields, where you can select a date and time and enter values only for the necessary fields. Manually entered values are marked with an underline and an asterisk (*) to indicate that they are corrected values.

Since I enter my weight and body fat percentage every day, all of these values are adjusted figures. As for the step count on March 12, my Fitbit ran out of battery, and since I had left my phone behind, I’ve entered an approximate value.
Finally
Using the smartphone app I developed, Hc2Spread (HealthConnect to Spreadsheet), I retrieve step counts and sleep duration data from Fitbit and Google Fit. For weight and body fat percentage data, which aren’t imported automatically, I can now enter them into HealthConnect directly from this app. If the values are incorrect, I can now edit them in the app and update the data in the spreadsheet via Google Apps Script (GAS).

Ideally, I would have liked to eliminate the app on Appsheet, but since it excels at visualizing data through graphs, I’ve decided to keep using it while reducing the number of input fields. It’s hard to say for sure whether this constitutes an improvement, but I’m quite satisfied that I’ve been able to use generative AI to connect to HealthConnect and store the data in a spreadsheet for easier use.
Going forward, I’d like to explore “automation” and other approaches to further enhance the effectiveness of this system.