Professional Documents
Culture Documents
Arduino
, 2012
.
,
/ .
Arduino
.
.
.
.
, ,
,
..
, ,
, , ,
.
Arduino
. ,
Arduino (Microcontroller),
( ) , Ethernet
Shield Arduino LAN.
, Arduino, , ,
Php, MySql, C, PIR, Hall
ABSTRACT
KEY WORDS
.
. ,
.
,
.
.................................................................................................................... 3
...................................................................................................................... 4
............................................................................................................ 5
.................................................................................................................. 8
.............................................................................................................. 9
............................................................................................... 11
K ............................................................................................... 13
1 - .......................................................................................... 14
1.1.
........................................................................... 15
1.2.
....................................................... 15
1.3.
................................................................................... 16
2 - ............................................................... 17
2.1.
.................................................................................... 18
2.2.
.............................................................................. 19
2.3.
........................................................................................... 19
2.4.
........................................................................... 19
2.5.
....................................................................... 20
2.6.
................................................................ 21
3 - .......................................... 24
3.1.
............................................................... 25
3.2.
........................................................................... 26
3.3.
Arduino ............................................................................................................. 26
3.3.1.
Arduino ........................................................................................ 27
3.3.2.
3.3.3.
3.3.4.
................................................ 36
3.4.
....................................................................................................... 39
3.4.1.
3.4.2.
PIR ........................................................................... 41
3.5.
............................................................................ 44
4 - .................................. 46
4.1.
................................................................. 47
4.1.1.
.............................................................................. 48
4.1.3.
CSS ........................................................................................................... 60
4.1.4.
........................................................................................ 61
4.1.5.
Arduino ............................................................................. 65
4.2.
..................................................................................... 68
4.2.1.
.................................................................................. 69
4.2.2.
.......................................................... 72
4.3.
...................................................................................... 73
4.3.1.
.......................................................................... 73
4.3.2.
. .......................................................................... 75
5 - & ............................. 76
............................................................................................................. 79
10
3.1 . 25
3.2 Arduino Uno.
28
3.3 /
29
3.4 ..
31
3.5 32
3.6 Arduino IDE
33
3.7 Shields...............................................................................
34
36
3.9
37
3.10 Hall 39
3.11 PIR
41
3.12 PIR. 42
3.13 ..
44
47
4.2 /.
48
4.3 /
49
50
4.5
51
4.6 ..
52
4.7
53
4.8 ... 54
4.9
11
55
4.10
56
4.11 . 57
4.12 .. 58
4.13 Ajax ... 59
4.11 Ajax
60
4.15 .
64
65
67
4.19 67
4.20 post_data.php string.
68
4.21 .
69
4.22 Arduino..
70
4.23 Setup...
71
4.24 mysql_real_escape_string() ..
74
4.25 ... 75
12
3.1 ..
26
63
4.2 ...
63
4.3 .. 63
4.4 Events..
63
4.5 .
63
4.6 ..
64
13
14
1.
1.1.
.
,
. ,
, ,
.
,
.
--- ..
,
,
.
.
1.2.
Arduino
, ,
.
,
,
15
,
.
1.3.
, ,
,
.
3 .
.
, .
4 .
5
.
16
17
2.
2.1.
[11]
.
,
. ,
, ,
.
, ,
, ,
,
.
, .
,
, ,
. ,
,
, ,
.
, ,
24
.
18
2.2.
[5]
, ,
. ,
, , ,
.
,
.
2.3.
[3], [8]
, , , , .
.
.
, ,
,
,
, ..
2.4.
HTML.
,
JavaScript,
.
.
,
,
.
, PHP
,
2.5.
,
, (computer on a chip).
VLSI ,
, Silicon Wafers.
. ,
.
.
.
[5]
1 0.
, assembly,
.
20
, ,
C.
. ,
.
, compiler () interpreter
(). ,
.
2.6.
Xampp
XAMPP [14] ,
http Apache, MySQL
PHP Perl.
XAMPP :
X ( "cross-platform"
)
Apache HTTP
MySQL
PHP
Perl
21
XAMPP
PHP/MySQL. Microsoft Windows, Linux,
Solaris, and Mac OS X
PHP, JSP Servlets.
. Apache [14],
, ,
Linux, Unix, Windows .. C
HTTP . ,
, PHP.
Perl, Python, Tcl, , SSL TLS.
, . PACHE,
,
.
,
, ,
.
. ,
PHP,
.
MySql Server
H MySql [17]
UNIX ,
Win32.
, MySql
standards SQL.
22
MySql
.
Arduino IDE
Arduino Arduino
IDE [21]. 3.
23
24
3.
3.1.
1 9 Arduino.
Arduino 9
. O 8
( ).
,
. /
.
3.1
25
3.2.
.
. .
:
Arduino Uno
25
Ethernet Shield
50
Hall
PIR
2xLed
0,20
:
84,20
3.2
3.3.
Arduino
Arduino
[20]
ATmega Atmel , software
,
. ,
,
/
,
.
26
Arduino
, .
Arduino Arduino.
Arduino
.
3.3.1.
Arduino
Arduino Uno.
:
-
Arduino Diecimila
Arduino Extreme
Arduino Usb
Arduino Lilypad
Arduino Nano
Arduino Mini
Arduino Duemilanove
Arduino Uno
Arduino Mega
27
Arduino
3.3.2.
Arduino Uno
ATMEGA328
5V
()
7-12V
6-20V
14(6 PWM )
40mA
3.3V
50mA
flash
32KB(ATMEGA328)
SRAM
2KB(ATMEGA328)
EEPROM
1KB(ATMEGA328)
16MHz
28
Arduino Uno
USB,
2.1mm ( ) -
Arduino. ,
7 12V ,
DC.
3.3 /
:
Vin: .
.
(jack), Vin.
5V:
5V. , , 5V
USB, Vin.
3.3V: FTDI.
50mA.
GND: .
29
ATmega328 . flash
memory, Arduino sketch, SRAM (static random access
memory), sketch
, EPPROM,
.
-
2K SRAM
, ..
runtime. ,
Arduino reset.
1K EEPROM
/ ( datatype) byte
runtime. SRAM, EEPROM
reset .
32K Flash, 2K
30
14 ,
/ . :
3.4
31
0 1 RX TX
. ,
, USB
Serial-Over-USB, 0
.
interface, 2 / .
2 3 interrupt (interrupt 0
1 ).
,
. interrupt
.
3, 5, 6, 9, 10 11
3.5
-
6 pin, 0 5
1.1V ( 2 5V)
pin AREF
. , AREF 3.3V
32
1.65V, Arduino
512.
Arduino Uno
.
USB FTDI (drivers).
bootloader, .
Arduino Arduino IDE. Arduino
IDE Java :
-
(
sketch Arduino)
,
33
compiler sketch,
serial monitor
(USB),
Arduino
debugging sketch
-
sketch Arduino.
3.3.3.
Shield
Arduino .
hardware plugin, addon extension
software. Arduino Shields
.
3.7 Shields
Shield Arduino
,
Shield. , Shield
34
Arduino
Shield. Shield
pin Arduino .
, Shield Arduino ( ..
Shield),
extender Shield Arduino
Shield ,
. Arduino, Shield
hardware
sketch
high level. Shield
Arduino :
Shield : Arduino.
calculator OLED touchscreen
iPhone.
Motor Shields:
( DC, servo, stepper ..) Arduino.
ProtoShield: ,
Arduino Shield.
35
Ethernet Shield,
Arduino .
Arduino Ethernet Shield Arduino
Ethernet.
3.3.4.
Sketch
Arduino : (structure),
(values) (functions).
36
3.9
'//'. (//)
'/*' '*/' . ( /* *//)
IDE ,
debugging.
gcc
AVR
libc.
37
setup()
I/O
HIGH LOW
pinMode()
INPUT OUTPUT
digitalWire()
if
true - false
digitalRead()
if..else
integer constants
for
loop()
switch case
I/O
analogReference()
analogRead()
while
void
do...while
boolean
break
(unsigned)char
tone(), noTone()
continue
byte
shiftOut()
return
(unsigned)int
pulseIn()
goto
word
analogWrite()
I/O
(unsigned)long
millis(), micros()
float
delay(), delayMicroseconts()
{}
double
// /* */
string ( char)
#define
String ()
#include
array
randomSeed(), random()
Bits/Bytes
+, -, *, /, %
long(), float()
Interrupts
==, !=
attachInterrupt(), detachInterrupt()
volatile, const
interrupts(), noInterrupts()
&&, ||, !
sizeof()
Serial
3.3 Arduino
38
3.4.
:
-
3.4.1.
3.10 Hall
Hall [1], [10]
(
) / .
,
(DIS) .
.
" " ,
. ,
39
. Hall
"" on-off "" .
(AC)
, Hall
.
.
Hall :
, .
:
-
bit (1 , 0
)
,
.
Parallax Arduino
,
.
/ .
40
3.4.2.
PIR
3.11 PIR
[1]
(Passive Infrared Sensor). ,
.
PIR ,
, ,
.
.
,
PIR. ,
.
galliumnitride,
41
. H 34 C,
.
3.12 PIR
,
.
.
, . ,
,
,
, .
. ,
9 10 m. ,
8 14 m
. , Fresnel
.
42
.
, IR
.
.
,
.
. PIR
Arduino.
:
-
bit (1 , 0
)
,
.
Parallax Arduino
(
) Arduino
Pin . o ,
.
43
3.5.
3.13
Hall PIR
pull-up 10 k Data Sheets [12], [13]
Led
( HIGH).
(Breadboard) 3.13.
44
3.14 Breadboard
3.14
Breadboard .
45
46
4.
.
.
. ,
.
.
4.1.
Php, MySql
Ajax [15], [16], [17].
Web Server settings.php.
4.1
Hostname, ,
,
.
47
4.1.1.
.
.
// , ,
,
.
.
/ 4.2.
4.2 /
48
.
,
.
Session,
. Session
.
4.3 /
:
, .
:
49
Arduino
50
4.5
,
(log) .
51
:
-
,
( ), ( ),
.
, .
, Admin Settings:
4.6
:
52
4.7
.
, , Arduino ID
, Pin ID
Arduino, .
, .
53
4.8
.
, .
54
4.9
:
-
Member Settings
.
/ e-mail .
:
55
4.10
Sensors
,
.
-
rduino ID
56
4.11
Sensors
ID , .
57
4.12
4.1.2.
Ajax
58
bandwith
.
interface browser client
,
. ,
server
. AJAX, server ,
(scripts) style sheets , ,
JavaScript ,
. 4.13,
7 .
4.13 Ajax
59
4.12 Ajax
( 4.14) Ajax
( 4.13)
.
4.1.3.
CSS
h1{
color: red;
fontsize: 12px;
}
h1, html tag
h1, selector
12 pixel.
4.1.4.
MySql (RDBMS)
,
. , ,
.
.
.
MySql,
phpMyAdmin, PHP
MySql . ,
MySql, ,
SQL , .
[7],
, , .
, ,
.
61
,
,
( ,
, ..), .
:
-
: ID, Arduino Device
ID Pin ID , , Type ID
, .
-
: ID
, .
-
: ID, ,
,
.
-
: ID .
Events
5 Events
. , ,
62
, . Event
ID .
,
:
Sensors
sensor_id
device_id
pin_id
sensor_name
type_id
zone_id
sensor_status
4.1
Sensor types
type_id
type_name
4.2
Zones
zone_id
zone_name zone_status
4.3
Events
event_id
event_name
4.4 Events
History
history_id
4.5
63
pin_id
zone_id
sensor_id
Users
user_id
username
password
date
user_level
4.6
,
( )
.
( 4.15) [2]
:
4.15
64
4.1.5.
Arduino
Arduino
Php:
arduino.php
String 4.16.
GET string arduino.php.
65
Serial Monitor
4.17.
post_data.php
.
string
post_data.php .
,
php string HTTP
, Pin ID, Device ID
Event ID ( 5). E 4.18 string
Arduino , :
Pin 3 Arduino ID 1.
66
4.18 string
string ( post_data.php)
(E 4.20),
4.18.
4.19
(4.19)
,
.
67
String post_data.php
.
(event_id, pin_id, device_id )
Arduino.
4.2.
,
.
()
Loop.
.
.
Request String
String
.
String ( 4.1.5),
68
.
.
4.21
4.2.1.
69
4.22 Arduino
setup ( 4.23)
. setup
loop .
( loop), setup
noLoop();. .
70
4.23 Setup
71
TimerOne
4.2.2.
4.2.2.
,
.
,
.
SPI
(SPI)
. ,
.
SPI
Ethernet
Arduino
.
client .
(
). Arduino Uno Ethernet Shield
SPI. , digital pins 10,11,12 13 Ethernet
Shield.
72
TimerOne
TimerOne 16-bit
Timer1 ATmega168/328.
4.3.
.
.
.
4.3.1.
:
-
Session:
redirect
admin_settings.php/user_settings.php.
admin_settings.php/member_settings.php
session_start(); $_SESSION['entrance'].
(/),
. Logout
Session
session_destroy(); .
73
mysql_real_escape_string:
SQL Injection
hackers. sql
.
. (Bug). ,
,emails Hackers .
.
PHP
.
, , escaped
o SQL server '
, .
addslashes() string, ,
, .
, directive
magic_quotes_gpc,
addslashes() gpc ($_GET, $_POST) .
mysql_real_escape_string().
String SQL,
charset .
4.24 mysql_real_escape_string()
74
mysql_real_escape_string()
( 4.24) .
4.3.2.
. string
string .
4.25
75
&
76
1.
,
, ,
Arduino.
.
Server
.
Internet of things [21].
(Internet of things),
, (Future
Internet).
,
, , ()
. ()
(mainframes, servers)
(Internet),
.
. ,
-
(..
, ..)
77
Zigbee,
,
(
event).
Android iPhone.
78
[1] . . , , 2003.
[2] Batini C., Cesi S. and Navathe S., Conceptual Database Design: An EntityRelationship Approach,1992.
[3] Mahalik, N., Sensor Networks and Configuration: Fundamentals, Standards,
Platforms and Applications, 2007,
[4] Noble, J., Programming interactivity: A Designers Guide to Processing,
Arduino and openFramework, O Reilly Media,2009.
[5] Barr, M., Programming Embedded Systems in C and C ++, 1999
[6] Tan H., D orazio T., C , , 2000.
[7] Ramakrishnan R. and J. Gehrke, ,
, 2002.
[8] Ilyas M., Mahgoub I., Handbook of Sensor Networks: Compact Wireless and Wired
Sensing Systems, CRC Press, 2005.
[9] Evans, B., Arduino Programming Notebook, 2007.
[10] Lenz JE. A review of magnetic sensors, IEEE, 1990.
[11] . , , , 2009.
[12] Data Sheet of Hall Effect Sensor, US1881, 2006
[13] Data Sheet of PIR Sensor, SE-10
[14] Apache friends XAMPP: http://www.apachefriends.org, 2012
[15] PHP - Hypertext Preprocessor: http://www.php.net, 2012
[16] W3C Cascading Style Sheets: http://www.w3.org, 2012
[17] MySql - Open source database: http://www.MySql.com/, 2012
[18] Sensirion AG: http://www.sensirion.com, 2012
[19] Wiring: http://www.wiring.org.co/, 2012
[20] Arduino Homepage: http://www.arduino.cc, 2012
[21] The internet of things | Are you ready for the Internet of Things?:
http://www.theinternetofthings.eu/, 2012
79