How to check Battery Health on iPadOS/macOS
Tags: apple, ruby, ipados, macos
Published: 2023-02-04 01:16:34

---
title: How to check Battery Health on iPadOS/macOS
published: true
description: 
tags: apple,ruby,ipados,macos
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-02-04 01:09 +0000
---

This article is also available on [Medium](https://medium.com/@TETRA2000/how-to-check-battery-health-on-ipados-macos-10ae60be1fe8).


If you have iPhone, you probably have seen Battery Health. It’s useful to check how much your battery is damaged by age. Unfortunately, it’s not available on iPadOS and macOS.

But it’s technically not true. There are same statics recorded in analytics logs. I’ll tell you how to see them.

First, you have to enable equivalents of “Share iPhone & Watch Analytics” on your devices.

[Share analytics, diagnostics, and usage information with Apple](https://support.apple.com/en-us/HT202100)

[Share analytics information from your Mac with Apple](https://support.apple.com/guide/mac-help/share-analytics-information-mac-apple-mh27990/mac)

Logs will be written on next 0:00 UTC once you’ve enabled these settings.

You can find logs from Settings app on iPad. (”Privacy & Security” ⇒ “Analytics & Improvements” ⇒ “Analytics Data”)

On Mac, they’ll be written on `/Library/Logs/DiagnosticReports/`(or will be moved to `/Library/Logs/DiagnosticReports/Retired/`).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7b32uq7nryffz34xnah.jpeg)


There are JSON files start with `Analytics-`. You can view on your text editor. You’ll find rows which contains `last_value_CycleCount`on its values. 

This line contains lots of statics. I’ll explain some of them I usually monitor.

- `last_value_CycleCount` seems to be charge cycle counts.(Same as it [on System Information app](https://support.apple.com/en-us/HT201585).)
- `last_value_MaximumCapacityPercent`seems to be “Battery Health” which available on iPhone.
- `last_value_NominalChargeCapacity` seems to be normalized battery capacity value which used to calculate “Battery Health’
- `last_value_DailyMaxSoc` seems to be highest value of the battery percentage on the day.
- `last_value_DailyMinSoc` seems to be lowest value of the battery percentage on the day.

Aside from above, `last_value_AppleRawMaxCapacity`is especially useful for me because I can see raw battery capacity values like before iOS 11.3. 

For example, my iPad mini has 5124 mAh battery. And current `last_value_AppleRawMaxCapacity`is 4757. So it’s roughly 93% battery health. It’s lower compared to `last_value_MaximumCapacityPercent` (”Battery Health”) which has 97 percent. It’s interesting. 🤔

It’s also interesting to watch changes of these values.



Finally, I’ll show you an example Ruby code to read these stats.

```ruby
require "json"

BATTERY_KEYS = [
  "last_value_CycleCount",
  # "last_value_AverageTemperature",
  # "last_value_DailyMaxSoc",
  # "last_value_DailyMinSoc",
  "last_value_MaximumCapacityPercent",
  "last_value_NominalChargeCapacity",
  "last_value_AppleRawMaxCapacity",
  # "last_value_batteryServiceFlags",
  # "last_value_ServiceOption",
  # "last_value_calibrationFlags",
]

Dir.glob("./*.{synced,core_analytics}") do |file_name|
  os_version = nil
  timestamp = nil
  messages = []

  File.readlines(file_name).each_with_index do |line, idx|
    data = JSON.parse(line)
    if idx == 0
      os_version = data["os_version"]
      timestamp = data["timestamp"]
    end

    message = data["message"]
    next unless message&.keys&.include?(BATTERY_KEYS[0])
    messages << message
  end

  puts os_version
  puts timestamp
  puts BATTERY_KEYS.join("\t")
  messages.each do |message|
    puts (BATTERY_KEYS.map do |k|
      message[k].nil? ? "null" : message[k]
    end).join("\t")
  end

  puts "\n"
end
```

Have fun!!