Close

Finally got the accelerometer working on Time Machine Mk. 8!

A project log for Time Machine Mk. 8

An attempt at a DIY watch focused on low-power, high performance operation

eric-minEric Min 06/17/2023 at 07:310 Comments

After weeks of misery and head scratching, I finally got the accelerometer working for TM8. Huuuuuuuuge load off my shoulders.

There was a very small hardware quirk on the SAMD21G18 chip that was messing around with my SERCOM implementation. I set SERCOM2 on Time Machine Mk. 8 by calling

  pinPeripheral(4, PIO_SERCOM_ALT); // SDA: D4 / PA08
  pinPeripheral(3, PIO_SERCOM_ALT); // SCL: D3 / PA09

 , which worked fine for the LCD, but not for the LIS3DH accelerometer and BME680 temp sensor. After muck dicking around and googling, I found this GitHub issue, which led me to replace PIO_SERCOM_ALT with PIO_SERCOM, and voila, the accelerometer now works perfectly. So now my SERCOM setup code looks like this:

#include <Wire.h>
#include "wiring_private.h" // pinPeripheral() function

TwoWire wire1(&sercom2, 4, 3); // new Wire object to set up second I2C port on SERCOM 2

void setup() {
  Wire.begin();
  wire1.begin();

  pinPeripheral(4, PIO_SERCOM); // SDA: D4 / PA08
  pinPeripheral(3, PIO_SERCOM); // SCL: D3 / PA09
}

This is incredibly exciting because TM8's accelerometer has many exciting potential applications, such as free-fall detection, tap detection, or even cornering grip analysis for track driving! I don't have the BME680 working yet but it should be cakewalk. Coupled with the BME680's altitude sensing, Time Machine Mk. 8 can even be a skydive computer!

I'll keep the project updates rolling

Discussions