Introduction: ArduinoBlueTooth(NotSoSmart)Watch

Picture of ArduinoBlueTooth(NotSoSmart)Watch

INTRO

Hello everyone & Welcome to my first Instructable!

I´m Markus and I have started arduino programming in March 2014. So I´m pretty new to the MAKERscene :-)

Idea and its origin

After the last couple of months I got inspired by all those Maker-Projects out there and this week I decided to share this project with the community (in other words: I wanted to test this "Instructables-Platform").

I have to mention that it was not planned to build a "smart" watch. The project was planned as a learning-process for myself because I had troubles getting a serial-protocol up and running for a home-automation system.

One day I saw the RetroWatch Instructabel by GodsTale (Thanks for your inspiration) and decided to make something similar.

I didn´t want to add somuch/too much features because I thought "less is more". I wanted to keep the whole thing as simple as possible.

Implemented Features

lets have a look at the inside of the box.

- TIMEsynchronisation via BT (UTC Format, change values to your need in the Ai2 file), clock will also work (after Sync) if there is no BT connection or App running (just a stupid little watch).

- get notified about incoming messages, display the message (16char max)

- get notified about incoming/outgoing calls, display the phonenumber (16char max)

- altimeter (GPS)

- display timeout with wakebutton

- clear notifications via button or android

Planned Features

what should come into the box, what should be changed:

- better process to run the app in the background

- calculate the speed from long/lat changes (there is more math to do, but it is implemented in the protocol)

- build a second version which can be used as a car OSD (speedometer! will keep you updated on that)

- "clear up the" Prototype-Code :-)

Step 1: Concept, Material & Connecting the Hardware

Picture of Concept, Material & Connecting the Hardware

Concept


My concept was to just use the watch as a kind of secondary display which notifies me whenIi got a textmessage or a call. During the development I also added some GPS features (Altimeter, nice for hiking trips). More features are planned but not yet implemented. [Be creative :-)]

Material for the "final" project

(I will update the Instructable as soon as I get the 3.3V Hardware, follow picture 2)

- Arduino Mini 3,3V 8Mhz [Sparkfun]

- I2C 128x64 OLED (3,3V compatible) [Aliexpress]

- HC-06 or HC-07 3,3V BT Module [Aliexpress]

- Lipo Loader [Adafruit]

- USB UART Adapter (to upload your scetch) [Adafruit]

- 1s Lipo ~ 150mAh + [Adafruit] also have a look at the 500mAh LIPO!

- housing & wristband (I´m planning to store the Lipo and its loading module in the wristband, to keep everything as flat as possible. hopefully I get some more inspiration from the community)

- hot glue (mounting the switches, glue the modules together, prevent shorcircuits)

- soldering Iron

- wires

Material I used for the prototype

(just like the final Version but 5V Hardware)

- Arduino Uno R3 (328P)

- I2C Oled (5V)

- HC-06(5V)

- half sized Breadboard

Connceting the hardware (prototype version)

If you follow the attached Fritzing file (picture 1) the assembling of the electronics should be "straight forward".

There are a few things you will need:

  • The Controller: It doesn´t matter if you take a Arduino pro Mini, pro Nano or a Uno. Just be sure it has a 328P Atmel on it (168P will not have enough memory).
  • The Display: be sure that it is an I2C 128x64 and it is 5V tolerant
  • The BT Dongle: HC-06 or HC-07 (5V Version); [Configuration]
  • a small breadboard, some breadboard wires

Let´s wire everything.

Plug the display into the breadboard, connect VCC to +5V/VCC (Prototype!) of your µController. Connect SCL to pin A4 and SDA to pin A5. (picture 2)

Wire the two switches to D4 (this will be the "Display on Button") and D5 (this is the "Clear Button"). I,m using the internal pullup resistors (pinmode INPUT_PULLUP, have a look at the sketch) (picture 3)

Now hook up your BT Module (VCC to 5V/VVC, GND to GND). if you plan to use the hardware Serial, don't yet connect the TX RX pins! Else (softwareserial is implemented but you have to adapt the code, have a look at the sketch and feel free to ask me), crossconnect (TX to RX, RX to TX) them.

Step 2: Arduino Software / Android App

Picture of Arduino Software / Android App

Arduino Software

Download the attached ZIP file and be sure you have the Arduino IDE 1.0.4 (this is due to a compiler error in 1.0.5) installed! Make sure your BT Dongle is not connected to hardware RX TX of the Arduino. Connect your Arduino to your PC and upload the file. After a few seconds you will see the "start screen", the controller is now "patiently" waiting for time sync (UnixTimeFormat with leading "T").(picture 1)

Reconnect your BT Dongle if you use the hardware Serial.

Download and install the APK. You can also download the AI2 .aia file to modify the code. Open the App!

(picture 2)

Android App (AppInventor2):

Buttons

Bluetooth: Opens a Listpicker. Choose the Bluetooth Dongle (check step 1 for BT Dongle configuration)

Disconnect: disconnect from paired BT Device

TIMESet Option (check .aia File in AppInventor for Reference and to change the TIMEZone). <-- If you need help, feel free to mail me :-)

Daylight: Set Daylightsaving (MET)

Set Time: Set Time (MET)

ResetCall and ResetSMS: will Clear the pending Msg, Call on the Watch.

Debug: Is used to test some protocol - features (Try them out)

After connecting:

If you have connected succesfully to the "watch" the "startscreen" should immediatly change. If not SetTime with the AndoidApp. (picture 3);

Once connected and synced, Time and Date will also work without BT connection.

You can now test the Debug Buttons. Test SMS will generate a Dummy-TextMsg-Packet, Test Call and GPS will simulate a Call or a gps protocol-packet.

Ok before you call or text yourself, you have to know, that the watch will only read 16 characters of the incoming text or 16 characters from the phonenumber (incoming and outgoing calls!)

The GPS Altimeter will work outdoors. I am planning to implement a speedometer but there is some more math to do :-)

Now we are ready to go! Change it, tweak it, expand it, do what you want! But please credit me.

For those who are interested in a short explanation of the code and the protocol, see the further steps.

Thanks to:

my girlfriend Jaqueline ( for her endless patience, correcting the instructible, help with the icons and the start screen Logo ),

PJRC.com ( TimeLIB, SoftwareSerialLIB ),

adafruit.com ( OLEDLIB ),

Arduino.cc ( for giving me the possibility to MAKE ),

All Makers out there ( for inspiration and the endless pool of "knowhow" )

Step 3: Arduino Code - Explanation 1

Definition

The main parts of the code is commented. I will just pick up the protocol function (readBT) and the Definitioins.

definitions:

Every message has its own uniwue header, trailer. I have made that to check the incoming SerialStream for those defined characters.

eg. Textmessage: DATA/Payload = "Hi Instructable!" -> $Hi Instructable!|

I have also defined some single char-Packets (like SMS0_Header). These datapackets are used to reset values, or are leading bytes for integers or floats which you can parse from the SerialStream.

// define Buttons, Protocol Headers & Trailers ...<br>#define TIME_MSG_LEN  11
#define TIME_HEADER  'T'
#define TIME_REQUEST  7
#define SMS2_HEADER '|'
#define SMS1_HEADER '
#define SMS0_HEADER '%'
#define SMSN_length 12
#define CALL2_HEADER '*'
#define CALL1_HEADER '?'
#define CALL0_HEADER '!'
#define GPS_HEADER '&'

//wakeButton
#define button 4

//clearButton
#define rbutton 5

// MSG Array 1
char inData[16];
char inChar;
// Call Array 2
char inCall[16];
char inNumber;
//Define variables
byte index = 0;
long tmillis = 0;
long ptmillis = 0;
int ctimeout = 5000;
int count = 0;
int sms = 0;
int call = 0;
int gps = 0;
int alt = 0;
int spd = 0;
int bstat = 1;
int notifier = 1;
int timeout = 5000; //Displaytimeout

Step 4: Arduino Code - Explanation 2

The readBT function

So... lets have a look at the "brain" :-)

All we do here is reading char c, check whether it matches one of our headers. BTW: we also handle the TIMESet function here, if it is false call the timesync function.

Lets have a look at the line witch handles the "SMS1_HEADER". Arduino will make this decision if it receives "$" it will clear the "old" array Data and then read from Serial and write the following chars to the inData Array till it gets "SMS2_HEADER" (thats the "|") or the ArraySize (16) is reached.

Let´s move on to "SMS0_HEADER" that´s a single char ("!") packet. It will set a flag for the sms-clear mechanics and will clear the array and the notification.

The "GPS_HEADER" (char "&") we do not need a trailer here because all we do is use the Serial.parseInt() command.

eg. Serial stream "&123,456,...". if we use the Serial.parseInt() we will analyse the stream and "get" the int´s ("123") out of it. The Function will end if a char is not a number (","). When we use it again, we will get the int "456"

if you have further questions, feel free to mail me.

void readBT() // Handle received Data<p>{       
  while (Serial.available() > 0){
        char c = Serial.read();
        while (timeStatus()!= timeSet) { // sync Clock if timeSet false
        timesync();
        }  
        if(c == TIME_HEADER) { // Handle Packet for Time, see definitions
        timesync();
        }          
        if (c == SMS1_HEADER) // Handle Packet for SMS, see definitions
           {  
             memset(inData, 0, sizeof(inData)); //Clear old Data
             //bstat = 1;
             notifier = 1;
             sms = 1;         
             char c = Serial.readBytesUntil(SMS2_HEADER, inData, sizeof(inData)); //write Data to ARRAY
            }
        if (c == SMS0_HEADER || sms == 0) // Handle Packet for SMS RESET, see definitions
          {
           //bstat = 0;
           //notifier = 0;
           sms = 0; 
           memset(inData, 0, sizeof(inData)); //Clear old Data
          }
       
      if(c == CALL1_HEADER){ // Handle Packet for call, see definitions
          memset(inCall, 0, sizeof(inCall)); //Clear old Data
          //bstat = 1;
          notifier = 1;
          call = 1;
          char x = Serial.readBytesUntil(CALL2_HEADER, inCall, sizeof(inCall)); //write Data to ARRAY
         }   
      if(c == CALL0_HEADER || call == 0){ // Handle Packet for call reset, see definitions
          //bstat = 0;
          //notifier = 0;
          call = 0;
          memset(inCall, 0, sizeof(inCall)); //Clear old Data
         }  
        
        if(c == GPS_HEADER){ // Handle Packet for GPS INFO, see definitions
          gps = 1;
          alt = Serial.parseInt();
          spd = Serial.parseInt();
          } 
        Serial.flush();
        c = ' ';  
     }
 }</p>

Step 5: Android Code (AppInventor2)

Picture of Android Code (AppInventor2)

Android code

I´ve never coded an Android App before. So I decided to ask Google for an ADK and found AppInventor.

AppInventor was easy to use but has limited functionality.

The first picture will give you a short overview of my work. It´s a little confusing when you look at it but coding in AI is straight forward (just give it a shot).

The second picture shows you the main functions "loop". In this Section I generate the "Protocol-Messages" which are send to the Arduino via BT.

The first part will send the Timesync message if BTConnected = True (this will work everytime you connect to the ArduinoWatch).

The following parts will check if the global sms or call and the BTConnected Status is true and will then process the messages. At the moment we send the messagetext / phonenumber. There is an *.aia file attached, feel free to change it to fit your needs.

In the GPS Part we will check for a location change. If true, we will construct and send the message.

Because AppInventor does not support Apps running in the background i had to do a workaround (again Google was very helpful :) )HereI implemented a timer (picture 3) which triggers an alert-message to prevent Android to close the app in background. It is working, but I´m not really satisfied with this solution. I´ll give you an update when I find a better solution.

Last but not least, have fun making the ArduinoBluetoothNotSoSmartWatch :-)

Comments

SarvjitP (author)2017-06-11

Will u please post the apk file ?
I don't know how to make apk from the .aia file.

SarvjitP (author)SarvjitP2017-06-11

Sorry i did not get the zop and apk file you attached.
Sorry for that.

SerialQ (author)SarvjitP2017-06-12

No Problem, you are welcome :-)

SarvjitP (author)SerialQ2017-06-26

Hey please reply. I want your help in developing the app
Thanks

SarvjitP (author)2017-06-24

I'mhaving issue with the apk. It shows no text on app buttons.
Also shows some blinking box like this everywhere if app is running in background.
Please update app or fix it for me.
Thanks

gemingyu (author)2015-06-21

thanks but where is TimeLIB and SoftwareSerialLIB?

SerialQ (author)gemingyu2015-06-23

You can get the TimeLIB here :
https://www.pjrc.com/teensy/td_libs_Time.html

The SoftwareSerial should be implemented in the Arduino IDE since V1.6x else you can download it here: https://www.pjrc.com/teensy/td_libs_SoftwareSerial...

gemingyu (author)SerialQ2015-06-24

THANKS,working on It.:-)

SerialQ (author)2014-11-07

I got the materials for the "final" version of the prototype yesterday. I think i can get the whole thing together till monday or tuesday. Stay tuned :-)

SerialQ (author)SerialQ2014-11-12

Destroyed my OLed (wanted to press it in my wooden case :( ) i will update the instructable when i get the new display.

About This Instructable

2,091views

44favorites

License:

Bio: I have started arduino programming in March 2014. You/Instructables will be a part of my &quot;learning-process&quot;.
More by SerialQ:ATTiny-RAT, ATTINY powered mini lightfollowerTheSUN, Arduino powered design wall clockArduinoBlueTooth(NotSoSmart)Watch
Add instructable to: