Click here to Skip to main content
15,867,308 members
Articles / Internet of Things

Let’s make a SmartWatch

Rate me:
Please Sign up or sign in to vote.
4.99/5 (30 votes)
17 Oct 2015CPOL10 min read 73.9K   21   28
Intel Edison is small enough to use as a wearable, so why not we make a smart watch with Edison.

Contents

  1. Introduction to Intel Edison

  2. Specs

  3. Programming Methods

  4. Prototyping with Edison

  5. Why to choose Edison?

  6. Let’s make a SmartWatch

  7. Requirements

  8. Make Edison ready for programming

  9. Set up Serial terminal

  10. Connect to Wi-Fi

  11. Making Connections

  12. Programming for SmartWatch

  13. Code for Displaying Time and Temperature

  14. Code for Sending SMS

  15. Code for Accelerometer and Gyroscope

  16. Code for turning on the flashlight with button press

  17. Sending data to Cloud

  18. Working

  19. Points of Interest

  20. History

  21. References

Introduction to Intel Edison

The compute module of Intel called Intel Edison is slightly larger than a SD card. After playing around Edison extensively I am completely in love with this tiny computer. The specialty of Edison is – It can be used for wearables also it is enough powerful to control robots. It is 35.5 × 25.0 × 3.9 mm module also equipped with Yocto, a Linux OS . It has an onboard Wi-Fi and Bluetooth, perfect for IoT projects. We can connect to Edison remotely and can run commands or access the file system. This gives lots of flexibility to developers via SSH. Its specs will definitely impress you, they are:

Image 1

Specs

Intel® Atom™ Processor clocked at 500MHz
100MHz Quark MCU
1GB of LPDDR3 RAM
4GB eMMC flash memory
WiFi (802.11a/b/g/n)
Bluetooth (4.0 and 2.1 EDR),
UARTs
I2C
SPI
USB
40 multiplexed GPIO interfaces

 

Programming Methods

Edison can be used with Arduino IDE but to get most out of it you can use other programming languages like Python, Node.JS, C/C++. Intel has its own IDE called Intel XDK IoT edition which makes programming with Edison easy. While setting up the programming environment for Edison you can choose between Arduino IDE, Intel XDK or Eclipse.

Prototyping with Edison

To keep the Edison small all of the I/O pins are broken out to a 70-pin Hirose connector. This 70 pin connector is not prototyping-friendly. Interfacing with these connectors are really difficult so to interface with Edison we need a board with mating Hirose connector.

Currently available interfacing boards are:
Arduino Expansion Board
Mini Breakout Board
SparkFun Edison Blocks

If you are new to Edison and wanted to play around it, Arduino Expansion Board is for you. It will give you Arduino like feel also Arduino based shield are compatible with this board but slightly larger than Intel Galileo. The features are:

 

Image 2

 

• 20 digital input/output pins including 4 pins as PWM outputs
• 6 analog inputs
• 1 UART (RX/TX)
• 1 I2C
• 1 ICSP 6-pin header (SPI)
• Micro USB device connector OR (via mechanical switch) dedicated standard size USB host Type-A connector
• Micro USB device (connected to UART)
• Micro SD card connector
• DC power jack (7V – 15V DC input)

If you want to embed Edison into a project than you can use Mini Breakout Board or SparkFun Edison Blocks. They are slightly larger than Intel Edison. Mini Breakout Board has minimal features as:

 

Image 3
Image courtesy: Adafruit

 

• Exposes native 1.8V I/O of the Edison module
• 0.1” grid I/O array of through-hole solder points
• USB OTG with USB Micro Type-AB connector
• USB OTG power switch
• Battery charger
• USB to device UART bridge with USB Micro Type-B connector
• DC power supply jack (7V – 15V DC input)

 

SparkFun has a whole set of modules for Interfacing, Power, Sensors and Actuators. You can browse them here are can find one or many suitable for your project with Edison.

Image 4

Why to choose Edison?

Edison is a low power IoT computing module hence for less power consumption processor also slightly larger than a SD card . It is the best choice for a wearable project.

 

Let's make a SmartWatch

Edison is enough small to use in wearble projects, so why not we make a smart watch with this tiny computer. I am going to use Arduino breakout board for prototyping though this will not look exactly like a smartwatch in prototype stage but will have all the functionalities and later we can work on to make it modular and compact. For the prototyping I used 16*2 LCD module for display as currently I was not having an OLED display, if you have one you can use the OLED display as it has low power consumption and smaller too. I will soon update this project with an OLED. So let’s see functionalities of our Edison Smart Watch

  1. Show time continuously
  2. Monitoring and showing nearby temperature and sending to cloud
  3. Sending SMS with one touch.
  4. Flashlight
  5. Pedometer and sleep monitor.

 

Requirements:

Intel Edison Module

Arduino expansion board for Edison

Touch Sensor

Grove Button

LSM303 Accelerometer/Compass Sensor

Temperature Sensor

16*2 LCD RGB backlight

Grove LED module

Super bright LED (White)

Grove base shield

Power supply

Micro USB cable

Jumper wires

 

Image 5

 

Image 6

 

I am using Grove's sensors as it makes prototyping easy. You will find most of the sensors used in this project in Grove's Starter Kit for Edison . If you are new to IoT, the Seed Studio Grove Starter Kit will help you to easily get started with development since you need not worry about circuits and other electronics stuff. With Grove shield and sensor modules you can easily create anything without worrying about electronic components much. There is no need to manage sensors using soldering or a breadboard. This article "Grove Starter Kit With Intel Galileo Gen 2: Getting Started" will guide you about how to set up and get running with the Grove Starter Kit plus, though it is with Galileo gen 2 but everything is similar for Intel Edison. I am using Adafruit's Flora accelerometer/compass as I am having this one currently with me, it works fine but as this is designed as sewable module you will have to do a little extra work while making connections with this. If you don't have any I suggest you Grove - 6-Axis Accelerometer & Compass or Adafruit's accelerometer/compass LSM303.

 

Make Edison ready for programming

  1. Download the installer depending on your PC’s configuration from https://software.intel.com/en-us/iot/software/installers
  2. Run the installer, it will ask you about the programming environment and IDE you want to install. Choose one or many according to your preference. For this project I am using Intel XDK and programming using node.jsImage 7
  3. Set up Serial terminal: If you want to use your board run commands remotely, you have to set up a serial connection. First install putty from http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe , Run the installer. Expand Connection in the menu and select Serial. Now in serial line type the COM port to which your Edison is connected. In the Speed field, type 115200 and select Serial in the connection type. Click ok, it will open a serial connection. Press enter, now it will prompt for login. Enter your credentials. Default username is root with no password. Now you will see a terminal port.Image 8
  4. Connect to Wi-Fi: enter this command in serial terminal-
    configure_edison --wifi  , Edison will scan for all Wi-Fi networks for approximately 10 seconds. When it is finished, a list of available networks will be displayed. Choose the network by corresponding number in the list, type Y and press enter. It will ask for network credentials, enter valid credentials and you will be connected to WiFi with your Edison.Image 9
  5. In your web browser type the IP address of your Edison or "http://edison.local" this will show this page if your Edison is connected to network.Image 10
  6. Now we are all done to start developing with our Edison project.

 

Making Connections

As we are using Grove's sensors we will make connections with the four pin cables that comes with grove sensors. Don't worry about polarity as you won't be able to make wrong connection with them, they will fit only when you connect them in the correct way.

1) Connect your Edison to power supply and to your PC via USB cable.

2) It will take 15-20 seconds to boot up, after that stack the Grove Base Shield.

3) Connect the Temperature Sensor to analog pin A0

4) Connect the temperature sensor to A1.

5) Connect the LCD Display to one of the I2C port

6) Connect the Accelerometer to another I2C port.

7) Connect the Grove button to D2.

8) Connect the LED module to D3.

9) Connect the touch sensor to D4.

 

Image 11

 

Programming for SmartWatch

  1. Open Intel XDK IoT edition, if it is not already installed in your PC get it from https://software.intel.com/en-us/iot/downloads
  2. If you have flashed you Edison with the Flash Lite Tool Node.Js will be already installed on your board.
  3. Connect IDE to your Edison board. It will ask you for username and password, default username is root with no password.

Image 12

  1. Select a blank Node.Js template and create a new project.

Image 13

 

 

Code for Displaying Time and Temperature

JavaScript
var lcd = new jsUpmI2cLcd.Jhd1313m1(6, 0x3E, 0x62);

var groveSensor = require('jsupm_grove');

var today = setInterval(function ()
    {
    var d = new Date();
    var b= d.toTimeString();
    lcd.setColor(0, 255, 0);

// Go to the 2nd row, 6th character (0-indexed)

    lcd.setCursor(0,0);
    lcd.write(b);
     var celsius = temp.value();
        var fahrenheit = celsius * 9.0/5.0 + 32.0;
        var t = Math.round(fahrenheit);
        lcd.setCursor(1, 1);
        lcd.write(t+" *F");
       v.saveValue(t);
}, 1000);

 

Code for Sending SMS

 

JavaScript
var twilio = require('twilio');


// Create a new REST API client to make authenticated requests against the

// twilio back end

var TWILIO_ACCOUNT_SID = '' ;

var TWILIO_AUTH_TOKEN = '';

var OUTGOING_NUMBER = '';

var TWILIO_NUMBER = '';


var client = new twilio.RestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);


// Pass in parameters to the REST API using an object literal notation. The

// REST client will handle authentication and response serialzation for you.

client.sms.messages.create({

    to:OUTGOING_NUMBER,

    from:TWILIO_NUMBER,

    body:'Hi, sending from my Edison SmartWatch'

}, function(error, message) {

    // The HTTP request to Twilio will run asynchronously. This callback

    // function will be called when a response is received from Twilio

    // The "error" variable will contain error information, if any.

    // If the request was successful, this value will be "falsy"

    if (!error) {

        // The second argument to the callback will contain the information

        // sent back by Twilio for the request. In this case, it is the

        // information about the text messsage you just sent:

        console.log('Success! The SID for this SMS message is:');

        console.log(message.sid);


        console.log('Message sent on:');

        console.log(message.dateCreated);

    } else {

        console.log('error: ' + error.message);

    }

});

 

 

Code for Accelerometer and Gyroscope

 

JavaScript
var accelrCompassSensor = require('jsupm_lsm303');

// Instantiate LSM303 compass on I2C

var myAccelrCompass = new accelrCompassSensor.LSM303(0);


var successFail, coords, outputStr, accel;

var myInterval = setInterval(function()

{

        // Load coordinates into LSM303 object

        successFail = myAccelrCompass.getCoordinates();

        // in XYZ order. The sensor returns XZY,

        // but the driver compensates and makes it XYZ

        coords = myAccelrCompass.getRawCoorData();


    // Print out the X, Y, and Z coordinate data using two different methods

        outputStr = "coor: rX " + coords.getitem(0)

                                      + " - rY " + coords.getitem(1)

                                      + " - rZ " + coords.getitem(2);

        console.log(outputStr);

        outputStr = "coor: gX " + myAccelrCompass.getCoorX()

                               + " - gY " + myAccelrCompass.getCoorY()

                               + " - gZ " + myAccelrCompass.getCoorZ();

        console.log(outputStr);


    // Get and print out the heading

        console.log("heading: " + myAccelrCompass.getHeading());


    // Get the acceleration

        myAccelrCompass.getAcceleration();

        accel = myAccelrCompass.getRawAccelData();

    // Print out the X, Y, and Z acceleration data using two different methods

        outputStr = "acc: rX " + accel.getitem(0)

                               + " - rY " + accel.getitem(1)

                               + " - Z " + accel.getitem(2);

        console.log(outputStr);

        outputStr = "acc: gX " + myAccelrCompass.getAccelX()

                               + " - gY " + myAccelrCompass.getAccelY()

                               + " - gZ " + myAccelrCompass.getAccelZ();

        console.log(outputStr);

        console.log(" ");

}, 1000);


// Print message when exiting

process.on('SIGINT', function()

{

        clearInterval(myInterval);

        myAccelrCompass = null;

        accelrCompassSensor.cleanUp();

        accelrCompassSensor = null;

        console.log("Exiting");

        process.exit(0);

});

 

Code for turning on the flashlight with button press

 

JavaScript
var groveSensor = require('jsupm_grove');

// Create the button object using GPIO pin 0

var button = new groveSensor.GroveButton(2);

// Read the input and print, waiting one second between readings


function readButtonValue() {
    console.log(button.name() + " value is " + button.value());
    var v=button.value();
    if(v==1){ led.on();}
    if(v==0){ led.off();}
}
setInterval(readButtonValue, 1000);

 

Sending data to Cloud

JavaScript
var ubidots = require('ubidots');

var client = ubidots.createClient('YOUR-API-KEY');


client.auth(function () {

  this.getDatasources(function (err, data) {

    console.log(data.results);

  });

  var ds = this.getDatasource('xxxxxxxx');


  ds.getVariables(function (err, data) {

    console.log(data.results);

  });

  ds.getDetails(function (err, details) {

   console.log(details);

});


  var v = this.getVariable('xxxxxxx');


  v.getDetails(function (err, details) {

    console.log(details);

  });

  v.getValues(function (err, data) {

    console.log(data.results);

  });

 

Here I am using Ubidots for IoT cloud, with Ubidots we can visualizing the data in an effective way. It supports a wide range of devices and can also trigger some actions like sending mails and messages. It also offers numbers of API to speed our development with the language of our choice. Hence I have chosen its Node.Js library to interact with my Edison.

 

Setting up Ubidots Cloud

  1. Log in to your Ubidots account or you can create one here http://ubidots.com/
  2. Select the “Sources” tab and then click on “Add Data Source” to create a new data source. Here I have added My Edison.

 

Image 14

 

  1. Once the data source is created we have to add variables to it. Here in this project we are going to send Temperature data, hence we will create a single variable.

 

  1. Click on the variable and copy the variable ID. Paste this in your code.

Image 15

  1. Select My Profile->API Keys. Get your API Key from here.

Image 16

  1. On your Dashboard add a widget of your choice, depends on how you want to visualize the data.
  2. I have chosen line chart and table values for the temperature sensor. By looking at the Table values you can easily determine at the last value of temperature and with Graph you can evaluate a sudden variation in temperature.

 

Working:

You will need to create a twilio account  for sending the messeges. Copy the API key in the code that you get from twilio account. Build, Upload and Run your app on Edison. It will download the NPM modules and upload the current project to Edison. While working with Intel XDK IoT edition you need an active internet connection.

Image 17

 

You will see the sensor values in debug console, if everything works fine you will notice data being send to Ubidots cloud and message send to mobile phone with touch. Press the button and this will turn on the flashlight that will be useful to see you in the dark and the display will show current time and temperature.

 

Image 18

 

Image 19

 

Navigate to Ubidots dashboard, you will see all the data sent from the sensor in our widgets. You can see the last value recorded by the temperature sensor and a line graph about variations. Here I have also created some alerts, if the temperature level exceeds up to a certain level (an alert will send to our mobile phone through SMS.

Image 20

 

Now when we touch on the touch sensor a text message is sent to my mobile phone immediately. I have used Twilio trial account, so they have added some other text with the SMS. If you will get a paid account you won't see any Twilio advertisements.

Image 21

Points of Interest

Making a smart watch and carrying it is something you will really enjoy. I am still working to make this small and also working on the pedometer and sleep monitor that I will update soon.

History

20-10-2015: TOC and References added

16-10-2015: Article first published

References

http://www.intel.com/content/www/us/en/do-it-yourself/edison.html

https://software.intel.com/en-us/iot/hardware/edison/downloads

http://poojabaraskar.com/grove-starter-kit-with-intel-galileo-gen-2-getting-started/

https://software.intel.com/en-us/iot/library/edison-getting-started

www.seeedstudio.com/depot/

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Pooja Baraskar is an accomplished software engineer, inventor, and technical author with over a decade of experience in the tech industry. With a passion for innovation and a commitment to excellence, Pooja has established herself as a thought leader and an agent of change in the industry. Currently, Pooja is leading various developer programs globally at Intel, leveraging her expertise and vision to drive impactful initiatives that shape the industry and empower tech professionals around the world.
As a tech trailblazer, Pooja is passionate about challenging the status quo and driving innovation. She is a pioneer in areas such as artificial intelligence and the Internet of Things and has a proven ability to translate complex technical concepts into accessible and actionable ideas. She has an impressive track record of delivering results in complex, high-stakes projects and is continually seeking new ways to drive value and make a difference.
Pooja is also an accomplished technical author. Her writing is known for its clarity, accessibility, and technical accuracy, making her a trusted source of information for developers and tech enthusiasts around the world. Digital courseware For Educators for OpenVINO developer by her has been used to teach AI in several universities across the globe, helping to equip the next generation of tech professionals with innovative skills. Pooja is an active member of the tech community, sharing her expertise through speaking engagements, workshops, and mentorship. Her contributions to the field have been widely recognized, including being named a Top Software Innovator by Intel and a Most Valuable Professional by Microsoft.
In addition to her work in the tech industry, Pooja is an avid traveler, passionate cook, and skilled martial artist. Her diverse interests and experiences have given her a well-rounded perspective on life and work, allowing her to approach challenges with creativity, energy, and enthusiasm.

Comments and Discussions

 
QuestionFormat Pin
Nelek31-Aug-16 3:15
protectorNelek31-Aug-16 3:15 
Questionlooks like you have copy pasted code from an old twilio tut Pin
Member 1271098030-Aug-16 2:29
Member 1271098030-Aug-16 2:29 
AnswerRe: looks like you have copy pasted code from an old twilio tut Pin
Pooja Baraskar30-Aug-16 21:14
professionalPooja Baraskar30-Aug-16 21:14 
GeneralRe: looks like you have copy pasted code from an old twilio tut Pin
Member 1271098031-Aug-16 0:51
Member 1271098031-Aug-16 0:51 
GeneralRe: looks like you have copy pasted code from an old twilio tut Pin
Member 1271098031-Aug-16 0:56
Member 1271098031-Aug-16 0:56 
GeneralMy vote of 5 Pin
Ehsan Sajjad2-Jul-16 21:31
professionalEhsan Sajjad2-Jul-16 21:31 
GeneralMy vote of 5 Pin
Renju Vinod15-Nov-15 17:29
professionalRenju Vinod15-Nov-15 17:29 
GeneralRe: My vote of 5 Pin
Pooja Baraskar3-Dec-15 8:07
professionalPooja Baraskar3-Dec-15 8:07 
Questiongood work.. Pin
Anurag Sinha V24-Oct-15 0:13
Anurag Sinha V24-Oct-15 0:13 
AnswerRe: good work.. Pin
Pooja Baraskar24-Oct-15 4:04
professionalPooja Baraskar24-Oct-15 4:04 
Generaldesire to work in internet of thing. Pin
shaad khan22-Oct-15 6:33
shaad khan22-Oct-15 6:33 
GeneralRe: desire to work in internet of thing. Pin
Pooja Baraskar22-Oct-15 9:04
professionalPooja Baraskar22-Oct-15 9:04 
GeneralRe: desire to work in internet of thing. Pin
shaad khan23-Oct-15 13:43
shaad khan23-Oct-15 13:43 
GeneralRe: desire to work in internet of thing. Pin
Pooja Baraskar23-Oct-15 23:37
professionalPooja Baraskar23-Oct-15 23:37 
GeneralMy vote of 5 Pin
DataBytzAI21-Oct-15 11:55
professionalDataBytzAI21-Oct-15 11:55 
GeneralRe: My vote of 5 Pin
Pooja Baraskar22-Oct-15 4:44
professionalPooja Baraskar22-Oct-15 4:44 
SuggestionGood one Pin
Rojalin Sahoo20-Oct-15 22:21
professionalRojalin Sahoo20-Oct-15 22:21 
GeneralRe: Good one Pin
Pooja Baraskar21-Oct-15 5:21
professionalPooja Baraskar21-Oct-15 5:21 
GeneralAwesome ! Pin
Suvendu Shekhar Giri20-Oct-15 12:42
professionalSuvendu Shekhar Giri20-Oct-15 12:42 
GeneralRe: Awesome ! Pin
Pooja Baraskar20-Oct-15 18:52
professionalPooja Baraskar20-Oct-15 18:52 
Thanks a ton Smile | :)

QuestionMy vote of 5 Pin
Abhishek Nandy20-Oct-15 10:35
professionalAbhishek Nandy20-Oct-15 10:35 
GeneralRe: My vote of 5 Pin
Pooja Baraskar20-Oct-15 18:54
professionalPooja Baraskar20-Oct-15 18:54 
GeneralMy vote of 5 Pin
Farhad Reza20-Oct-15 9:49
Farhad Reza20-Oct-15 9:49 
GeneralRe: My vote of 5 Pin
Pooja Baraskar20-Oct-15 18:54
professionalPooja Baraskar20-Oct-15 18:54 
QuestionGood Article Pin
Santhakumar M20-Oct-15 2:50
professionalSanthakumar M20-Oct-15 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.