ZigBee技術與實訓教程――基於CC2530的無線傳感網技術(第3版·微課視頻版)
薑仲、朱曉紅
相關主題
商品描述
"本書以 ZigBee無線傳感網技術為主要對象,基於以 TI公司 CC2530芯片為核心的硬件平臺,在介紹了常用傳感器編程的基礎上,深入剖析了 TI 公司的 Z-Stack協議棧架構和編程接口,並詳細講述瞭如何在此基礎上開發自己的 ZigBee項目,最後簡單介紹了 ZigBee 3.0的應用。 本書可作為工程技術人員進行單片機、無線傳感器網絡應用、 ZigBee 技術等項目開發的學習和參考用書,也可作為高等院校電腦、電子、自動化、無線通信等相關課程的教材。 "
目錄大綱
目錄
第 1章 無線傳感器網絡 .............................................................................................................1
1.1無線傳感器網絡概述 ....................................................................................................1
1.2無線傳感器網絡的發展歷程及發展趨勢 ....................................................................2
1.2.1 無線傳感器網絡的發展歷程 ............................................................................2
1.2.2 無線傳感器網絡的發展趨勢 ............................................................................3
1.3無線傳感器網絡的研究現狀和前景 ............................................................................3
1.4無線傳感器網絡的特點 ................................................................................................4
1.5無線傳感器網絡體系結構 ............................................................................................6
1.6無線傳感器網絡的關鍵技術 ........................................................................................9
1.7無線傳感器網絡應用與發展 ......................................................................................11
1.8典型短距離無線通信網絡技術 ..................................................................................14
1.9無線傳感器網絡的主要研究領域 ..............................................................................19 思考題...................................................................................................................................21
第 2章 IEEE 802.15.4無線傳感器網絡通信標準 ..................................................................22
2.1 IEEE 802.15.4標準概述 .............................................................................................22
2.2網絡組成和拓撲結構 ..................................................................................................26
2.3協議棧架構 ..................................................................................................................28
2.4物理層規範 ..................................................................................................................29
2.5 MAC層規範 ................................................................................................................31
2.6 MAC/PHY信息交互流程 ...........................................................................................38
2.7基於 IEEE 802.15.4標準的無線傳感器網絡應用實例 ................................................39 思考題...................................................................................................................................41
第 3章 ZigBee無線傳感器網絡通信標準 ..............................................................................42
3.1 ZigBee標準概述 .........................................................................................................42
3.2 ZigBee技術特點 .........................................................................................................43
3.3 ZigBee協議框架 .........................................................................................................45
3.4 ZigBee網絡層規範 .....................................................................................................46
3.5 ZigBee應用層規範 .....................................................................................................48
3.6 ZigBee安全服務規範 .................................................................................................50 思考題...................................................................................................................................50
第 4章 ZigBee開發平臺..........................................................................................................51
4.1
ZigBee硬件開發平臺 .................................................................................................52
4.1.1
CC2530射頻模塊............................................................................................52
4.1.2
調試器接口 ......................................................................................................53
4.1.3
ZigBee學習板 .................................................................................................54
4.2
ZigBee軟件開發平臺 .................................................................................................56
4.2.1
IAR簡介 ..........................................................................................................56
4.2.2
IAR基本操作 ..................................................................................................57
第 5章 CC2530基礎實驗 ........................................................................................................63
5.1
CC2530無線片上系統概述........................................................................................63
5.1.1
CC2530芯片主要特性 ....................................................................................64
5.1.2
CC2530的應用領域........................................................................................64
5.1.3
CC2530概述....................................................................................................65
5.1.4
CC2530芯片引腳的功能 ................................................................................67
5.1.5
CC2530增強型 8051內核簡介......................................................................68
5.2通用
I/O埠...............................................................................................................68
5.2.1
通用 I/O埠簡介...........................................................................................68
5.2.2
通用 I/O埠相關寄存器...............................................................................69
5.2.3
實驗:點亮 LED .............................................................................................70
5.2.4
實驗:按鍵控制 LED交替閃爍 ....................................................................71
5.3外部中斷
......................................................................................................................72
5.3.1
中斷概述 ..........................................................................................................72
5.3.2
中斷屏蔽 ..........................................................................................................73
5.3.3
中斷處理 ..........................................................................................................75
5.3.4
實驗:按鍵中斷控制 LED .............................................................................78
5.4定時器
..........................................................................................................................79
5.4.1
片內外設 I/O....................................................................................................79
5.4.2
定時器簡介 ......................................................................................................81
5.4.3
定時器 1寄存器..............................................................................................81
5.4.4
定時器 1操作..................................................................................................82
5.4.5
16位計數器 .....................................................................................................83
5.4.6
實驗:定時器 1控制 LED閃爍 ....................................................................84
5.4.7
定時器 3/4概述...............................................................................................85
5.4.8
實驗:定時器 1和定時器 3同時控制 LED1和 LED2以不同頻率閃爍 .....86
5.5
1602型 LCD ................................................................................................................88
5.5.1
1602型 LCD簡介 ...........................................................................................88
5.5.2
1602型 LCD引腳功能 ...................................................................................88
5.5.3
1602型 LCD的特性 .......................................................................................88
5.5.4
1602型 LCD字符集 .......................................................................................88
5.5.5
1602型 LCD基本操作程序 ...........................................................................89
5.5.6
1602型 LCD指令集 .......................................................................................90
5.5.7
1602型 LCD 4線連接方式 ............................................................................90
5.5.8
實驗: LCD顯示實驗 .....................................................................................90
5.6 USART .........................................................................................................................94
5.6.1
串行通信接口 ..................................................................................................94
5.6.2
串行通信接口寄存器 ......................................................................................95
5.6.3
設置串行通信接口寄存器波特率 ..................................................................97
5.6.4
實驗: UART發送 ..........................................................................................97
5.6.5
UART接收 ......................................................................................................99
5.6.6
實驗: UART發送與接收 ..............................................................................99
5.7 ADC............................................................................................................................102
5.7.1
ADC簡介 ......................................................................................................102
5.7.2
ADC輸入 ......................................................................................................102
5.7.3
ADC寄存器 ..................................................................................................103
5.7.4
ADC轉換結果 ..............................................................................................105
5.7.5
單個 ADC轉換 .............................................................................................105
5.7.6
實驗:片內溫度傳感器實驗 ........................................................................105
5.8睡眠定時器
................................................................................................................106
5.8.1
睡眠定時器簡介 ............................................................................................106
5.8.2
睡眠定時器寄存器 ........................................................................................107
5.8.3
實驗:睡眠定時器喚醒實驗 ........................................................................107
5.
9時鐘和電源管理 ........................................................................................................ 111
5.9.1
CC2530電源管理簡介 .................................................................................. 111
5.9.2
CC2530電源管理控制 .................................................................................. 111
5.9.3
CC2530振盪器和時鐘 ..................................................................................112
5.9.4
實驗:中斷喚醒系統實驗 ............................................................................112
5.10看門狗
......................................................................................................................114
5.
10.1看門狗模式 ................................................................................................115
5.
10.2定時器模式 ................................................................................................115
5.
10.3看門狗定時器寄存器 ................................................................................115
5.
10.4實驗:看門狗實驗 ....................................................................................116
5.11 DMA.........................................................................................................................118
5.11.1
DMA操作..................................................................................................118
5.11.2
DMA配置參數..........................................................................................119
5.11.3
DMA配置安裝..........................................................................................121
5.11.4實驗: DMA傳輸......................................................................................122 思考題.................................................................................................................................125
第 6章常用傳感器 .................................................................................................................126
6.
1數字溫濕度傳感器 DHT11 .......................................................................................126
6.1.1
DHT11簡介...................................................................................................126
6.1.2
DHT11典型應用電路 ...................................................................................126
6.1.3
DHT11串行接口...........................................................................................126
6.1.4
DHT11串行接口通信過程 ...........................................................................127
6.1.5
實驗: DHT11實驗.......................................................................................128
6.
2紅外人體感應模塊實驗 ............................................................................................131
6.2.1
紅外人體感應模塊功能特點 ........................................................................131
6.2.2
實驗:紅外人體感應模塊實驗 ....................................................................132
6.
3結露傳感器實驗 ........................................................................................................132
6.3.1
結露傳感器 HDS05特性曲線 ......................................................................132
6.3.2
結露傳感器 HDS05電路設計 ......................................................................133
6.3.3
實驗:結露傳感器實驗 ................................................................................133
6.
4煙霧傳感器模塊 ........................................................................................................135
6.4.1
煙霧傳感器模塊的功能特點 ........................................................................135
6.4.2
實驗:煙霧傳感器模塊實驗 ........................................................................135
6.
5光強度傳感器模塊 ....................................................................................................136
6.5.1
數字光模塊 GY-30介紹 ...............................................................................136
6.5.2
I2C總線介紹 .................................................................................................137
6.5.3
實驗:光強度傳感器模塊實驗 ....................................................................138 思考題.................................................................................................................................142
第 7章 CC2530實現紅外通信 ..............................................................................................143
7.1紅外通信簡介
............................................................................................................143
7.1.1
紅外通信的特點 ............................................................................................143
7.1.2
紅外發射和接收 ............................................................................................143
7.1.3
紅外遙控發送和接收電路 ............................................................................144
7.1.4
紅外發射電路 ................................................................................................145
7.1.5
NEC協議.......................................................................................................145
7.
2實驗:中斷方式發射紅外信號 ................................................................................145
7.3實驗:
PWM方式輸出紅外信號 ..............................................................................150
7.
4實驗:紅外接收實驗 ................................................................................................154
第 8章 Z-Stack協議棧...........................................................................................................158
8.1
Z-Stack協議棧基礎...................................................................................................158
8.1.1
Z-Stack協議棧簡介 ......................................................................................158
8.1.2
Z-Stack協議棧基本概念 ..............................................................................158
8.1.3
Z-Stack的下載與安裝 ..................................................................................160
8.2
Sample Application工程 ...........................................................................................161
8.2.1
Sample Application工程簡介 .......................................................................161
8.2.2
Sample Application工程概況 .......................................................................163
8.2.3
Sample Application工程初始化與事件的處理............................................163
8.2.4
Sample Application工程事件的處理函數....................................................164
8.2.5
Sample Application工程流程 .......................................................................165
8.3
OSAL循環.................................................................................................................169
8.3.1
Z-Stack的任務調度 ......................................................................................169
8.3.2
Z-Stack主函數 ..............................................................................................170
8.3.3
Z-Stack任務的初始化 ..................................................................................171
8.3.4
Z-Stack的系統主循環 ..................................................................................172
8.
4數據的發送和接收 ....................................................................................................174
8.4.1
網絡參數的設置 ............................................................................................174
8.4.2
數據的發送 ....................................................................................................176
8.4.3
數據的接收 ....................................................................................................178
8.5修改
LED驅動 ..........................................................................................................180
8.6修改按鍵驅動
............................................................................................................183
8.6.1
Z-Stack的按鍵機制概述 ..............................................................................183
8.6.2
Z-Stack按鍵的宏定義 ..................................................................................184
8.6.3
Z-Stack按鍵初始化代碼分析 ......................................................................184
8.6.4
Z-Stack按鍵的配置 ......................................................................................186
8.6.5
Z-Stack輪詢方式按鍵處理 ..........................................................................188
8.6.6
Z-Stack中斷方式按鍵處理 ..........................................................................193
8.7
Z-Stack 2007串口機制 ..............................................................................................198
8.7.1
串口配置 ........................................................................................................198
8.7.2
串口初始化 ....................................................................................................199
8.7.3
串口接收數據 ................................................................................................203
8.7.4
串口發送數據 ................................................................................................207
8.8
Z-Stack啟動分析 ......................................................................................................209
8.8.1
啟動配置 ........................................................................................................209
8.8.2
Z-Stack啟動相關概念 ..................................................................................209
8.8.3
SampleApp工程協調器啟動過程分析 ........................................................213
8.9
ZigBee綁定機制 .......................................................................................................216
8.10
SimpleApp工程.......................................................................................................217
8.10.1
SimpleApp的打開.....................................................................................217
8.10.2
SimpleApp啟動分析 .................................................................................218
8.11燈開關實驗
..............................................................................................................219
8.11.1 SimpleController.c......................................................................................219
8.11.2 SimpleSwitch.c...........................................................................................222
8.11.3燈開關實驗其他函數分析 ........................................................................226
8.
12傳感器採集實驗 ......................................................................................................226
8.12.1 SimpleCollector.c.......................................................................................226
8.12.2 SimpleSensor.c...........................................................................................228
8.13
GenericApp 工程......................................................................................................229
8.13.1
GenericApp 工程概述 ...............................................................................229
8.
13.2關鍵函數分析 ............................................................................................230
8.13.3
GenericApp工程實現數據的收發 ............................................................231
第 9章智能家居系統 .............................................................................................................234
9.
1智能家居系統設計 ....................................................................................................234
9.1.1
智能家居系統的需求分析 ............................................................................234
9.1.2
智能家居系統分析 ........................................................................................234
9.1.3
智能家居系統軟件設計 ................................................................................235
9.
2智能家居系統開發環境的搭建 ................................................................................235
9.2.1
Mini6410 ARM11開發板 .............................................................................236
9.2.2
建立 Android應用開發環境 .........................................................................236
9.2.3
在 Android程序中訪問串口 .........................................................................239
9.2.4
Android上的 Servlet服務器 i-jetty..............................................................240
9.
3智能家居系統下位機程序設計 ................................................................................241
9.3.1
下位機程序設計思路 ....................................................................................241
9.3.2
一鍵報警功能下位機實現 ............................................................................241
9.3.3
水浸報警功能下位機實現 ............................................................................242
9.3.4
中斷方式報警的紅外入侵傳感器的實現 ....................................................243
9.
4智能家居系統設置模塊 ............................................................................................244
9.4.1
SQLite簡介 ...................................................................................................244
9.4.2
Android系統中 SQLite數據庫的操作 ........................................................245
9.4.3
智能家居系統設置模塊的實現 ....................................................................246
9.
5智能家居系統監聽服務 ............................................................................................248
9.5.1 Android Service..............................................................................................248
9.5.2
Android多線程..............................................................................................249
9.5.3
短信的發送與接收 ........................................................................................250
9.5.4
智能家居系統監聽服務的實現 ....................................................................251
9.6
Web方式訪問智能家居系統 ....................................................................................255
9.6.1
ContentProvider簡介.....................................................................................255
9.6.2
ContentProvider操作.....................................................................................256
9.6.3
創建 ContentProvider.....................................................................................258
9.6.4
Web方式訪問智能家居系統的實現............................................................258
第 10章智能溫室系統 ...........................................................................................................264
10.1
智能溫室系統設計 ..................................................................................................264
10.1.1
智能溫室定義 ............................................................................................264
10.1.2
智能溫室系統的需求分析 ........................................................................264
10.1.3
智能溫室系統分析 ....................................................................................264
10.2
入侵檢測、水浸檢測和煙霧報警的實現 ..............................................................265
10.2.1
學習板的改進 ............................................................................................265
10.2.2
入侵檢測的實現 ........................................................................................265
10.2.3
水浸檢測的實現 ........................................................................................269
10.2.4
煙霧檢測的實現 ........................................................................................270
10.3
Wi-Fi模塊的使用....................................................................................................271
10.4 PHP...........................................................................................................................273
10.4.1
PHP簡介....................................................................................................273
10.4.2
PHP語法概述............................................................................................274
10.4.3
PHP例程....................................................................................................275
10.5 Drupal.......................................................................................................................276
10.5.1
Drupal簡介................................................................................................276
10.5.2
環境功能的實現 ........................................................................................283
10.5.3
控制功能的實現 ........................................................................................298
10.6
溫濕度檢測的實現 ..................................................................................................305
10.6.1 溫濕度傳感器 DHT11模塊的連接 ..........................................................305
10.6.2 Enddevice.c................................................................................................306
10.6.3 Coordinator.c..............................................................................................309
10.6.4 s7396.php ...................................................................................................309
10.7
光照度檢測的實現 ..................................................................................................310
10.7.1 GY-30數字光模塊簡介 ............................................................................310
10.7.2 Enddevice.c................................................................................................311
10.7.3 Coordinator.c..............................................................................................317
10.7.4 S8657.php...................................................................................................318
10.8
一鍵報警的實現 ......................................................................................................318
10.8.1 Enddevice.c................................................................................................319
10.8.2 Coordinator.c..............................................................................................319
10.8.3 alert.php......................................................................................................320
10.9
遠程控制設備的實現 ..............................................................................................320
10.9.1
繼電器簡介 ................................................................................................320
10.9.2
遠程控制設備處理流程 ............................................................................321
10.9.3 Enddevice.c................................................................................................322
10.9.4 Coordinator.c..............................................................................................323
10.9.5 lamp.php.....................................................................................................325
10.
10微信小程序訪問智能溫室系統 ............................................................................326
10.
10.1微信小程序簡介 .....................................................................................326
10.
10.2微信小程序訪問智能溫室系統的實現 .................................................326
10.10.3 lol6216.php .............................................................................................331
10.
11智能溫室系統休眠功能的實現 ............................................................................332 思考題.................................................................................................................................333
第 11章學生考勤管理系統 ...................................................................................................334
11.
1學生考勤管理系統設計 ..........................................................................................334
11.1.1
校園一卡通學生考勤管理系統的組成 ....................................................334
11.1.2
校園一卡通學生考勤管理系統的可行性分析 ........................................334
11.1.3
校園一卡通學生考勤管理系統的需求分析 ............................................335
11.
2學生考勤管理系統的時鐘功能的實現 ..................................................................335
11.2.1
DS1302實時時鐘電路 ..............................................................................335
11.2.2
DS1302實時時鐘模塊 ..............................................................................335
11.2.3
DS1302實時時鐘模塊的操作說明 ..........................................................335
11.2.4
DS1302時鐘模塊例程 ..............................................................................337
11.2.5
Z-Stack中使用 DS1302時鐘模塊實現顯示時間的功能 ........................340
11.
3學生考勤管理系統讀卡功能的實現 ......................................................................341
11.3.1
RFID介紹 ..................................................................................................341
11.3.2
M104BPC讀寫模塊 ..................................................................................342
11.3.3
例程 ............................................................................................................346
11.3.4
Z-Stack實現讀卡功能 ...............................................................................351
第 12章 ZigBee 3.0 .................................................................................................................353
12.1 ZigBee 3.0簡介 .......................................................................................................353
12.1.1 Z-Stack 3.0.2 ..............................................................................................353
12.1.2 BDB............................................................................................................354
12.1.3 Z-Stack 3.0.2數據發送實驗 .....................................................................356
12.2 ZCL ..........................................................................................................................360
12.2.1
ZCL簡介 ...................................................................................................360
12.2.2
ZCL開關命令實驗 ...................................................................................360
12.3
ZCL屬性的讀寫實驗..............................................................................................365
12.3.1
ZCL屬性讀命令實驗 ...............................................................................365
12.3.2
ZCL屬性寫命令實驗 ...............................................................................369
12.4
CC2530節點與 CC2652R雙協議節點的通信實驗 ..............................................373
12.4.1
SimpleLink MCU平臺 ..............................................................................373
12.4.2
多協議無線 MCU......................................................................................374
12.4.3 CC2652R....................................................................................................374
12.4.4 SIMPLELINK-CC13XX-CC26XX-SDK ..................................................375
12.4.5 實驗步驟 ....................................................................................................378
12.5
使用 Wireshark對 ZigBee網絡進行抓包分析 ......................................................382
思考題.................................................................................................................................387 參考文獻.....................................................................................................................................388