Close
0%
0%

Color Open Source Smartwatch

Reverse engineering the SMA-Q2 smartwatch to run open source firmware on it

Similar projects worth following
SMA-Q2 also known as SMA TIME is a Chinese smartwatch featuring a color Memory LCD, heart rate sensor and a NRF52832 Bluetooth SoC to drive it all.

Its low price, cool features and simple construction make it look like a prefect platform for an open source smartwatch firmware.

Firmware

Original firmware

The original firmware runs on S132 SoftDevice ver 2.0.1.

The device contains an OTA bootloader that can be used with the generic Nordic upload tool, so new firmware can be uploaded safely.

Custom firmware

The chip is locked, so if you want to use your own firmware you have to use the built-in OTA bootloader or erase the whole chip to remove the lock.

Hardware

Hardware Components

NRF52832-QFAAB0
Main SoC
LP2985 (?)      
 3.3V LDO for everything
LP2985 (?)
3.3V LDO for heart rate sensor module
RT9526 (?)
Battery charger
KX022-10203-Axis accelerometer
PAH8002Heart rate sensor
GD25Q16C16Mbit SPI flash
LPM013M126A176×176 Japan Display Color memory LCD   

Main MCU

Nordic Semiconductor NRF52832.
32-bit ARM Cortex-M4F CPU with 512kB flash and 64kB RAM and of course Bluetooth.

MCU pinout:

Pin

Description

P0.02

LCD SCLK

P0.03

LCD SI

P0.05

LCD SCS

P0.06

LCD EXTCOMIN

P0.07

LCD DISP



P0.04

Battery voltage measurement (x0.25 divider)



P0.08

BACKLIGHT ON



P0.09

BUTTON BACK

P0.27

BUTTON UP

P0.28

BUTTON OK

P0.29

BUTTON DOWN



P0.11

FLASH MISO

P0.12

FLASH CS

P0.13

FLASH MOSI

P0.14

FLASH CLK



P0.25

UART RX

P0.26

UART TX



P0.30

VIBRATOR ON



P0.15

ACCEL INT ?

P0.16

ACCEL POWER

P0.17

ACCEL SDA

P0.18

ACCEL SCL



P0.19

HRM SDA

P0.20

HRM SCL

P0.22

HRM INT ?

P0.10

HRM RESET ?

P0.31

HRM POWER ON



P0.23 CHARGER STATUS ?
P0.24 CHARGER POWER GOOD ?

3.3V LDO for system

Unknown chip, but similar to LP2985. Powers the whole thing

3.3V LDO for heart rate sensor module

Same as above. Powers the PAH8002 heart rate sensor module.
Enable pin controlled by the MCU.

Battery charger

Unknown chip, seems like a generic linear li-ion battery charger IC.

Possibly a Richtek RT9526, the pinout seems to match.

Accelerometer

Kionix KX022-1020 3-axis accelerometer.
Communication over I2C. Powered from an MCU pin!

Heart rate sensor

PAH8002 heart rate sensor with green and infrared LEDs. Mounted on the back plate of the watch, connects to the mainboard with a ribbon cable.
Communicates over I2C.
I have managed to dig up the complete datasheet and application note.

External Flash

GigaDevices GD25Q16C 16Mbit (2MB) SPI Flash.

LCD

LPM013M126A 176×176 Japan Display Color memory LCD.

Driven with SPI. Has a LED backlight controlled...

Read more »

SMA_Q2_HRM2.txt

I2C bus sniff after starting the HRM function. Finger on sensor. Stopping measurement at the end.

plain - 155.80 kB - 01/09/2019 at 11:23

Download

SMA_Q2_HRM.txt

I2C bus sniff after starting the HRM function. Finger not on sensor.

plain - 77.04 kB - 01/09/2019 at 11:19

Download

plain - 48.67 kB - 01/01/2019 at 15:00

Download

  • Join us on IRC

    emeryth10/25/2020 at 08:53 0 comments

    I know this project looks dead, but that's because the watch is hard to find and I was the only one developing for it.

    But there is some renewed interest in the firmware, so join us on Freenode IRC channel #smaq2oss

  • Firmware update: notifications and security

    emeryth03/10/2020 at 12:41 7 comments

    The work is not complete, but with this update, the firmware has all the most important smart watch features.

    I've added call and message notifications. The user interface is rather crude, but they serve their purpose.

    I've also secured the connection between watch and phone with maximum BLE security, including pairing with passkey check on both sides.

    In terms of power consumption, I have confirmed a 12-day battery life. But that was before message notifications, which might eat up some more energy.

  • Firmware update: Menu system and two-week battery life

    emeryth02/09/2020 at 14:14 3 comments

    I've redesigned the way screens/apps are handled and introduced a main menu.

    More importantly, I have managed to get the average current consumption down to 350-550uA (1.5mA previously)!

    Turns out a huge chunk of it - 800uA, was a bug in the TWI (I2C) peripheral. Documented in the errata as Anomaly #89, the peripheral does not actually stop consuming power when disabled. Fortunately there is a simple software fix for it.

    Another gain was from a small change in the notoriously power-hungry FreeRTOS implementation for nrf52.

    Two weeks might be exaggerated, but based on my previous measurements, I expect at least 9 days of normal operation. To help with monitoring, I've added a battery app that shows a charge history graph.

    One grid interval is 12 hours (X) and 20% of charge (Y). In this case the slope shows an expected 3 day lifetime - this is with the previous 1.5mA consumption!

    UPDATE:

    Looks like the current consumption fixes really did make a difference and are in line with my 9 day lifetime expectation.


  • Custom board v2 and Arduino firmware for it

    arthur_jordan0502/05/2020 at 11:24 0 comments

    The new version of the custom replacement board (2 variants) is out. There's also a basic Arduino firmware with tons of features demonstrating most hardware comonents, drawing about 1000µA in dualMode (BLE central and peripheral active at the same time).

    https://github.com/BigCorvus/SMA-Q2_replacement_board_v2

    https://github.com/BigCorvus/SMA-Q2-nrf52840-dualMode-firmware

  • New watchface, weather, music control

    emeryth01/21/2020 at 19:57 0 comments

    I decided to lay my pebble watch to rest, so now I am motivated to make the SMA-Q2 firmware actually useful.

    I have designed a new watchface including current weather form Gadgetbridge. I have also added basic music control support, although the song info is not yet transmitted from the phone. That is because I need to decide on a protocol for transmitting large packets of data.

    Along with those updates, I have also improved the current consumption, mostly by redrawing the screen only when it is needed. Consumption now oscillates around 1.5mA which should give about 5 days of battery life.


    I can already see I will have to heavily modify the current graphics library (Nrf GFX) or find a better one.

  • Firmware source

    emeryth10/21/2019 at 23:03 2 comments

    I have uploaded my firmware source:

    https://github.com/Emeryth/sma-q2-oss

    It's based on nRF5 SDK 11.0 and FreeRTOS.

    I have also uploaded my fork of Gadgetbridge that lets you connect to the watch:

    https://github.com/Emeryth/Gadgetbridge

  • Custom and open source hardware!!

    arthur_jordan0510/17/2019 at 09:15 2 comments

    For you hardware hackers out there:  there is now a custom replacement board for the SMA-Q2 based on the nrf52840 with a custom purely analog pulse sensor. If you manage to open the watch (it IS possible without breaking anything) it is quite easy to install. You'll have to leave out the plastic frame holding the battery. Firmware updates can be made over USB now...I've only flashed the current Adafruit bootlader right now and the thing shows up as a mass storage device. Not done any programming yet.

    https://github.com/BigCorvus/SMA-Q2_replacement_board

    https://github.com/BigCorvus/PulseSensor-for-SMA-Q2

    Not sure whether this whole RTC-based power management stuff is really necessary since the chip can run on really nice low power modes, but this can also be omitted in future revisions. All basic housekeeping (LDO, charger, buttons, accelerometer, display connectors, vibration motor driver...) is in place and the dimensions are correct.

  • Kept you waiting, huh?

    emeryth10/16/2019 at 14:22 4 comments

    I have been very slowly working on the project.

    I now have a very simple firmware (based on Nordic SDK and FreeRTOS) that showcases all the hardware in the watch, and basic integration with Gadgetbridge (smartphone app).

    I'm working on publishing the source now.

    Heart rate monitor
    Heart rate monitor

    The heart rate monitor outputs raw waveforms and it's up to the firmware to analyze them.

    There is a binary library from Pixart for that, but because it requires 13kB of RAM I don't want to use it.

    With simple filtering and FFT I've managed to get a pretty good result, compared to a chest strap sensor.

    Unfortunately the slightest movement disturbs the PPG reading, so it may never be useful for fitness tracking.

    The accelerometer has built-in tilt and tap detection that works great. It's interesting that the original firmware did not use them at all.

    I haven't ported DOOM yet, but have a Tetris clone by my friend [msgctl]:

  • A bit of bad news

    emeryth04/08/2018 at 15:48 2 comments

    A few months after release, the watch has received a slight silent mechanical redesign.

    Most noticeably, the buttons are now oval instead of round (and feel nicer).

    Unfortunately for the hardware hackers, the screws on the back that held the watch together are now GONE!

    Left: old watch, right: current version

    I don't see any seams on the back, I'm afraid the watch is now glued together and has to be disassembled from the LCD "glass" side.

    I'm pretty sure the electronics remain the same, because there is no mention of different watch versions when downloading firmware.

    Still, the watch remains entirely hackable without disassembling.

    You can upload your own firmware through OTG, you just have to be more careful.

    If you soft brick it somehow, you will have to wait for the battery to die to let you reset and go into the bootloader again.

  • Dumping the internal flash

    emeryth03/19/2018 at 18:34 0 comments

    The MCU on board is locked, which means you can't do anything over the debug interface unless you do a total chip erase.

    I wanted to dump the internal flash to get the bootloader and perhaps some other interesting stuff.

    Since I already have the ability to upload my own firmware, dumping the flash over UART seemed straightforward, but turned out to be not so simple.

    For some reason I just could not receive the full dump without interruption.

    At first, I blamed the notoriously flaky NRF52 UART when used without flow control. But even when I added flow control by using the SPI flash testpoints, it wouldn't work.

    Many hacks later I realized it's the MCU that's resetting periodically.

    Turns out the bootloader is enabling the watchdog!

    With a reload value of 0x50000 it gives you exactly 10 seconds.

    Once I fed it properly (via the RR0 register), I could get the full dump.



    The flash layout is standard - Softdevice, followed by user firmware, followed by the OTA bootloader at 0x76000.

    There is a tiny bit of data between the firmware and bootloader, that may be the persistent app data partition.

    The UICR registers are also unused, except for the bootloader addres and bootloader data page.

    NRFFW[0]:00076000
    NRFFW[1]:0007E000

View all 11 project logs

Enjoy this project?

Share

Discussions

JVS wrote 02/25/2021 at 21:38 point

Cant find this watch, is it still being produced?

  Are you sure? yes | no

Ken Yap wrote 10/25/2020 at 10:53 point

Is that the temperature? Brrr!

  Are you sure? yes | no

arthur_jordan05 wrote 10/25/2020 at 07:24 point

The same company

https://www.smawatch.com

seems to be releasing a SMA-Q3. Unfortunately it's also glued together. Maybe it has the same/similar internals? It's cheaper as well, but only has one button.

https://www.alibaba.com/product-detail/2020-Best-seller-Smart-watch-SMA_60760372855.html?spm=a2700.icbuShop.41413.11.2f735091ktt8FK

Edit: lol, check this out:

https://fccid.io/2AKUO-10/Letter/Family-model-letter-3314061

they're declaring that differences should be marginal between a SMA-Q2 and an SMA-Q3. 

  Are you sure? yes | no

emeryth wrote 10/25/2020 at 08:45 point

Good find with that FCC document.

I have been monitoring the SMA alibaba page, but sadly I don't see any potential in their new designs. I really miss physical buttons.

  Are you sure? yes | no

arthur_jordan05 wrote 10/25/2020 at 14:24 point

I wonder how this thing is supposed to work with only one button without a touchscreen. Some of those cheapo trackers have a touch button but that's also lame. It's a shame. The SMA-time was such a perfect concept. And then came the sealing madness.....and then the whole thing disappeared. Ridiculous.

I'm playing with Aaron Christophel's P8/Pine Time firmware at the moment which is really cool too. The P8 is ubiquitous and costs 15 rediculous € and for some reason has almost the same pinout as the Pine Time. The latter looks better and will be available for some time I hope. 

But still: nothing compares to the cool memory lcd. Would take it over any of those fancy AMOLED things.

  Are you sure? yes | no

Matias N. wrote 10/26/2020 at 01:50 point

I'm hoping the Q3 becomes more widely available and does not disappear as fast as the Q2 did. I'm really digging all the sensors it has. Still, one button + touch screen is better than just one touch button, as the Kospet DK08 has.

  Are you sure? yes | no

JVS wrote 02/25/2021 at 21:40 point

What about the other models? they got a ton, the M3 even has GPS

  Are you sure? yes | no

Daniel Rodríguez Rivero wrote 09/16/2020 at 08:23 point

Seems to be available in some stores, but the price has raised significantly (up to $80). Did anyone found a reasonable price at any place?

  Are you sure? yes | no

Matias N. wrote 09/22/2020 at 22:11 point

I tried fasttech and eventually they informed it was discontinued. I bought a Kospet DK08, mostly to get the screen (which is worth double on digikey): https://www.gearbest.com/smart-watches/pp_009567360092.html?wid=1433363

  Are you sure? yes | no

Matias N. wrote 08/25/2020 at 17:38 point

Do you know about the difference between Q2 and Time? They are differently priced and have a different external case

  Are you sure? yes | no

emeryth wrote 08/31/2020 at 19:53 point

They are the same thing. Some time after release they redesigned the case: new buttons and glued together instead of screwed. I actually have one of the old ones. The electronics are the same.

  Are you sure? yes | no

Matias N. wrote 08/31/2020 at 19:56 point

Cool thanks. I bought the TIME from fasttech as it has screws as you mention (the Q2 is already the newer one without screws).

  Are you sure? yes | no

Matias N. wrote 09/01/2020 at 13:45 point

Fasttech has answered that the TIME is discontinued. I asked if they can ship the Q2 but my guess it will be the same.

If anyone finds a link for the TIME or the Q2 it would be really appreciated. It is too bad that such a hackable smartwatch with this display and chip is no longer to be found =(

  Are you sure? yes | no

Romain wrote 07/13/2020 at 20:47 point

Does anyone knows where we can find this watch these days? It's seems it's not on aliexpress anymore!

  Are you sure? yes | no

emeryth wrote 07/13/2020 at 20:52 point

Unfortunately it's been sold out and out of production for months.

Fasttech.com claims to have some, but that may be bs.

  Are you sure? yes | no

Romain wrote 07/14/2020 at 20:41 point

Thanks for this! That's what I thought. I'll look at fasttech to see what's up. But this would be a perfect platform for my sailing autopilot remote project!

  Are you sure? yes | no

Matias N. wrote 08/25/2020 at 17:09 point

Anyone bought from them? Would like to know if they are legit

  Are you sure? yes | no

NurlanZ wrote 06/12/2020 at 14:30 point

Hi.

I am using Emeryth/sma-q2-oss firmware, and  Emeryth/Gadgetbridge  application
During pairing, a red crash appears on the watch.
E:4001,0,200048EC
E:0x3
Someone can advise something?

  Are you sure? yes | no

x29a wrote 08/06/2021 at 08:06 point

this might be the same problem like here https://github.com/Emeryth/sma-q2-oss/issues/3 - could be solved

  Are you sure? yes | no

Rajeen Nabid wrote 03/01/2020 at 15:22 point

I'm a big fan of this project.  I got the watch, toolchains, and compiled everything.  I modified my source to display date/time in my preferred format and weather info in my preferred units.  I'm going to write a watchface now, and I soon hope to be able to incorporate it seamlessly into the UI.

  Are you sure? yes | no

enricorov wrote 03/01/2020 at 19:52 point

Cool! I just found out about this. Can one just buy a smartwatch and flash away?

  Are you sure? yes | no

Rajeen Nabid wrote 03/01/2020 at 21:05 point

if you follow the directions exactly, sure.  Notes: NRF SDK version 11.0 is not the latest.  When you install android studio, make sure to install the version 28 API and accept its licenses.   You have to use python 2.7 (deprecated) to install nrfutil 0.5.2 to package the zip for DFU.  After that, it really is easy mode.  I'm using mingw-w64 on windows x86 on my home computer, but it was far easier to get everything to compile using cygwin on the work laptop.  Mostly, I had to apply the twi patch by hand because getting "patch" is nontrivial on windows.

I suspect this would all be trivial on a linux system that has a robust tool suite already. 

  Are you sure? yes | no

arthur_jordan05 wrote 10/16/2019 at 13:18 point

Preliminary and dirty Arduino firmware III is out. 

https://github.com/BigCorvus/SMA-Q2-Firmware-3

It's usable as a basic watch with Nordic UART service now. Power consumption is about 50µA so it lasts about 10 days. Accelerometer works, but the HR sensor does not. At least I get the library to compile within the IDE.

Emeryth , would you mind sharing your current progress? I'm too curious.

  Are you sure? yes | no

Jacob MacLeod wrote 10/01/2019 at 08:54 point

How expensive is this to make?

  Are you sure? yes | no

emeryth wrote 10/16/2019 at 16:29 point

The watch costs around $40 on aliexpress.

  Are you sure? yes | no

James Hall wrote 09/26/2019 at 16:38 point

Have you heard about the PineTime watch? Sounds interesting: https://wiki.pine64.org/index.php/PineTime

  Are you sure? yes | no

emeryth wrote 09/28/2019 at 07:50 point

Yes, I hope this will lead to more interest in some kind of open smartwatch ecosystem.

I still think the SMA-Q2 has superior hardware :P

  Are you sure? yes | no

arthur_jordan05 wrote 09/23/2019 at 14:22 point

some interesting discussion about coding for for the SMA-Q2 using the Arduino IDE has been going on under this video lately:

https://www.youtube.com/watch?v=3gjmEdEDJ5A&t=825s

https://www.forward.com.au/pfod/BLE/LowPower/index.html is a low power mod for the sandeepmistry core which implements some slightly weird but also convenient stuff. I've written a custom SMA-Q2 firmware based on this core now. Power consumption is quite nice. (45µA with display on and 500ms advertising interval, with some thin current spikes in between). Code will be published as soon as it has matured a little.

  Are you sure? yes | no

emeryth wrote 09/23/2019 at 21:13 point

Thanks for the info. I know this project looks dead, but I *am* working on it slowly.
Recently I got very close to getting the heart rate sensor to work.

I have also had success with adding very basic support for my firmware to Gadgetbridge, which is an android app for managing smart watches.

  Are you sure? yes | no

deʃhipu wrote 09/23/2019 at 21:28 point

That's great news to hear! A project log once in a while couldn't hurt, even if it was just a photo of your testing rig, or a short "now working on this". Just saying.

  Are you sure? yes | no

arthur_jordan05 wrote 09/26/2019 at 14:16 point

Great! I assume you're still using the Nordic SDK? Which IDE are you using? Ireally like Segger embedded Studio that is easy to use withe more recent versions of the SDK, but I havent't managed to make it work with the SDK 11.0

Aaron Christophel was able to find a precompiled algorithm library for the PAH8002 by the manufacturer so they seem to be around somewhere...are you using that in your implementation too? I heard that otherwise these sensors are hard to get useful data from the wrist area....

Btw. the first revision of my nrf52840 replacement board seems to have bugs on it and is not working properly. Was able to upload the bootloadervia SWD and it even showed up as a USB device once but now I can't upload anything anymore. Dammit. I have to overcome my laziness and finally publish the current design.

  Are you sure? yes | no

emeryth wrote 09/28/2019 at 08:03 point

Yes, I'm using Nordic SDK. As for IDE I'm using regular eclipse with gnu arm eclipse plugins for debugging over openocd.

I just got PAH8002 to work using that precompiled library. I get reasonable readings now.

The drawbacks are that it's not open obviously, and it needs 13kB of RAM to run.

But looking at the raw waveforms from the sensor, it really needs some serious DSP.


I hope to publish my basic firmware soon.

  Are you sure? yes | no

arthur_jordan05 wrote 09/28/2019 at 09:03 point

Awesome! Really looking forward to having a look

  Are you sure? yes | no

arthur_jordan05 wrote 03/04/2019 at 13:36 point

Currently designing a custom replacement board with an nrf52840 module somewhat based on the feather board. It will also feature a https://abracon.com/realtimeclock/AB-RTCMC-32.768kHz-IBO5-S3.pdf RTC which is supposed to make programming easier. It will take care of generating the extcomin signal and minute-wise updates of the display. In between the updates the MCU can be turned off completely which will lead to very low  overall power consumption of the watch. That way one can just write Sketches for the nrf52840 without having to engineer low power stuff, so one should have a reliable device capable for everyday use. The final design is supposed to have native USB for DFU und other communication via the charging cable which has a USB plug connected to the  four contacts anyway. The accelerometer will be a BMA400 and the heart rate sensor based on https://pulsesensor.com sitting on a custom flex PCB connected to an analog input.

  Are you sure? yes | no

Kian wrote 01/20/2019 at 13:59 point

Hi everyone, I just got one of this watch and I am trying to see how I can program this. Has anyone manage to program this using OTA.

I have some experience in writing programs for the nrf52832 and can compile and upload programs onto the nordic development boards for testing. I am however clueless on how I can actually upload some program onto the watch using OTA.

Which SDK version do I need to use? I am using Keil. So I just compile my program as what I use to do and generate the Hex file. I am able to put the watch to OTA mode, and I have transferred the hex file to my mobile phone running the nRF toolbox app. I start the DFU program on my phone and I selected the hex file as an application. Then I got this message:

**********************

Init packet

Do you want to select the init packet file?

The init packet file (*.dat) should contain the device type and revision, application version, list of supported Soft Device and firmware CRC in binary format.....

*********************

I don't know what to do and where to find this file. So I just clicked Yes, and select the same hex file again.  I then select the device, in this case the phone see  the device "Dfu10B10". I selected this and click on UPLOAD.

Then the app just stays at Uploading..... Starting DFU....and nothing happens. 

Now the watch is forever stucked in the OTA mode.

  Are you sure? yes | no

emeryth wrote 01/21/2019 at 19:12 point

You have to use SDK 11.0 to be compatible with the old softdevice that is on the watch.

To generate the update package I use an old version of nrfutil with the following command:

nrfutil dfu genpkg --application application.hex --application-version 0xffffffff --dev-revision 0xffff --dev-type 0xffff --sd-req 136 app_dfu_package.zip

See the original firmware package for reference what it should contain.

  Are you sure? yes | no

Francisco wrote 12/21/2018 at 06:16 point

Hello, accelerometer is working with micooke library:

https://github.com/micooke/arduino-nRF5-smartwatches/tree/master/libraries

Just change the Wire interface in variant.h:

#define PIN_WIRE_SDA         (17u)
#define PIN_WIRE_SCL         (18u)

 Best,

Francisco

  Are you sure? yes | no

fabianpie wrote 12/28/2018 at 19:58 point

Gracias Francisco !!!

By the way, did you find a library for heart rate sensor ?

Best,

Fabian

  Are you sure? yes | no

Francisco wrote 12/28/2018 at 20:13 point

No I didn't.

I was trying to port one that I found from mbed, but inside the code It calls to a file with an algorithm from the company that built the chip. And that files seems that is not on the web.

Best,

Francisco 

  Are you sure? yes | no

fabianpie wrote 02/17/2019 at 06:53 point

Hi, anybody implemented a step counter with this accelerometer or have any reference code ?

Thanks,

Fabian

  Are you sure? yes | no

fabianpie wrote 07/14/2019 at 05:14 point

Hi Francisco,

Have you developed anything for the heart rate sensor this year ?

Best,

Fabian

  Are you sure? yes | no

arthur_jordan05 wrote 09/23/2018 at 12:22 point

Display library is online now. https://github.com/BigCorvus/ColorMemLCD

The example also explains how to feed the watchdog.

The RTC library is here: https://github.com/arduino-org/arduino-core-nrf52/tree/master/libraries/RTC. If you use the Adafruit core 0.8.5. only the line #include "nrf_clock.h" has to be commented out and the library works.

Having trouble getting the accelerometer to work. Tried several libraries without success. 

  Are you sure? yes | no

fabianpie wrote 09/27/2018 at 04:25 point

Hi, I'm waiting for my samples to contribute. By the way have you tried this library https://os.mbed.com/teams/Rohm/code/KX022/ ?

  Are you sure? yes | no

arthur_jordan05 wrote 09/28/2018 at 09:31 point

Haven't tried ports of the mbed lib you mentioned yet, but several other Arduino libraries instead.  (https://github.com/micooke/Kx022-1020, https://github.com/jgromes/RohmMultiSensor, https://github.com/goran-mahovlic/nRF51_ID107_libs) When I have some spare time left I'll hook up a logic analyzer and check the activity on the bus...

The power and reset management has to be done by the application itself: Created an example now: https://github.com/BigCorvus/SMA-Q2-Arduino

  Are you sure? yes | no

fabianpie wrote 10/10/2018 at 06:19 point

Still waiting for my samples :) There was a delay at Spain customs because of the batteries ... Any news about the accelerometer and or heart rate ? I hope to get my samples soon in order to contribute with the project.

  Are you sure? yes | no

arthur_jordan05 wrote 10/13/2018 at 08:08 point

unfortunately not. Lots of worki worki. But I've started coding the library for the heart rate sensor. Ordered another device so there is one for development and power consumption measurement and one for actual usage ^^

  Are you sure? yes | no

fabianpie wrote 11/10/2018 at 04:17 point

Hi, Arthur. I'm receiving my SMA-Q2 on Monday, if you have any work of accelerometer and/or heart rate please share in github or any place to collaborate in the development.

Thanks,

  Are you sure? yes | no

arthur_jordan05 wrote 11/13/2018 at 08:10 point

Hi Fabian

unfortunately, my time for the hobby is virtually non-existent at the moment, but my first steps in writing the PAH8002 library are here: https://github.com/BigCorvus/PAH8002/blob/master/README.md 

This is just a starter and the code is not working yet. It has to be brought into shape with adaptation of the I2c write/read functions etc.. Feel free to contribute ;) If I advance, I'll update the repository.

  Are you sure? yes | no

fabianpie wrote 11/25/2018 at 04:47 point

Hi Arthur,

I received my SMA-Q2. I compiled https://github.com/BigCorvus/SMA-Q2-Arduino with AdaFruit 0.9.1 to avoid nrf_clock.h error and exported binary and then create de zip with nrfutil-0.5.2 of AdaFruit 0.8.5. I used NRF tools selecting the zip and when I have to select ALL, SYSTEM or APP I selected APP. The firmware was uploaded the progress bar in OTA of SMA-Q2 reach the end  but the application never started. Any idea ? Do you think the problem could have been to use 0.9.1 core instead 0.8.5 I have other SMA-Q2 but I want to recover this one I hope with having to disassembly the watch. Please give me any advice.

Thanks ,

Fabian

  Are you sure? yes | no

arthur_jordan05 wrote 11/25/2018 at 12:25 point

I think you should compile this firmware only with the core it was written for (0.8.5 in tihis case). Throughout the core updates the Adafruit folks might have implemented changes that are not compatible to the sketch. 

We do not necessarily need the newest core here since we have an old softdevice at our disposal. The potential do implement fancy stuff via the low level API is still there with the 0.8.5 core I think. You just have to study the examples of the "raw" nordic SDK und port the functions you need to Arduino. This is how I implemented the watchdog feeder for example. 

If the DFU screen is persisting, the error might as well be in the pin definition file for the display pins. Have you re-defined the SPI pins in the variant.h file? If the code is not running properly the watchdog might not get fed. Try holding down the OTA DFU button combo for at least 10s. Maybe the thing will reset and get into DFU mode. Otherwise try the back button for some seconds and then the up button to turn back on in case the actual code IS running without the display being driven properly.

Good luck!

  Are you sure? yes | no

fabianpie wrote 11/25/2018 at 17:30 point

Hi Arthur, I confirm your examples only work with Adafruit core 0.8.5. Now I have a working environment. Thanks !!!!

By the way I'll start with the accelerometer could you share your work to move forward from there ? 

  Are you sure? yes | no

arthur_jordan05 wrote 11/25/2018 at 19:15 point

well done! I'm curious what you will come up with. Unfortunately I didn't keep the code I for the accelerometer, mainly because it didn't work at all and because it was too simple (it would have produced a non-working primer sketch and nobody wants that!).

There are several Arduino libs for the KX022-1020. Just try them, most of them are easy to use. Don't forget to set the I2C pins in the variant.h file. I hope that you do better than I did. I just don't have the time to advance this topic right now, although I would love to.

  Are you sure? yes | no

fabianpie wrote 12/19/2018 at 15:57 point

Hi Arthur, I was trying to connect the accelerometer. The chip is there as it answers to the address but it doesn't. Did you have time to check the bus with a logic analyzer with the manufacturer firmware ? I don't have one ...  If you could get of the information exchange I could dig in the documentation and create a library.

It would be also great to have a dump for the pulse rate chip.

I hope you have a bit of time.

Best,

Fabian

  Are you sure? yes | no

Francisco wrote 12/21/2018 at 08:31 point

Hello Fabian,

I´m using the library from micooke:

https://github.com/micooke/arduino-nRF5-smartwatches/tree/master/libraries

Just change the Wire interface in variant.h:

#define PIN_WIRE_SDA         (17u)
#define PIN_WIRE_SCL         (18u)

 Best,

Francisco

  Are you sure? yes | no

arthur_jordan05 wrote 01/01/2019 at 15:06 point

Happy new year!

I hooked up a logic analyzer to the accelerometer bus and recorded the activity upon power-up:

https://cdn.hackaday.io/files/854633656448992/accelQ2.txt

Still need to make sense of the data. 

Did you actually get useful data from micooke's library Francisco? I wasn't able to get the library to work. Thanks for joining us.

Best, Arthur.

  Are you sure? yes | no

fabianpie wrote 01/01/2019 at 18:15 point

Hi Arthur. Happy new year !!

For micooke's library try changing in variant.h  #define PIN_LED1 (17) to other pin. If I read in every loop and show the values in the display I'm having problems to show the values so I'm using something like: 

if (millis() - accSampleTimer > 20) { // 20ms = 50Hz 
    accSampleTimer = millis();
    acc.getAccelXYZ(xyz);

}

Best,

  Are you sure? yes | no

fabianpie wrote 01/01/2019 at 18:25 point

By the way if anybody can capture any data from heart rate please share the code. I'm trying to contact the manufacturer to get the algorithm if not i'll try to analyze the data to try to define the pattern to calculate the heart rate.

Thanks,

  Are you sure? yes | no

arthur_jordan05 wrote 01/06/2019 at 15:04 point

aaah OK, I didn't notice that pin 17 was already taken by the LED. Thank you! I'll try to capture the I2C communication on the heart rate sensor lines and upload the file. 

I don't think we necessarily need this algorithm. Most important ting is to interface to to the sensor, get the data and figure out how to get into low power modes etc. If we get the photoplethysmography data there sure will be some open source algorithm we can apply to get heart rate...or we just write our own.

What I find interesting is the power consumption of the original firmware. I measured it with a Current Ranger and during non-connected normal operation, displaying the time and advertising itself the device draws about 200µA with short 3ma spikes during TX. It should be a challenge to get power consumption down to this level, but theoretically possible. 

What I also noticed on the original firmware is that timekeeping is not very accurate. My device has a deviation of about 2 minutes/month. Already thought about hiding a tiny I2C real time clock somwhere inside the enclosure. 

  Are you sure? yes | no

arthur_jordan05 wrote 01/09/2019 at 11:25 point

Hi everybody,

data from the heart rate sensor is online now. I sniffed the bus with finger on sensor and without.

We have to get a second i2c bus working correctly with the bus in order to use both devices.

  Are you sure? yes | no

arthur_jordan05 wrote 09/11/2018 at 09:24 point

How cool is that. You can program this thing via the Arduino IDE easily by installing the Adafruit nrf52 core, which also contains an older version of the nrfutil (0.5.2 in the case of core version 0.8.5). With the following nrfutil commands you can generate the .zip files for OTA DFU from .hex files the Arduino IDE produces if you go to "Sketch->Export compiled binary"  (I'm working under windows):

C:\Users\[.....]\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.8.5\tools\nrfutil-0.5.2\binaries\win32\nrfutil dfu genpkg --application C:\Users\[.....]\Documents\Arduino\SMAQ2_test\SMAQ2_test.ino.feather52.hex --sd-req 0x88 C:\Users\[.....]\Documents\Arduino\SMAQ2_test\vibrotest1.zip

The --sd-req 0x88 stands for s132 2.0.1 on nRF52

You enter the DFU mode of the watch by pressing the "back" as well as the "up" and "down" buttons simultaneously (a little acrobatic) when the watch powered off. Alternatively press this button combo and reset the thing (by pulling the rst testpad (P0.21) to ground) or power-cycling it. 

Once in DFU mode the .zip file can be fed into the DFU tool of the "nRF Toolbox" Android app to program the device over the air.

I hope this helps somebody to get started quickly.

  Are you sure? yes | no

arthur_jordan05 wrote 09/08/2018 at 15:06 point

i received a newer SMA-Q2 instead of the older one. If you're patient you can open it from the upper side as you said, f.e. using a "sesamo opening tool". The problem is  that you'd have to glue it back together with some elastical glue with sealing properties which is annoying. The circuit board has a blue solder mask but is otherwise identical. I'm planning to include a tiny reed switch for reset purposes after which the thing will be glued together again.

Which platform do you use to program yours? Did you roll your own display library or is there one around which is wasy to modify (for example for sharp memory displays).

Thanks for sharing the fruits of your effort here. 

  Are you sure? yes | no

emeryth wrote 09/11/2018 at 20:54 point

Great! Thanks for the info.

Even though I have a few spare watches, I couldn't get myself to wreck one.

As for the platform, I'm just using Nordic SDK 11.0 (for compatibility with the old softdevice already on the watch) and GCC.

The LCD is pretty simple to use, you basically just send pixel values over SPI. I think it is a clone of the sharp displays, so you can reference existing libraries.

  Are you sure? yes | no

arthur_jordan05 wrote 09/19/2018 at 18:17 point

Ok I have a working Arduino library for the display (ported from mbed) which uses the Adafruit GFX library and a working real time clock library based on the real time counter. Originally the latter was included in the "official" Arduino nrf52 core and worked almost out of the box with the Adafruit core. I already have a crude sketch that ties stuff together and demonstrates some fundamental functions too... Will publish everything on Github soon. Now it's time for the PAH8002. Unfortunately I've lost the programming application note and the files on Nextcloud are gone...any chance to get them back online? 

This hack has a lot of potential, What's quite cool about this OTA concept is that you can carry several different firmwares with you on the phone and just upload them on the fly if you need a certain functionality. The low power consumption of the nrf52832 is remarkable too. 

  Are you sure? yes | no

emeryth wrote 09/19/2018 at 18:26 point

Sorry, we are having a rough transition to NextCloud, try this link for now:

https://owncloud.hackerspace.pl/index.php/s/fR7jom478oSoE8p

  Are you sure? yes | no

ddavidmelo wrote 03/14/2018 at 21:53 point

I have this watch and I think with a good firmware can be better than pebble. Keep going with this work, I would love to see the something cool in the end.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates