50
IoT with Intel Galileo Gerardo Carmona makerobots.tk

IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

  • Upload
    others

  • View
    21

  • Download
    0

Embed Size (px)

Citation preview

Page 1: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

IoT with Intel GalileoGerardo Carmona

makerobots.tk

Page 2: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

OutlineWhat is Intel Galileo?

Hello world! In Arduino

Arduino and Linux

Linux via SSH

Playing around in Linux

Programming flexibility

How GPIOs works

Challenge 1: Bash script

makerobots.tk

Page 3: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

What isIntel Galileo?

makerobots.tk

Page 4: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Intel GalileoThe Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor, a 32-bit Intel® Pentium® brand system on a chip (SoC). It is the first board based on Intel® architecture designed to be hardware and software pin-compatible with shields designed for the Arduino Uno* R3.

This platform provides the ease of Intel architecture development through support for the Microsoft Windows*, Mac OS*, and Linux* host operating systems. It also brings the simplicity of the Arduino integrated development environment (IDE) software.

From Intel website, Galileo overview

makerobots.tk

Page 5: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Intel Galileo

Intel Galileo Gen 2 Intel Galileo Gen 1

makerobots.tk

Page 6: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Intel Galileo Gen 1

5 V input

Micro SD slot

SD card LED, powerLED and Reset button

Ethernet

RS-232 USB client USB Host

Digital pins, some PWM, Serial, I2C and others

Power pins & analog pins

Quark SoC X1000

Reboot

RAM memory

Pin 13 LED

makerobots.tk

Page 7: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Intel Galileo Gen 2

Ethernet port

6 pin FTDI header

USB device port USB host port Pin 13 LED, Power LED and SD card LED

Digital pins, some PWM, Serial, I2C and others

RAM memory

Quark SoC X1000

Power pins & analog pins

Reset button (sketch)

7 to 15 V input

Micro SD Card slot

Reboot Linux button

makerobots.tk

Page 8: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Hello world! In Arduino

makerobots.tk

Page 9: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Hello World! - ArduinoBefore we can program our Intel Galileo board we need to do some setup steps, like installing drivers, software, etc.

Refer to “Installing Intel Galileo.pdf” in my webpage for more details.

makerobots.tk

Page 10: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Hello World! - ArduinoOpen Arduino IDE.

Open file under:

“File >> Examples >> 01.Basics >> Blink“ menú

Go to menu “Tools >> Boards >> Galileo Gen 2”

Then “Tools >> Serial port >> COMx” and select corresponding COM port for your Galielo.

If you do not know which one it is, go to “Device manager” and look under COM and LTP ports.

Compile, Upload, New, Open, Save

makerobots.tk

Page 11: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Hello World! - ArduinoCode:

void setup() {// initialize digital pin 13 as an output.pinMode(13, OUTPUT);

}

// the loop function runs over and over again forevervoid loop() {digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage

level)delay(1000); // wait for a seconddigitalWrite(13, LOW); // turn the LED off by making the voltage LOWdelay(1000); // wait for a second

}

makerobots.tk

Page 12: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Arduino + Linux

makerobots.tk

Page 13: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Arduino + LinuxYou can combine the easy to use of Arduino and the power of an Operative System like Linux.

From the Arduino code you can make “system calls” to the Linux side using system command.

Example:

system(“ls > /dev/ttyGS0”);

System command

List of directories

Redirect output to…

Serial port

http://explainshell.com/

makerobots.tk

Page 14: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Arduino + LinuxWhat if I want to know my Galielo’s IP address?

makerobots.tk

Page 15: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Arduino + LinuxWhat if I want to know my Galielo’s IP address?

R: Using ifconfig. upload this program

void setup() {// Init serial comSerial.begin(9600);// Waits 5 seconds before printing itdelay(5000);// Gets network interface info and sends // it through the serial interfacesystem("ifconfig > /dev/ttyGS0");

}

void loop() {}

makerobots.tk

Page 16: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Arduino + Linux

makerobots.tk

Page 17: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Linux via SSH

makerobots.tk

Page 18: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Linux via SSHSecure Shell is a encrypted network protocol that initializes sessions on remote machines.

We can connect to our Intel Galileo Linux-side using SSH. Follow the next steps (windows):

1) Connect your Intel Galileo to your local network

2) Get PuTTy o r any other SSH client, for PuTTY go to:

http://www.putty.org/

makerobots.tk

Page 19: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Linux via SSH

Open PuTTy and configure as shown

1

2 3

4

1. Select SSH2. Write Galileo’s IP

address3. Leave port as 224. Click Open

makerobots.tk

Page 20: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Linux via SSHThe following window opens

Type root as username and hit enter, no password is required

makerobots.tk

Page 21: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Linux via SSHNow you are inside Linux Yocto Project

https://www.yoctoproject.org/

makerobots.tk

Page 22: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around withLinux

makerobots.tk

Page 23: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around with LinuxNow we can create files, folders, navigate though the Linux file system.

You can use common Linux commands such as “ls”, “cd”, “cd ..”, “rm”, …

Create a folder and name it as “semanai”

makerobots.tk

Page 24: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around with LinuxNow we can create files, folders, navigate though the Linux file system.

You can use common Linux commands such as “ls”, “cd”, “cd ..”, “rm”, …

Create a folder and name it as “semanai”

Navigate to the folder

$ mkdir semanai$ lssemanai

makerobots.tk

Page 25: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around with LinuxNow we can create files, folders, navigate though the Linux file system.

You can use common Linux commands such as “ls”, “cd”, “cd ..”, “rm”, …

Create a folder and name it as “semanai”

Navigate to the folder

Create a file and name it hello.txt

$ mkdir semanai$ lssemanai

$ cd semanai

makerobots.tk

Page 26: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

No nano editor =´(We will use vi editor, old school…

makerobots.tk

Page 27: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around with LinuxNow we can create files, folders, navigate though the Linux file system.

You can use common Linux commands such as “ls”, “cd”, “cd ..”, “rm”, …

Create a folder and name it as “semanai”

Navigate to the folder

Create a file and name it hello.txt

$ mkdir semanai$ lssemanai

$ cd semanai

$ vi hello.txt

makerobots.tk

Page 28: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

New fileWrite “Hello world” and save it

http://www.lagmonster.org/docs/vi.html

makerobots.tk

Page 29: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Vi editorTo start editing this file press “i” (insert mode).

Now you can type your text, after you finish, to save and exit file:

•Press escape key (exit editing mode)

•Type “:wq” (write and quit command)

makerobots.tk

Page 30: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Playing around with LinuxIf you want to display the content of a file in terminal type:

$ cat hello.txt

makerobots.tk

Page 31: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Programming flexibility

makerobots.tk

Page 32: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Programming flexibilityOne of the advantages of having a OS is that we can program using different programming languages.

We will make hello world in the following programming languages:

Bash

Python

C

Node.js

makerobots.tk

Page 33: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

BashA shell script is a file containing one or more commands that you would type on the command line.

Create a file and name it hellobash.sh and write the following lines

Execute the file by typing:

#!/bin/bash#Author: Gerardo Carmonaprintf "Hello world! \n"

$ sh hellobash.sh

In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark (that is, "#!") at the beginning of a script.The program loader is instructed to run the program "/bin/sh" instead (usually this is the Bourne shell or a compatible shell), passing "path/to/script" as the first argument.

makerobots.tk

Page 34: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

PythonCreate a file and name it hellopython.py and write the following lines

Execute the file by typing:

#!/usr/bin/python#Author: Gerardo Carmonaprint “Hello world!”

$ python hellopython.py

This is Python 2.x compatible only

makerobots.tk

Page 35: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

CCreate a file and name it helloc.c and write the following lines

Compile file

Execute compiled file

//Author: Gerardo Carmona#include <stdio.h>int main(){

printf(“Hello world!\n”);}

$ gcc helloc.c –o hello

$ ./hello

makerobots.tk

Page 36: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Node.jsCreate a file and name it hellonode.js and write the following lines

Execute the file by typing:

// Author: Gerardo Carmonaconsole.log("Hello world!");

$ node hellonode.js

makerobots.tk

Page 37: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

How GPIOs Works

makerobots.tk

Page 38: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Galileo Gen 1 Pinout

makerobots.tk

Page 39: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsTo see a list of GPIOs type:

$ cat /sys/kernel/debug/gpio

http://bit.ly/1iHk5Ji

makerobots.tk

Page 40: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsYou will observe that Galileo Gen2 contains 79 GPIO ports.

Some of these pins are connected to the Arduino headers:

https://anandvetcha.wordpress.com/category/galileo/

GPIO Digital I/O--------------------------gpio11 pin0gpio12 pin1gpio13 pin2gpio14 pin3gpio6 pin4gpio0 pin5gpio1 pin6

GPIO Digital I/O--------------------------gpio38 pin7gpio40 pin8gpio4 pin9gpio10 pin10gpio5 pin11gpio15 pin12gpio7 pin13

makerobots.tk

Page 41: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsWhile the Intel Galileo, in essence, a very inexpensive Linux computer, there are a few things that distinguish it from laptop and desktop machines that we usually use for writing email, browsing the web, or word processing.

One of the main differences is that the Intel Galileo can be directly used in electronics projects because it has general purpose input and output pins right on the board.

It also lacks a video output to connect to a monitor

makerobots.tk

Page 42: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Virtual filesIn order to manage gpios you need to write some configurations to different virtual files.

They are a part of Linux’s virtual file system, which is a system that makes it easier to access low-level functions of the board in a simpler way.

For example, you could turn the LED on and off by writing to a particular section of the Intel Galileo memory, but doing so would require more coding and more caution.

makerobots.tk

Page 43: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Turning ON/OFF an LED

makerobots.tk

Page 44: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsLets turn On/Off pin 8, that’s gpio40. First we need to export gpio:

Above command will create “/sys/class/gpio/gpio40” folder.

$ echo -n “40" > /sys/class/gpio/export

makerobots.tk

Page 45: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsLets turn On/Off pin 8, that’s gpio40. First we need to export gpio:

Above command will create “/sys/class/gpio/gpio40” folder.

Set the direction of gpio40 to “out”.

$ echo -n “40" > /sys/class/gpio/export

$ echo -n "out" > /sys/class/gpio/gpio40/direction

makerobots.tk

Page 46: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsLets turn On/Off pin 8, that’s gpio40. First we need to export gpio:

Above command will create “/sys/class/gpio/gpio40” folder.

Set the direction of gpio40 to “out”.

Now we can turn on the LED and off:

$ echo -n “40" > /sys/class/gpio/export

$ echo -n "out" > /sys/class/gpio/gpio40/direction

$ echo -n "1" > /sys/class/gpio/gpio40/value$ echo -n “0" > /sys/class/gpio/gpio40/value

makerobots.tk

Page 47: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Accessing GPIOsLets turn On/Off pin 8, that’s gpio40. First we need to export gpio:

Above command will create “/sys/class/gpio/gpio40” folder.

Set the direction of gpio40 to “out”.

Now we can turn on the LED and off:

Unexport pin

$ echo -n “40" > /sys/class/gpio/export

$ echo -n "out" > /sys/class/gpio/gpio40/direction

$ echo -n "1" > /sys/class/gpio/gpio40/value$ echo -n “0" > /sys/class/gpio/gpio40/value

$ echo -n "40" > /sys/class/gpio/unexport

makerobots.tk

Page 48: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Challenge 1Make a script in bash that blinks 10 times an LED. Use LED located on Pin 8 on Arduino (gpio40).

makerobots.tk

Page 49: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Some helpFor cicle in bash:

for i in `seq 1 10`;do

# Printecho $i

done

Challenge 1:Make a script in bash that blinks 10 times an LED. Use LED located on Pin 8 on Arduino, gpio40 in Linux.

makerobots.tk

Page 50: IoT with Intel Galileo - WordPress.com · Intel Galileo The Intel® Galileo Gen 2 development board is a microcontroller board based on the Intel® Quark™SoC X1000 application processor,

Thanks!

Time to recharge batteries!

makerobots.tk