Smarty the watch – it is aliveeee

Smarty the watch – it is aliveeee

After a bit of struggle I was able to wake up the clock.

I was completely dead but when I removed battery I could see him with raspberry debugger and load new firmware.

ESPruino

First thing I have found that it is possible to program it from arduino

http://www.rogerclark.net/

Roger has nice tutorial how to get arduino working, and there is tut how to get cheap USB programmer debugger

Arduino on BLE

I already had STM32F103C8T6 ARMSTM32 Minimum System Development Board from ebay so I decided to give it a try

I programmed programmer on raspberry pi programmer :)

s-l500

So I have now tried but I had problems with it I could not upload sample

nrf51arduino1

Debuger was installed

nrf51arduino2

It all seems OK

nrf51arduino3

Some suggestions was that I need to change ID in registry, but I did not do that

nrf51arduino4

So I loaded Arduino sample with raspberry watch just to check if I’m on right way. And nRF accepted flash

nrf51arduino6

I did not have time to test it because it was Thursday and I need to rush to my makerspace radiona.org

I just surf a bit and on some picture I saw that when programming with similar debuger they do not use SWD pins that are named on board, they have used pins A4 and A5, and that was bingo. I was now able to upload sample from arduino.

nrf51arduino7

But sample with arduino did not work I was not able to get blink led on P0_07 (there is vibro motor on that pin) so it should vibrate while HIGH.

I have searched how can I test if it is working and find The ARM® mbed™ IoT Device Platform so I decided to try it.

https://developer.mbed.org/

nrf51_mbed1

I was really easy to start programming within MBED I just selected some nordic board loaded and wrote a blink led

and that worked. Button on pin P0_04 worked to.

Next was to get OLED working. I have searched MBED libraryes and found this one

https://developer.mbed.org/users/synvox/code/SFE_MicroOLED/

I have tested it and LCD woke up with only garbage on screen.

I have contacted author of library Nenad to help me with getting something on screen. Here is his response couse I still did not get OLED working right:

“Hello Goran, first you have to make sure, that your OLED SSD1306 controller is configured for the SPI interface. My adapted library only supports SPI, so it won’t work with OLEDs configured for I2C. Second you will want to change the LCDWIDTH and LCDHEIGHT in SFE_MicroOLED.h to your actual OLED size. If it’s a 64 x 32 one, you have to set it to that. You can also try to change LCDCOLUMNOFFSET to a different value than 32. Normally on OLEDs with SSD1306 controller and less than 128 pixels width, the actual pixels are arranged in the middle of the SSD1306 memory width. So an OLED with 64 pixels width is often mapped with an offset of 32 in the controller memory. But it could be different for your patricular OLED, so you could try an offset of 0 or any multiple of 8. Third you should adapt the init sequence in SFE_MicroOLED.cpp to your OLEDs values. What i have seen from your attached datasheet, some values are different: command(SETMULTIPLEX, 0x2F) should be 1F instead of 2F (because your hight is 32 and not 48 pixels). command(SETCOMPINS, 0x12) should be 00 or 02 instead of 12. command(SETCONTRAST, 0x8F) per your datasheet is 4F and not 8F, but i doubt this will cause problems. command(SETPRECHARGE, 0xF1) per your datasheet is 1F and not F1. I’m not sure if this is important or maybe even a typo in the datasheet. Best regards Nenad”

Datasheet of OLED is here: http://microco.sm/out/cEAZg

After some change I was able to get Hello world on screen.

hello

So next step to get really Smarty is to get accelerometer to work.

First I have tried with library https://developer.mbed.org/components/KX022-1020-I2CSPI-3-axis-accelerometer/

But did not work,I ave tried I2C scanner to check if I use wrong I2C address but that did not work to. Then I readed all pins that are connected to accelerometer:

http://kionixfs.kionix.com/cn/datasheet/KX022-1020%20Specifications%20Rev4.0%20cn.pdf

//P0_16 SCL     — default HIGH probably pullup
//P0_15 SDO/ADR — default HIGH probably pullup
//P0_14 SDI/SDA — default HIGH probably pullup
//P0_13 Trigger — default LOW
//P0_12 INT1    — default LOW
//P0_11 INT2    — default HIGH probably pullup
//P0_10 nCS     — default HIGH probably pullup — from datasheet is this pin is high I2C is enabled so this is ok
// The  Slave  Address associated  with  the KX022 is 0011111X,
// where  the  programmable  bit,  X,  is  determined by  the  assignment  of ADDR (pin 1) to GND or IO_Vdd.
// So in this case we have adress 0011111
// 1Fh 3Fh 00111111

But nothing worked.

So I reported that to Roger, he pointed me to some I2C problems with nRF

Its possible the I2C scanner will not work, as I think it uses a bit of a trick

However I found this

https://developer.mbed.org/questions/69178/NRF51-DK-I2Cnot-working/

which links to this

https://developer.mbed.org/users/Cannonball2134/code/I2C_Scanner/

So perhaps you could try that code, even if you have to use mbed

And I have tried, and get response from Accelerometer and its adress.

It was using some wire library that is not compatible with i2c and I did not manage to easily get original KX022 library to work.

So I just tested WHO_A_I register and got response, and then I decided to write line by line in main file and I got response from accelerometer X axis in MBED.

Untitled

While I was working with MBED Roger worked in fixing Arduino to accept all pins, and change pinout that suits Smarty.

He suggested that we open a chat room so others can join so I did so.

Chat: https://gitter.im/nRF51822-Arduino-Mbed-smart-watch/Lobby

Roger created repository with Smarty pinout:

https://github.com/rogerclarkmelbourne/Arduino_nrf51822

On my watch I broke pin 18 so now I use pin 17 as TX pin, you can change that in

ble-nrf51822-master\RBL_nRF51822\variants\Smartwatch\pins_arduino.h

It was easy to port some code from MBED to arduino, so now we have all working as on MBED

OLED is still not working good still has some garbage on screen, accelerometer does not have library it is all in main ino file, it does not use smart things like tap double tap flip interupts. accelerometer could wake up nRF to save battery life and so on…

I have pushed some samples on git you can check and fix within Smartwatch examples

This is some digital watch example.

Other BLE samples are working too

arduino_smarty

Back to the hand:

backtothehand

 

Join us in chat room, and on git, and thanks for reading :)

Ideas Todo:Flash old android phone (Samsung Galaxy Fame) to firmware that can do BLE — done  phone now has CM12.1 I can connect with bracelet

Adding more sensors like pulse sensor or muscle sensor

Epilepsy seizure detect

On Threat CALL or send SMS

Blind read SMS privatly

TROL other bracelets with Smarty bracelet

If bracelet is stolen and someone connect to it and install our app from store  (make some nasty stuff SEND SMS with location or something)

One Bracelet to rule them all

P.S.

Roger has fixed OLED …

clock

Leave a Reply