WhoBuilt

Connecting React Native App with Garmin Smartwatch

Sep 25, 2023· 21 min· 2.2K views·Watch on YouTube

Speaker

At React Native EU 2023, Callstack developer and competitive cyclist Małgorzata Mazurek-Biel explains how she connected a Garmin smartwatch to a React Native app to measure and analyze cycling cornering technique.

Why cornering matters

Mazurek-Biel describes cyclocross as a fast, technical sport with many turns and obstacles. She breaks cornering into assessing the turn and surface, choosing technique, and following a line that preserves speed and traction. She estimates using the technique around 100 times in a race.

Measuring a bike’s lean

Inspired by bank-angle measurements in motorbikes and aircraft, Mazurek-Biel set out to measure how far her bike tilts through a turn. She chose a Garmin watch because a phone would be less convenient, its sensors may be less accurate, and it is less resistant to mud and water. She uses accelerometer readings to calculate the angle, with extra calculations to correct the mirrored raw value.

Connecting Garmin to React Native

Garmin does not provide the direct Bluetooth connection she first expected. Instead, the watch sends messages through Garmin cloud services, which requires an internet connection and can introduce delays. On Android, Mazurek-Biel built a native module using Garmin’s library to find devices, track their status, connect to one, and pass incoming messages into JavaScript.

Recording and analyzing rides

The React Native app uses hooks and event listeners to manage device status and incoming messages, which it saves to a local database. In testing, she mounted the watch on the handlebar and compared bank angle with speed on a chart, alongside a track view with values for selected locations. The goal is to spot turns where she can maintain more speed and track progress in training.

Using data to improve technique

Mazurek-Biel says combining software development and cycling let her measure a part of performance she wanted to improve. She plans to use the app in technical training and analyze race laps to find where she can push harder and where she needs more practice. She says the code is available on GitHub.

Takeaways

  • Start with a specific performance question; here, it was how cornering technique affects speed.
  • Choose sensors and hardware for the conditions where the product will be used, including exposure to mud and water.
  • Check device vendor communication constraints early: Garmin messaging depends on internet access and can add latency.
  • A native module can bridge a vendor Android library into React Native when a ready-made integration is unavailable.
  • Pair sensor measurements with context such as location and speed so recorded data can guide practical training.

Mentioned in this talk

Search inside this talk

What was claimed 7

Related talks