Você está na página 1de 6

Intel Galileo Gen2- IOT with Python

1. Overview of IOT:

As per the hardware and software engineers point of view, IOT is to build interconnected
products. Embedded systems are already playing a crucial role in the development of the IoT. In
broad strokes, there are four main components of an IoT system:
The Thing itself (the device)
The Local Network; this can include a gateway, which translates proprietary
communication protocols to Internet Protocol
The Internet
Back-End Services; enterprise data systems, or PCs and mobile devices

2. Intel Gelileo Gen2 - GPIO interface from Linux

What is a GPIO?
GPIO - General Purpose Input/Output(GPIO) : It is a flexible software-controlled digital signal.
GPIOs are provided from many kinds of chip, and are familiar to Linux developers working
with embedded and customer hardware.

Each GPIO represents a bit connected to a particular pin or ball on Ball Array Grid(BG)
System-on-Chip (SOC) process heavily relay on GPIOs. In some cases, every non-dedicated pin
can be configured as a GPIO.
The Capabilities of GPIOs:
The exact capabilities of GPIOs vary between systems. Here some of the common properties are
below

GPIO pins can be configured to be input or output


GPIO pins can be enabled/disabled
Input values are readable (typically high=1, low=0)
Output values are writable/readable
Input values can often be used as IRQs

Intel Galileo Gen 2: GPIO Control using Linux


For I/O interfacing, Galileo Gen1 used Cypress CY8C9540A IC whereas Galileo Gen2 uses
NXPs PCAL9555A IC.
The PCAL9555A is a low-voltage 16-bit General Purpose Input/Output (GPIO) expander
with interrupt and weak pull-up resistors for I2C-bus/SMBus applications.
NXP I/O expanders provide a simple solution when additional I/Os are needed while
keeping interconnections to a minimum, for example, in ACPI power switches, sensors,
push buttons, LEDs, fan control, etc
Setting up a serial communication with board:
1. Open a new terminal(Ctrl+Alt+t) .

Note: If screen shell session manager is not installed enter the below command
#sudo apt-get install screen

2. To connect to the board, enter the following command and enter password
#sudo screen /dev/ttyUSB0 115200

3. Press Enter twice. A login screen is displayed.

4. At the login prompt, type root and press Enter.


5. Press Enter when prompted for a password. Type root as password. The following
screen is displayed:

You have now established serial communication with your board. You can now interact with
your board by entering common Linux commands.
Configuring GPIO Port
Lets assume gpio40 corresponds to Digital Pin8. Following commands will show how to
instantiate, set direction, define drive strength and set/read the value of a GPIO port.
Before configuring the GPIO port the sys file system as below. Form the screen shot, there is no
folder named with gpio40

Instantiation of GPIO:
# echo -n "40" > /sys/class/gpio/export
Above command will create /sys/class/gpio/gpio40 folder. Please verify the below screen shot

Defining GPIO direction:


To set the direction to output execute the below command.
# echo -n "out" > /sys/class/gpio/gpio40/direction

Above command will set the direction of gpio40 to out. To set the direction to input then
execute
#echo -n in > /sys/class/gpio/gpio40/direction

Defining/Reading GPIO Value:


If the direction is set to output, below command will set the output of gpio40 port to high.
#echo -n "1" > /sys/class/gpio/gpio40/value

If the direction is set to output, below command will set the output of gpio40 port to low.
#echo -n "0" > /sys/class/gpio/gpio7/value
Screen shot for the above commands

To get the port value, type the below command on terminal


#cat /sys/class/gpio/gpio40/value
Note: If the direction is set to input, above command will return the value measured by
gpio40 port.
Removing GPIO:
#echo -n "7" > /sys/class/gpio/unexport
Above command will remove /sys/class/gpio/gpio40 folder.

The mapping for Digital I/O and gpio

Galileo Gen2 has 79 gpio ports and only 13 of them will correspond to on boards Digital I/O
pins.

Ref: https://en.wikipedia.org/wiki/General-purpose_input/output

GPIO

Digital I/O

gpio11

pin0

gpio12

pin1

gpio13

pin2

gpio14

pin3

gpio6

pin4

gpio0

pin5

gpio1

pin6

gpio38

pin7

gpio40

pin8

gpio4

pin9

gpio10

pin10

gpio5

pin11

gpio15

pin12

gpio7

pin13

Você também pode gostar