Trang 1
TRƯỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY IT4735 Internet of Things and Applications Giảng viên: TS. Phạm Ngọc Hưng Viện Công nghệ Thông tin và Truyền thông hungpn@soict.hust.edu.vn
TRƯỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY IT4735 Internet of Things and Applications Giảng viên: TS. Phạm Ngọc Hưng Viện Công nghệ Thông tin và Truyền thông hungpn@soict.hust.edu.vn
Nội dung ▪ Chương 1. Tổng quan về IoT ▪ Chương 2. Hệ thống IoT và các công nghệ ▪ Chương 3. Lập trình IoT ▪ Chương 4. An toàn và Bảo mật IoT ▪ Chương 5. Xây dựng ứng dụng IoT IT4735 – IoT and Applications 2
Chương 3. Lập trình IoT ▪ 3.1. Lập trình với thiết bị IoT ▪ 3.1.1. Lập trình với thiết bị Arduino ▪ 3.1.2. Lập trình với thiết bị ESP32 ▪ 3.1.3. Lập trình với thiết bị Rasberry Pi ▪ 3.1.4. Truyền dữ liệu ESP32 – Raspberry Pi ▪ 3.2. Dịch vụ IoT trên máy chủ, nền tảng đám mây ▪ 3.3. Thiết kế một hệ thống ứng dụng IoT IT4735 – IoT and Applications 3
3.1.1. Lập trình thiết bị Arduino ▪ Lập trình với Arduino: ▪ VĐK ATMega 8 bit, không có hệ điều hành ▪ Arduino Uno: Microchip ATmega328 Digital output In circuit Serial ~: PWM. programming 0,1: Serial port. Atmel USB MicroController port Power input Power Supply Analog input. IT4735 – IoT and Applications 4
Lập trình Arduino ▪ Cài đặt Arduino IDE ▪ https://www.arduino.cc/en/guide/windows ▪ Cấu trúc code void setup() { //Used to indicate the initial values of system on starting. } void loop() { Contains the statements that will run whenever the system is powered after setup. } IT4735 – IoT and Applications 5
Lập trình Arduino ▪ Program used to code and upload it to arduino boards (using PC) ▪ Editor (for code edit) ▪ Sketch (piece of program) ▪ IT4735 – IoT and Applications 6
Lập trình Arduino ▪ Tài liệu: Arduino References ▪ http://arduino.cc/en/Reference/HomePage IT4735 – IoT and Applications 7
3.1.2. Lập trình thiết bị ESP32 ▪ Lập trình với EPS32 có HĐH FreeRTOS https://esp32.vn/index.html IT4735 – IoT and Applications 8
Lập trình thiết bị ESP32 ▪ A. Cài đặt môi trường Arduino IDE cho ESP32 ▪ B. Lập trình GPIO ví dụ LED Blinky ▪ C. Lập trình kết nối Wifi IT4735 – IoT and Applications 9
A. Cài đặt môi trường Arduino IDE cho ESP32 ▪ Cài đặt Add-on ESP32 Board trên Arduino IDE: ▪ 1) Mở cửa sổ tùy chọn từ IDE Arduino. Chuyển đến File> Preferences ▪ 2) Nhập https://dl.espressif.com/dl/package_esp32_index.json vào trường “Additional Board Manager URLs” như trong hình bên. Sau đó, nhấp vào nút “OK” IT4735 – IoT and Applications 10
Cài đặt môi trường Arduino IDE cho ESP32 3) Mở board quản lý. Chuyển đến Tools > Board > Boards Manager… IT4735 – IoT and Applications 12
Cài đặt môi trường Arduino IDE cho ESP32 3) Mở board quản lý. Chuyển đến Tools > Board > Boards Manager… IT4735 – IoT and Applications 13
Cài đặt môi trường Arduino IDE cho ESP32 ▪ Kết nối bo mạch ESP32 với máy tính. 1) Mở Arduino IDE 2) Chọn Board trong Tools > Board menu (trong trường hợp ví dụ là DOIT ESP32 DEVKIT V1 ) IT4735 – IoT and Applications 14
Cài đặt môi trường Arduino IDE cho ESP32 ▪ Mở ví dụ sau trong File > Examples > WiFi (ESP32) > WiFi Scan IT4735 – IoT and Applications 15
B. Lập trình GPIO cho ESP32 Ứng dụng LED Blinky ▪ STEP 1: Connect your ESP32 board to your computer through the micro-USB cable. Make sure the red LED goes high on the module to ensure power supply. ▪ STEP2: Start the Arduino IDE and navigate to Tools -> Boards and select ESP32Dev board as shown below IT4735 – IoT and Applications 16
Ứng dụng LED blinky ▪ STEP 3: Open device manager and check to which com port your ESP32 is connected to. Mine is connected to COM 8 as shown below. IT4735 – IoT and Applications 18
Ứng dụng LED blinky ▪ STEP 4: Go back to Arduino IDE and under Tools - > Port select the Port to which your ESP is connected to. Once selected you should see something like this on the bottom left corner of the IDE. IT4735 – IoT and Applications 19
Ứng dụng LED blinky ▪ STEP 5: Let’s upload the Blink Program, to check if we are able to program our ESP32 module. This program should blink the LED at an interval of 1 second. int LED_BUILTIN = 2; void setup() { pinMode (LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } IT4735 – IoT and Applications 20
Hiển thị 20 trang đầu. Tải tài liệu để xem đầy đủ.
Chưa có bình luận nào. Hãy là người đầu tiên!
Bình luận (0)
Chưa có bình luận nào. Hãy là người đầu tiên!