17
Design & Development of IOT application using Intel based Galileo Gen2 board A Practical Approach (Experimental Manual For B.Tech & M.Tech Students) For SoC and Embedded systems in association with Intel Program Designed & Developed By: Ms. Jasleen Kaur, PhD Scholar, CSE Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE Computer Science & Engineering Department Indira Gandhi Delhi Technical University for Women Kashmere Gate, Delhi-110006

Design & Development of IOT application using Intel based ...mobileeducationkit.net/labmanuals/LAB-Manual-IOT.pdf · with Intel Galileo Gen 2 and display the temperature on LCD. Exp

  • Upload
    vocong

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Design & Development of IOT application

using Intel based Galileo Gen2 board

A Practical Approach

(Experimental Manual For B.Tech & M.Tech Students)

For SoC and Embedded systems in association with

Intel Program

Designed & Developed By: Ms. Jasleen Kaur, PhD Scholar, CSE

Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE

Computer Science & Engineering Department

Indira Gandhi Delhi Technical University for Women

Kashmere Gate, Delhi-110006

LIST OF EXPERIMENTS

Exp No. Description of experiment

Exp. 1 To familiarize with Intel Galileo Gen2 board and understand

the procedure of creation and compilation of C source code.

Exp. 2

To write C source code to Interface LCD with Intel Galileo Gen 2

and display IGDTUW on LCD Display.

Exp. 3

To write C source code to Interface Temperature Sensor( LM35)

with Intel Galileo Gen 2 and display the temperature on LCD.

Exp. 4

To write C source code to Interface Temperature Sensor (LM35),

Piezo Buzzer & LCD Display with Intel Galileo Gen 2 .

Exp. 5

To write C source code to Interface Sound Detector with Intel

Galileo Gen 2 .

Exp. 6

To write C source code to Interface Bluetooth Module with Intel

Galileo Gen 2 and showing communication between Galileo Gen2

& Android Device .

INTEL BOARD

GALILEO GEN 2

Experiment 1 Objective: To familiarize with Intel Galileo Gen2 board and understand the procedure of creation and compilation of C source code.

Software Requirement: Arduino IDE

Hardware Requirement: Target board Galileo Gen2, USB Cable, Adapter

Procedure:

Step1: Download Arduino for Galileo Gen2

Windows OS Installation 1. Download Arduino IDE for Galileo Gen2 that matches your operating system. The download

is about 100MB, and comes as an archived (zip or tgz) file.

2. Unzip the file to the top directory of your drive (e.g. C:/). You can leave the unzipped

directory as named (arduino-1.5.3), or rename it to something descriptive, just make sure there

are no spaces in the name of the directory.

.

Examples Windows directory structure. The Arduino Galileo 1.5.3 software is installed at the top

level (C:/) of the drive.

3. Double-click, or run Arduino.exe to open up the Arduino IDE for Galileo.

Mac OS Installation

1. Mac users should unzip application and move it into your Applications folder. You can

rename the application (to differentiate it from any other Arduino installs), but make sure

there are no spaces in the name.

Example Mac directory structure. We’ve renamed the application to ArduinoGalileo to differentiate

it from our other Arduino install.

2. Double-click your newly downloaded Arduino application to run the IDE.

Linux Installation

1. Linux users need to use the tar tool to extract the tar.gz file. A command like tar -zxvf

arduino-1.5.3-linux32.tar.gz should do.

2. Disable the modem manager on most Linux distributions, to enable uploading to the board.

This will vary by distro, but something like sudo apt-get remove modemmanager will work.

3. Once installed, run the arduino file in the extracted directory. From a terminal, you can

enter ./arduino to run it.

Step 2: Install Drivers

Once you’ve downloaded and installed the software, the next step is to connect the board and install

drivers. This process differs on each operation system, follow the directions below that pertain to

your OS:

Windows

Mac OS

Linux

Windows Driver Install

1. Connect a 5V power supply to the Galileo. (The USB port alone cannot supply enough

power to run the Galileo.)

2. Connect a micro-B USB cable from the Galileo’s USB Client port to an available USB

socket on your computer.

3. Upon connecting the board, Windows will automatically attempt to install the driver and,

unsurprisingly, it will fail. We’ll have to manually install the driver.

4. Open up the Device Manager. (Either Start > Run > devmgmt.msc, or go to the Control

Panel, select System and click Device Manager.)

5. Locate the Gadget Serial v2.4 device, under the Other devices tree. Right-click that and

select Update Driver Software…

6. On the first window that pops up, click Browse my computer for driver software. And on

the next page selectBrowse… and navigate to the hardware\arduino\x86\tools folder within

your Arduino Galileo software installation. Then click Next.

7. Click Install on the next Windows Security window that pops up. And, after a number of

loading-bar-scrolls, the installation should complete and you should be greeted with

a Windows has successfully updated your driver software window.

8. Look back at the Device Manager, under the Ports tree now. There should be an entry

for Galileo (COM #). Remember which COM # your Galileo is assigned, it’ll be important

for Arduino sketch uploading and the next step, updating firmware.

Mac OS Driver Install

Mac has built-in driver support for the Galileo, so this setup should be easy. Follow the steps below

to install the board on your machine:

1. Begin by connecting 5V power to the Galileo.

2. Then connect a micro-B USB Cable from the USB Client port on the Galileo to an available

USB socket on your computer.

3. Wait a few seconds while the Galileo boots up. To verify the Galileo has enumerated

properly, open the System Information window (Hold Option > Click the Apple menu in the

top left > Click System Information), and check under the USB tab for a Gadget Serial

v2.4entry.

4. You can also check under the Network tab to find the Device Name of your Galileo.

Linux Driver Install

Like Mac, drivers are not necessary to use the Galileo with Linux. Follow the steps below to install

the board:

1. Connect 5V power to the Galileo (before connecting USB).

2. Connect a micro-B USB cable from the USB Client port on the Galileo to an available socket

on your computer.

3. Open a terminal and type ls /dev/ttyACM*

4. Take note of the port number that the Galileo is assigned to, you’ll need that when you

upload code to the board.

Step3: Updating Firmware

Updating the Galileo firmware is a good first step to take after driver installation. It helps to prove

that your software and drivers are set up correctly, and it prepares your Galileo board with the most

up-to-date firmware available. Follow the steps below to update your Galileo board’s firmware.

a) Reboot the Galileo (No SD Cards!)

To reboot the Galileo, first unplug the USB cable. Then unplug the 5V adapter from the board. If

there is an SD card in the Galileo, remove it before powering the board back up.

To power the board back up, make sure you plug the 5V cable in first, then plug in a USB cable into

the USB Client port.

b) Set Up the Arduino Galileo IDE

Open up the Galileo-specific Arduino software you downloaded earlier. Mac users can double-click

the application file, Windows users should run the Arduino.exe file at the top level of the unzipped

folder.

Serial Port Selection

Double-check that the title of the Window has Arduino 1.5.3 at the top. Then the first step is to select

the serial port. Go to the Tools menu, then hover over Serial Port. On a Windows machine, select

the COM port you saw earlier in the Device Manager. On a Mac machine, select

the /dev/cu.usbmodemXXXX (make sure it’s the cu option) that matched what you found in

theSystem Information panel.

Board Selection

Under the Tools > Board menu, make sure Intel ® Galileo is selected. (Not that you have any other

choice.)

c) Firmware Update

To update the board firmware go to Help > Firmware Update. Then click Yes to proceed.

The software will attempt to communicate with your board, and read the current version of the

firmware. On the next window that pops up, select Yes to acknowledge that you’d like to upgrade the

firmware, and the process will begin.

While the progress bar zooms across your screen, make sure you don’t unplug either power or

USB from the Galileo. As the pop-up says, the update procedure will take about five minutes. A

Target Firmware Upgraded Successfully pop-up will appear after the update completes.

Uploading Blink

As always, the first program to be uploaded to a board is the “Hello, world” of microcontrollers -

Blink.

To open the Blink example, go to the File > Examples > 01.Basics > Blink.

Source Code 1: Table 1.1

/* Blink

Turns on an LED on for one second, then off

for one second, repeatedly. */

// Pin 13 has an LED connected on most Arduino

boards.

// give it a name:

int led = 13;

// the setup routine runs once when you press

reset:

void setup() {

// initialize the digital pin as an output.

pinMode(led, OUTPUT);

}

// the loop routine runs over and over again

forever:

void loop() {

digitalWrite(led, HIGH); // turn the LED on

(HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(led, LOW); // turn the LED off

by making the voltage LOW

delay(1000);

// wait for a second

}

Make sure the Serial Port and Board selections are still correct. Compilers supported are GCC and

ICC. Then click the Upload button. Upload Button will Compile and run the code.

After the upload completes, you should see a tiny, green LED blinking on and off every second. This

LED is connected to pin 13 of the Galileo.

Result :- Compilation and Installation of Arduino IDE & Drivers is done and process understood. Conclusion :- Target board of such types can be used in low cost system designs using very less amount of components and can be used for many user defined applications or customizations.

Experiment 2 Objective: To write C source code to Interface LCD with Intel Galileo Gen 2 and display IGDTUW on LCD Display.

Software Requirement: Arduino IDE for Galileo Gen2

Hardware Requirement: Target board Intel Galileo Gen2, USB Cable, LCD, Connecting wires,

adapter

Procedure:

1. Write desired C source code 2. Compile the code as described in experiment1.

Source Code 1: Table 2.1

#include <LiquidCrystal.h>

// initialize the library with the numbers of the

interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("IGDTUW");

}

void loop()

{

// Turn off the cursor:

lcd.noCursor();

delay(500);

// Turn on the cursor:

lcd.cursor();

delay(500);

}

Snapshot:-

Result:- Output observed at LCD, as per compiled C source code.

Experiment 3 Objective: To write C source code to Interface Temperature Sensor( LM35) with Intel Galileo Gen 2 and display the temperature on LCD.

Software Requirement: Arduino IDE for Galileo Gen2

Hardware Requirement: Target board Intel Galileo Gen2, USB Cable, LCD, LM35, Connecting

wires, adapter

Procedure:

1. Write desired C source code 2. Compile the code as described in experiment1.

Source Code 1: Table 3.1

#include <LiquidCrystal.h> //initializes/defines the output pin of the LM35 temperature sensor int outputpin= 0; //this sets the ground pin to LOW and the input voltage pin to high // BS E D4 D5 D6 D7 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16,2); } //main loop

void loop() { int rawvoltage= analogRead(outputpin); float millivolts= (rawvoltage/1024.0) * 5000; float celsius= millivolts/10; lcd.setCursor(0, 0); lcd.print(" BY IGDTUW:ESENS,"); lcd.setCursor(0, 1); lcd.print(celsius); lcd.print("C"); delay(1000); } }

Snapshot:-

Result:- Output observed at LCD, as per compiled C source code.

Experiment 4 Objective: To write C source code to Interface Temperature Sensor (LM35), Piezo Buzzer & LCD Display with Intel Galileo Gen 2 .

Software Requirement: Arduino IDE for Galileo Gen2

Hardware Requirement: Target board Intel Galileo Gen2, USB Cable, LM35, LCD , piezo buzzer,

Connecting wires, adapter

Procedure:

1. Write desired C source code 2. Compile the code as described in experiment1.

Source Code 1: Table 4.1

#include <LiquidCrystal.h> int outputpin= 0; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16,2); pinMode(10, OUTPUT); } void loop() { while(1) { int rawvoltage= analogRead(outputpin); float millivolts= (rawvoltage/1024.0) * 5000; float celsius= millivolts/10;; lcd.setCursor(0, 0);

lcd.print(" BY IGDTUW:ESENS,"); lcd.setCursor(0, 1); lcd.print(celsius); lcd.print("C"); } if(celsius>25) { digitalWrite(10, HIGH); delay(1000); } else { digitalWrite(10, LOW); delay(1000); } delay(1000); }

Snapshot:-

Result:- Output observed at LCD, as per compiled C source code. Output is correlated with the

actual temperature. If the temperature goes beyond the predefined threshold value (e.g. 30C in this

example) then the buzzer will sound and in the reverse condition, the buzzer will stop making sound.

Experiment 5 Objective: To write C source code to Interface Sound Detector with Intel Galileo Gen 2 .

Software Requirement: Arduino IDE for Galileo Gen2

Hardware Requirement: Target board Intel Galileo Gen2, USB Cable, Sound Detector, Connecting

wires, Adapter

Procedure:

1. Write desired C source code 2. Compile the code as described in experiment1.

Source Code 1: Table 5.1

int sensorPin = A0; // select the input pin for the

potentiometer

int ledPin = 13; // select the pin for the LED

int sensorValue = 0; // variable to store the value

coming from the sensor

void setup ()

{

pinMode (ledPin, OUTPUT);

Serial.begin (9600);

}

void loop ()

{

sensorValue = analogRead (sensorPin);

digitalWrite (ledPin, HIGH);

delay (sensorValue);

digitalWrite (ledPin, LOW);

delay (sensorValue);

Serial.println (sensorValue, DEC);

}

Snapshot:-

Result:- Output observed at Serial Monitor, as per compiled C source code. The sound detector

detects the sound and display the values on the serial monitor.

.

Experiment 6 Objective: To write C source code to Interface Bluetooth Module with Intel Galileo Gen 2 and showing communication between Galileo Gen2 & Android Device .

Software Requirement: Arduino IDE for Galileo Gen2, Bluetooth SPP Manager for Android device.

Hardware Requirement: Target board Intel Galileo Gen2, USB Cable, Sound Detector, Connecting

wires, Adapter

Procedure:

1. Write desired C source code 2. Compile the code as described in experiment1.

Source Code 1: Table 5.1

void setup()

{

// put your setup code here, to run once:

// Open serial communications and wait for port

to open:

Serial.begin(9600);

while (!Serial)

{

; // wait for serial port to connect.

}

Serial.println("Goodnight moon!");

// set the data rate for the SoftwareSerial port

Serial1.begin(9600);

Serial1.println("Hello, world?");

}

void loop()

{

if (Serial1.available())

Serial.write(Serial1.read());

if (Serial.available())

Serial1.write(Serial.read());

}

Snapshot:-

Result:- Output observed at Serial Monitor & Android Device, as per compiled C source code. Send

and receive data between mobile phone and serial monitor. To receive data on mobile phone, Bluetooth

SPP manager has to be installed.