Click here to Skip to main content
13,146,742 members (79,819 online)
Click here to Skip to main content
Add your own
alternative version

Stats

3.9K views
2 bookmarked
Posted 9 Sep 2016

How-To Intel IoT Code Samples: Earthquake Detector

, 9 Sep 2016
Rate this:
Please Sign up or sign in to vote.
This earthquake detector application is part of a series of how-to Intel® Internet of Things (IoT) code sample exercises using the Intel® IoT Developer Kit, Intel® Edison development platform, cloud platforms, APIs, and other technologies.

Editorial Note

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Introduction

This earthquake detector application is part of a series of how-to Intel® Internet of Things (IoT) code sample exercises using the Intel® IoT Developer Kit, Intel® Edison development platform, cloud platforms, APIs, and other technologies.

From this exercise, developers will learn how to:

  • Connect the Intel® Edison development platform, a computing platform designed for prototyping and producing IoT and wearable computing products.
  • Interface with the Intel® Edison platform IO and sensor repository using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore the IoT and implement innovative projects.
  • Run this code sample in Intel® XDK IoT Edition, an IDE for creating applications that interact with sensors and actuators, enabling a quick start for developing software for the Intel® Edison or Intel® Galileo board.
  • Invoke the services of the United States Geological Survey (USGS) API for accessing earthquake data.

What it is

Using an Intel® Edison board, this project lets you create an earthquake detector that:

  • Senses motion using the digital accelerometer.
  • Checks live earthquake data, using the USGS API.
  • Displays the earthquake on the LCD.

How it works

This earthquake detector constantly reads the 3-axis digital accelerometer looking for movement that could indicate an earthquake.

When it thinks it detects an earthquake, it attempts to verify with the USGS API that an earthquake actually occurred.

If so, it displays a warning on the LCD.

Hardware requirements

Grove* Starter Kit Plus containing:

  1. Intel® Edison board with an Arduino* breakout board
  2. Grove 3-Axis Digital Accelerometer
  3. Grove RGB LCD

Software requirements

  1. Intel® XDK IoT Edition

How to set up

To begin, clone the How-To Intel IoT Code Samples repository onto your computer with Git* as follows:

$ git clone https://github.com/intel-iot-devkit/how-to-code-samples.git

To download a .zip file, in your web browser go to https://github.com/intel-iot-devkit/how-to-code-samples and click the Download ZIP button on the right-hand side. Once the .zip file is downloaded, uncompress it and use the files in the directory for this example.

Adding the program to Intel® XDK IoT Edition

In Intel® XDK IoT Edition, select Import Your Node.js Project:

Then, navigate to the directory where the example project exists, and select it:

You need to connect to your Intel® Edison board from your computer to send code to it.

Click the IoT Device menu at the bottom left. If your Intel® Edison board is automatically recognized, select it.

Otherwise, select Add Manual Connection. In the Address field, type 192.168.2.15. In the Port field, type 58888. Click Connect to save your connection.

Installing the program manually on the Intel® Edison board

Alternatively, you can set up the code manually on the Intel® Edison board.

Clone the How-To Intel IoT Code Samples repository to your Intel® Edison board after you establish an SSH connection to it, as follows:

$ git clone https://github.com/intel-iot-devkit/how-to-code-samples.git

Then navigate to the directory with this example.

To install Git* on the Intel® Edison board if you don’t have it yet, establish an SSH connection to the board and run the following command:

$ opkg install git

Connecting the Grove* sensors

You need to have a Grove* Shield connected to an Arduino*-compatible breakout board to plug all the Grove devices into the Grove Shield. Make sure you have the tiny VCC switch on the Grove Shield set to 5V.

  1. Plug one end of a Grove cable into the Grove 3-Axis Digital Accelerometer, and then connect the other end to any of the I2C ports on the Grove Shield.
  2. Plug one end of a Grove cable into the Grove RGB LCD, and then connect the other end to any of the I2C ports on the Grove Shield.

Manual Intel® Edison board setup

If you're running this code on your Intel® Edison board manually, you need to install some dependencies.

To obtain the Node.js* modules needed for this example to execute on the Intel® Edison board, run the following command:

npm install

Configuring the example

To configure the example to check for earthquakes in your area, change the LATITUDE key in the config.json file as follows:

{
  "LATITUDE": "47.641944",
  "LONGITUDE": "-122.127222"
}

Running the program using Intel® XDK IoT Edition

When you're ready to run the example, make sure you have saved all the files.

Click the Upload icon to upload the files to the Intel® Edison board.

Click the Run icon at the bottom of Intel® XDK IoT Edition. This runs the code on the Intel® Edison board.

If you made changes to the code, click Upload and Run. This runs the latest code with your changes on the Intel® Edison board.

You will see output similar to the above when the program is running.

Running the program manually

To run the example manually on the Intel® Edison board, establish an SSH connection to the board and execute the following command:

node index.js

Determining the Intel® Edison board's IP address

You can determine what IP address the Intel® Edison board is connected to by running the following command:

ip addr show | grep wlan

You will see output similar to the following:

3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    inet 192.168.1.13/24 brd 192.168.1.255 scope global wlan0

The IP address is shown next to inet. In the example above, the IP address is 192.168.1.13.

For a complete list of How-To Intel® IoT Code Samples, go to Intel® Developer Zone.

For more details about this code sample, go to GitHub*.

License

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

Share

About the Author

Intel Corporation
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
Group type: Organisation

44 members


You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 9 Sep 2016
Article Copyright 2016 by Intel Corporation
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid