Some Bits: Nelson's log

5 posts in May 2021

My Grafana / Starlink setup

I did a bunch of work setting up Grafana to track my Starlink system and promptly forgot about it! Documenting it now.

I’m graphing Starlink stats using InfluxDB and Grafana. Telegraf is not involved.

The data collector is from starlink-gprc-tools. It runs as a background process and writes data in to InfluxDB. I haven’t changed the code from sparky8512’s repo, although I do have my own fork on Github.

I’ve installed a frozen copy in /usr/local/src on my Grafana server. Here’s the “collect” script that fires off the background process. This runs forever, no need for cron:

#!/bin/bash
stats="status usage obstruction_detail alert_detail ping_drop ping_run_length ping_latency"
interval=60

cd /usr/local/src/starlink-grpc-tools
source venv/bin/activate

python ./dish_grpc_influx.py -U starlinkstats -P PASSWORD -t $interval $stats

I haven’t really configured Grafana yet. I found some stock dashboard (in the repo?) that looks like the screenshot below. But it’s storing a lot more stats and I should drill into it at some point.

24 hours of Starlink ping performance

I finally got my TIG monitoring stuff to do a useful ping test of Starlink performance. See the graph below; it’s the result of sending 5 pings a second to 8.8.8.8 and measuring average response, packet loss, etc. I’m not positive but I believe the scale of this is 1 pixel = 60 seconds, or 60 samples. The way Grafana works, any time you see a red dot indicates there was some packet loss in that interval.

That’s an average of 45ms and 1.4% packet loss. 8.8.8.8 is just about next to the ground station at the other end of the satellite; if anything it responds faster to pings than the ground station that’s hop #2 on my traceroute.

Here’s a similar graph for the last 30 minutes, with 1 pixel = 1 second.

Within the 5 pings sent in one sample there’s not much variance in latency. But there is latency on the scale of minutes. Not sure if that’s me switching satellites, or me being buffered because of time division multiplexing, or what.

The really annoying thing is the packet loss, the red dots, particularly in an outage like at 18:30. Those correspond to real noticeable ISP outages of 5-20 seconds at a time. They seem to mostly happen when there are no satellites in view or when the only one is hiding behind a tree that’s in the way. That should get better as they add more satellites to the constellation.

45ms is pretty good for space based Internet! Sonic.net gets me 5ms on their fiber network, but they are astonishingly great. My fixed wireless WISP is more like 70ms.

Wellue / Viatom O2Ring pulse oximeter

I’ve been playing around with a Wellue O2ring, a wearable pulse oximeter. I’m using it to track my blood oxygenation while I’m asleep as a way to understand whether I have sleep apnea. The device works great! Some notes on it after a few days’ use.

Caveat: I’m not a doctor nor do I have any health or medical training. I’m just a software nerd who’s read some stuff about pulse oximeters. My only goal is to get myself better informed so I can talk to a real doctor about my health.

Hardware

The hardware is remarkable. Tiny little thing, about the length of a finger joint, comfortable and secure to wear. The pictures show it worn around your thumb but I’m a little thick for that and it works fine on most finger joints, I’m wearing it on the middle of my index finger. Note most pulse oximeters are duckbill sensors that fit over your fingertip; this is a little different.

The main sensor in it is the pulse oximeter. This is a fairly standard medtech; your finger is illuminated with a bright LED and the color of your blood is evaluated. Thanks to hemoglobin, oxygen-rich blood is bright red while depleted blood is darker. A simple sensor can measure the percentage of oxygen saturation in your blood reasonably accurately. In addition the O2Ring controls pulse rate and motion. The sensors record data every 4 seconds, or just about once every breath in a normal awake adult.

The device has a nice little OLED screen on it that shows time, current pulse, current SpO2. It also has a vibration function; you can set it to buzz your finger if you’re sleeping and your pulse rate or SpO2 drops to a certain level. It also has both USB and Bluetooth interfaces for exporting data. There’s a small touchscreen button to get its attention. The battery is charged via USB and lasts about twelve hours.

All in all the quality of the product is very, very good. This is a Shenzhen-designed product and it’s an example of the best of that engineering. My favorite feature is the device starts recording automatically when I put it on (sensing my finger) and works entirely standalone; no need to tether to the phone while recording. My only complaint is the rubber finger cuff that holds the product on isn’t replaceable, at least not obviously. But it seems sturdy though, I’ve read reports of people using these things nightly for a year+. I paid about $160 for the device; not cheap, but given the quality not unreasonable.

Software

There are two choices of software from the manufacturer, both of which download and graph data for you. The desktop app “O2 Insight Pro” is the better of the two IMHO; it gives a nicely formatted PDF with an overview on the first page with summary stats like “average pulse rate” and “time below 90% SpO2”. Then detailed graphs showing second-by-second measurements of SpO2%, pulse rate, and motion. The mobile app also shows a summary and a graph but the graph is limited to the device screen so you can’t see detail, just the general pattern.

Both apps have CSV export if you want to do your own graphing and analysis. The desktop app writes data in a binary format to your hard drive. There’s support in OSCAR (an open source sleep apnea app) for importing data under the heading “Import Viatom”. The source code for that is simple; basically a 40 byte header and then a bunch of 5(?) byte records all in basic little endian binary numbers.

What does the data mean?

I like the product but it comes with precious little material telling you what the reports actually mean. Here’s some notes on that.

Normal SpO2% while awake is 94-99%, which is nearly full saturation. Folks who have severe respiratory disease (say, Covid) are below 94% for long periods of time and this is dangerous. From what I’ve read being regularly below 94% is “talk to your doctor” territory and below 90% is “consider the emergency room”.

I’m mostly interested in blood saturation when I’m asleep. I’ve tried reading about that but I get a little confused because there’s three different measures: SpO2%, which the O2Ring gives. Then SaO2% which I think is a measure specifically of arterial blood? And people talk about PaO2, partial oxygen pressure. Various studies quote numbers in terms of one or the other and while I know they’re correlated, I’m not sure in what important ways they are different. But, soldiering on...

When asleep, normal people have a blood saturation of 90-99% most of the time. (Or maybe 93-98%).

People with sleep apnea experience oxygen desaturation events, where SpO2 falls below 88% as they stop breathing. Check out Figure 1 in this paper for a detailed illustration of two minutes of this. In this patient SpO2 is often down below 70% and every 50 seconds or so bumps up to 95% briefly as they take a breath.

Sleep apnea is diagnosed by measuring the number of these apnea events in a score called the AHI, Apnea Hpyopnea Index. An AHI of under 5 events an hour is considered minimal; over 30 is severe.

It’s tempting to think you could diagnose sleep apnea solely by measuring SpO2%. The O2Ring software sort of encourages this, with a simple summary that shows counts of “drops over 3%” and “drops over 4%”. But SpO2% alone is not how sleep apnea is diagnosed. Real sleep studies use pulse oximetry and pulse rate, for sure, but even the simplest at-home type IV tests also measure air flow. Fancy in-lab type II tests also have various EEG measurements. A real sleep study also requires a trained professional to interpret the results, the diagnosis is not reduced to a simple measurement like “X drops in SpO2% per hour”.

However at-home SpO2% monitoring with a consumer device like the O2ring does seem to give someone a relatively easy way to measure at least part of their health in sleeping. Also according to this paper ODI is correlated with apnea, but not perfectly. I’ve already found it a useful tool for understanding things like the effects of different sleeping positions. And like I said, my real goal is to get some insight into what’s happening with me while I’m asleep so I can better inform a doctor.

Bottom line: the O2ring is impressive hardware with adequate software. I’m finding it useful!

Plotter greeting cards

Finally made some purpose-driven art with the AxiDraw; a design for use on custom greeting cards. Materials are some Pentel felt tip pens on simple 80lb cardstock. Nothing fancy but I like the result.

Unfortunately the effect doesn’t photograph well. What’s here are a bunch of nested squares drawn in alternating colors. On the left is medium blue over pale purple, on the right is medium blue over a light orange. The effect is a weird op/art blending though, it looks like a complicated mottled texture rather than a bunch of distinct lines.

There’s one clever trick here.. the underlying color is drawn with straight lines, but the overlay color was drawn with some noise thanks to vpype’s squiggle filter. That gives the whole thing a less machine-drawn feel and lets a bit more of the undercolor seep out. I still wanted to have the feel of a page filled with color though, so there’s little to no white paper showing through.

I love some of the artifacts here. Particularly on the border, where there’s a software crop. The little dots of ink as the pen rests are great. I’m less excited about the dots in the middle. I used reloop to randomize their positions some but that only really works great on the squiggle layer (on the straight layer there’s only 4 possible start spots for each loop). I should try this with higher quality pens that don’t bleed ink at all, it’d look cleaner. Maybe the squiggle noise is all I need for crunchiness.

Here’s a closeup of a rasterization of the lines showing the squiggle trick. You want to zoom this image to 100% for it to make sense.

ISP data usage pre-Starlink

Before I had Starlink, I was downloading about 175 GB a month via my WISP. My data cap is just about double that, 350 GB, although I’m not sure they enforce it. Note this isn’t really all the Internet I would like to use; because it’s only 12 Mbps and I have the cap in the back of my mind, I avoid making really big downloads and truck files in with a hard drive sometimes instead.

As you can see from the months of March and April my usage of the WISP is way down now that I have Starlink. No surprise; I’ve shifted my heaviest uses of traffic (game console, TV, my desktop) over to it.

I’m stuck paying for both ISPs for awhile; Starlink isn’t quite reliable enough.