{"id":157,"date":"2016-11-29T09:19:16","date_gmt":"2016-11-29T03:49:16","guid":{"rendered":"http:\/\/madhurendra.com\/?p=157"},"modified":"2021-03-30T00:16:23","modified_gmt":"2021-03-29T18:46:23","slug":"just-another-diy-smart-watch","status":"publish","type":"post","link":"https:\/\/madhurendra.com\/just-another-diy-smart-watch\/","title":{"rendered":"Just Another DIY “Smart” Watch"},"content":{"rendered":"\n
Note : This article was written after project was partially completed, so i don’t have better images.<\/p>\n\n\n\n
There are hundred’s of projects for building “Smart watch using arduino”, I have curated a list of better projects at end of this article. I didn’t plan to copy any of given projects but at end it turned out that world is a big place. So this blog post is my effort in developing “My smartwatch”.<\/p>\n\n\n\n
Hardware :<\/p>\n\n\n\n
Tools :<\/p>\n\n\n\n
Software :<\/p>\n\n\n\n
The guide here is definitely not a step by step guide, it just tells the flow (an algorithm not code).<\/p>\n\n\n\n
<\/p><\/li><\/ol>\n\n\n\n
Click here to watch working video.<\/a><\/p>\n\n\n\n Below is arduino code :<\/p>\n\n\n As told initially my build is not the best one, there are people with better electronics & better output check these :<\/p>\n\n\n\n http:\/\/www.instructables.com\/id\/Make-your-own-smart-watch\/?ALLSTEP<\/a><\/p>\n\n\n\n http:\/\/makezine.com\/projects\/make-43\/open-source-smartwatch\/<\/a><\/p>\n\n\n\n http:\/\/www.tinkernut.com\/portfolio\/make-smartwatch-old-cell-phone-part-1\/<\/a><\/p>\n\n\n\n http:\/\/oswatch.org\/mkII_build_page_1.php<\/a><\/p>\n\n\n\n\n#include "U8glib.h"\n\nU8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);\t\/\/ Display which does not send AC\n\n#include <SoftwareSerial.h>\n\/\/ software serial #1: RX = digital pin 10, TX = digital pin 11\nSoftwareSerial bluetooth(10, 11);\n#define buflen 10\n char str[buflen+1];\n int strCount=0;\n\n\n\/\/ setup input buffer\n#define LINE_MAX 30 \nuint8_t line_buf[LINE_MAX] = "Booting...";\nuint8_t line_pos = 0;\n\n\/\/ setup a text screen to support scrolling\n#define ROW_MAX 12\n\n\nuint8_t screen[ROW_MAX][LINE_MAX];\nuint8_t rows, cols;\n\n\/\/ line height, which matches the selected font (5x7)\n#define LINE_PIXEL_HEIGHT 7\n\n\/\/ clear entire screen, called during setup\nvoid clear_screen(void) {\n uint8_t i, j;\n for( i = 0; i < ROW_MAX; i++ )\n for( j = 0; j < LINE_MAX; j++ )\n screen[i][j] = 0; \n}\n\n\/\/ append a line to the screen, scroll up\nvoid add_line_to_screen(void) {\n uint8_t i, j;\n for( j = 0; j < LINE_MAX; j++ )\n for( i = 0; i < rows-1; i++ )\n screen[i][j] = screen[i+1][j];\n \n for( j = 0; j < LINE_MAX; j++ )\n screen[rows-1][j] = line_buf[j];\n}\n\n\/\/ U8GLIB draw procedure: output the screen\nvoid draw(void) {\n uint8_t i, y;\n \/\/ graphic commands to redraw the complete screen are placed here \n y = 0; \/\/ reference is the top left -1 position of the string\n y--; \/\/ correct the -1 position of the drawStr \n for( i = 0; i < rows; i++ )\n {\n u8g.drawStr( 0, y, (char *)(screen[i]));\n y += u8g.getFontLineSpacing();\n }\n}\n\nvoid exec_line(void) {\n \/\/ echo line to the serial monitor\n Serial.println((const char *)line_buf);\n \n \/\/ add the line to the screen\n add_line_to_screen();\n \n \/\/ U8GLIB picture loop\n u8g.firstPage(); \n do {\n draw();\n } while( u8g.nextPage() );\n}\n\n\/\/ clear current input buffer\nvoid reset_line(void) { \n line_pos = 0;\n line_buf[line_pos] = '\\0'; \n}\n\n\/\/ add a single character to the input buffer \nvoid char_to_line(uint8_t c) {\n line_buf[line_pos] = c;\n line_pos++;\n line_buf[line_pos] = '\\0'; \n}\n\n\nvoid setup(void) {\n Serial.begin(9600);\n bluetooth.begin(9600);\n Serial.print("Hello");\n\/\/ bluetooth.println("Hi");\n \n\/\/ u8g.firstPage(); \n\/\/ u8g.drawStr( 0, 0, "Booting..");\n\/\/ set font for the console window\n u8g.setFont(u8g_font_5x7);\n \/\/u8g.setFont(u8g_font_9x15);\n \n \/\/ set upper left position for the string draw procedure\n u8g.setFontPosTop();\n \n \/\/ calculate the number of rows for the display\n rows = u8g.getHeight() \/ u8g.getFontLineSpacing();\n if ( rows > ROW_MAX )\n rows = ROW_MAX; \n \n \/\/ estimate the number of columns for the display\n cols = u8g.getWidth() \/ u8g.getStrWidth("m");\n if ( cols > LINE_MAX-1 )\n cols = LINE_MAX-1; \n \n clear_screen(); \/\/ clear screen\n delay(1000); \/\/ do some delay\n exec_line(); \/\/ place the input buffer into the screen\n reset_line(); \/\/ clear input buffer\n}\n\n\nvoid loop(void) {\n \n \/\/ Keep reading from HC-05 and send to Arduino Serial Monitor\n if (bluetooth.available()){\n char c = bluetooth.read();\n Serial.write(c);\n\/\/ uint8_t c;\n \n if ( line_pos >= cols-1 ) {\n exec_line();\n reset_line();\n char_to_line(c);\n } \n else if ( c == '\\n' ) {\n \/\/ ignore '\\n' \n }\n else if ( c == '\\r' ) {\n exec_line();\n reset_line();\n }\n else {\n char_to_line(c);\n }\n}\n if (Serial.available())\n bluetooth.write(Serial.read());\n\n}\n\n\n<\/pre><\/div>\n\n\n