ESP32 with AWS IoT -1-

์น˜์‚ผ์ดยท2021๋…„ 11์›” 2์ผ
3

Workshop:ESP32 with AWS IoT

๋ชฉ๋ก ๋ณด๊ธฐ
1/4
post-thumbnail

๐Ÿ‘จโ€๐Ÿ’ป Connecting AWS with ESP32: Introduction

์ด๋ฒˆ ๊ธ€์€ ๐Ÿ”— Workshop:ESP32 with AWS IoT ์˜ ๋‚ด์šฉ์„ ์ง์ ‘ ์‹ค์Šตํ•œ ๋’ค ์žฌ ํฌ์ŠคํŒ… ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

1. ESP32 ๋ž€??

01

ESP32 ๋Š” espressif ์‚ฌ์—์„œ ๋งŒ๋“  SoC ๋‹ค. ESP32๋Š” Xtensaยฎ single-/dual-core 32-bit LX6 microprocessor(s) ์™€ 448 KB ROM, 520 KB SRAM๋ฅผ ๋‚ด์žฅํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ๊ทธ๋ฐ–์˜ ํŠน์ง•์œผ๋กœ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • Robust Design

  • Ultra-Low Power Consumption

  • High Level of Integration

  • Hybrid Wi-Fi & Bluetooth Chip

    ์ผ๋ฐ˜ PC๋‚˜ ํœด๋Œ€ํฐ์—์„œ ์ด์šฉํ•˜๋Š” WiFi๋ฅผ ์ƒ๊ฐํ•˜๋ฉด ์•ˆ๋œ๋‹ค.. WiFi๊ฐ€ ํ™˜๊ฒฝ๋•Œ๋ฌธ์— ์ทจ์•ฝํ•˜๋ฉด, ์™ธ์žฅ ์•ˆํ…Œ๋‚˜๋ฅผ ์ง€์›ํ•˜๋Š” ๋ชจ๋“ˆ์„ ์‚ฌ์ž.. ๐Ÿค‘๐Ÿค‘

ESP32๋ฅผ ์ด์šฉํ•œ Borad๋Š” ๊ฝค ๋‹ค์–‘ํ•œ๋ฐ ๊ฐ€์žฅ ๋Œ€ํ‘œ์ ์ธ๊ฒŒ NodeMCU ๊ณ„์—ด์ด๋‹ค. ์ด๋ฒˆ ์‹ค์Šตํ•  Board๋Š” NodeMCU๋Š” ์•„๋‹ˆ๊ณ  WEMOS์‚ฌ์—์„œ ๋งŒ๋“  LOLIN D32 ๋ผ๋Š” Borad์ด๋‹ค.

1.1 LOLIN D32

02

LOLIN D32๋Š” ESP32 SoC ๊ธฐ๋ฐ˜ ๊ฐœ๋ฐœ ๋ณด๋“œ๋กœ์จ 4MB Flash์™€ ์ตœ๋Œ€ 500mA ๋ฆฌํŠฌํด๋ฆฌ๋จธ ๋ฐฐํ„ฐ๋ฆฌ ์ถฉ์ „ํšŒ๋กœ ๋ฐ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ์•„๋ž˜ ์ŠคํŽ™์€ ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์—์„œ ๊ฐ€์ ธ์˜จ ๋‚ด์šฉ์ด๋‹ค.

  • Operating Voltage : 3.3V
  • Supported Battery : Lipo 3.7V
  • Battery Connector: PH-2 2.0mm
  • Digital I/O Pins : 22
  • Analog Input Pins : 6 (VP, VN, 32, 33, 34, 35)
  • Analog Output Pins : 2 (25, 26)
  • LED_BUILTIN : GPIO5
  • Clock Speed(Max) : 240MHz
  • Flash : 4M Bytes
  • Size : 57 ร— 25.4mm
  • Weight : 6.1g

2. ESP32์™€ Arduino IDE

ESP32๋ฅผ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ ํ†ตํ•ฉ๊ฐœ๋ฐœํ™˜๊ฒฝ(IDE) ์ค‘ ๊ฐ€์žฅ ์œ ๋ช…ํ•œ๊ฑด ์•„๋งˆ๋„ Arduino IDE๊ฐ€ ์ธ๊ฒƒ ๊ฐ™๋‹ค. ๋ญ PlatformIO ๊ฐ™์€ ๋” ๋›ฐ์–ด๋‚œ IDE๋„ ๋งŽ์ง€๋งŒ, ์˜ˆ์ œ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด ๋Œ€๋ถ€๋ถ„์ด Arduino IDE๋ฅผ ์ด์šฉํ•˜๋”๋ผ...๐Ÿค”๐Ÿค” ๊ฐœ์ธ์ ์ธ ์ƒ๊ฐ์œผ๋ก  Arduino IDE๋Š” ๊ต‰์žฅํžˆ ํ›Œ๋ฅญํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜์ง€๋งŒ ์žˆ์œผ๋ฉด ์ฐธ ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ(์˜ˆ๋ฅผ๋“ค๋ฉด ์ž๋™์™„์„ฑ ๊ฐ™์€ ๊ธฐ๋Šฅ)์€ ์—†์–ด์„œ ์•„์‰ฝ๋‹ค. ๊ทธ๋ž˜๋„ ์–ด์ง€๊ฐ„ํ•œ ์ผ๋“ค์€ ๋‹ค ํ•  ์ˆ˜ ์žˆ์œผ๋‹ˆ๊ป˜...

03

์—ฌ๋‹ด์œผ๋กœ ์˜ˆ์ „์— ๋ดค๋˜ YouTube ์˜์ƒ ์ค‘ Glitter Bomb 1.0 vs Porch Pirates ๋ผ๋Š” ์˜์ƒ์ด ์žˆ๋Š”๋ฐ ๋‚ด์šฉ์ด ์ „์ง NASA ์—”์ง€๋‹ˆ์–ด๊ฐ€ ํƒ๋ฐฐ๋„๋‘‘ ๊ณจํƒ•๋จน์ด๋Š” ๋‚ด์šฉ์ด๋‹ค. 1๋ถ„ 54์ดˆ ์ฏค ๋ณด๋ฉด ์ด ์‚ฌ๋žŒ๋„ Arduino IDE๋กœ ์ฝ”๋”ฉํ•˜๋Š” ๊ฑธ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

์•„๋ฌดํŠผ ๐Ÿ”— Arduino ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€ ์— ์ ‘์†ํ•ด Software ํƒญ์„ ๋ˆŒ๋Ÿฌ ๋“ค์–ด๊ฐ€๋ฉด ๋‹ค์šด๋กœ๋“œ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

2.1 ESP32 Arduino IDE setup

๊ธฐ๋ณธ์ ์œผ๋กœ Arduino IDE๋ฅผ ์„ค์น˜ํ•˜๋ฉด ์ง€์›๋˜๋Š” Board๋Š” Arduino์—์„œ ๋งŒ๋“  UNO, Micro, Mega ๋“ฑ Arduino ๊ณ„์—ด์ด๋‚˜ ํ˜น์€ ๊ทธ ์™ธ ๋ช‡๋ช‡ Board๊ฐ€ ๋””ํดํŠธ๋กœ ์„ค์น˜๋˜์–ด ์žˆ๋Š”๋ฐ ESP32๋Š” ๊ทธ๋ ‡์ง€ ๋ชปํ•˜๋‹ค. ๋งˆ์น˜ ์šฐ๋ฆฌ๊ฐ€ IAR Workbench, CubeMX, Segger Embedded Studio ๊ฐ™์€ IDE๋ฅผ ์ด์šฉํ• ๋•Œ SoC ๋‚˜ MCU ์ •๋ณด๊ฐ€ ์—†์œผ๋ฉด Borad ์ •๋ณด๋ฅผ ์ธํ„ฐ๋„ท์—์„œ ๋‹ค์šด ๋ฐ›๋Š” ์ž‘์—…์ฒ˜๋Ÿผ Arduino๋„ ESP32 ์ •๋ณด๋ฅผ ๋‹ค์šด๋ฐ›๋Š” ์ ˆ์ฐจ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

ํŒŒ์ผ โžœ ํ™˜๊ฒฝ์„ค์ • โžœ ์ถ”๊ฐ€์ ์ธ ๋ณด๋“œ ๋งค๋‹ˆ์ € URLs ์— ๋‹ค์Œ ์ฃผ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

04

๊ทธ ๋‹ค์Œ ํˆด โžœ ๋ณด๋“œ โžœ ๋ณด๋“œ๋งค๋‹ˆ์ €... ๋กœ ๋“ค์–ด๊ฐ€ ESP32๋ฅผ ๊ฒ€์ƒ‰ํ•œ ๋’ค ์„ค์น˜๋ฅผ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

05

2.2 CH340 Driver ์„ค์น˜

๋งŒ์•ฝ ์ง€๊ธˆ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ LOLIN D32์ด๊ฑฐ๋‚˜ ํ˜น์€ ์ •ํ’ˆ Arduino๊ฐ€ ์•„๋‹Œ Arduino ํ˜ธํ™˜ ๋ณด๋“œ๋ฅผ ์ด์šฉํ•˜๋Š” ์ค‘์ธ๋ฐ, ์žฅ์น˜ ๊ด€๋ฆฌ์ž์—์„œ ํฌํŠธ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋ฉด CH340 Driver๋ฅผ ์„ค์น˜ํ•˜๋ฉด ๋œ๋‹ค. ์ž์‹ ์˜ Board์— ์•„๋ž˜์˜ IC๊ฐ€ ์žˆ๋‹ค๋ฉด CH340 Driver๋ฅผ ์„ค์น˜ํ•ด์•ผ ํฌํŠธ๋ฅผ ์žก์„ ์ˆ˜ ์žˆ๋‹ค.

06

์œ„ ๋งํฌ๋กœ ์ ‘์†ํ•˜๋ฉด CH340 Drvier๋ฅผ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค. ๋‹ค์šด๋กœ๋“œ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด CH341SER.ZIP ๋ผ๋Š” ํŒŒ์ผ์ด ๋‹ค์šด๋กœ๋“œ ๋˜๋Š”๋ฐ ์••์ถ•์„ ํ•ด์ œ ํ•œ ๋’ค, Install ๋ฒ„ํŠผ๋งŒ ๋ˆ„๋ฅด๋ฉด ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค์น˜๋œ๋‹ค.

07

08

๋ชจ๋“  ์ž‘์—…์ด ์ž˜ ์ง„ํ–‰์ด ๋ฌ๋Š”์ง€ ํ™•์ธํ• ๊ฒธ ๊ฐ„๋‹จํ•œ LOLIN D32์— Blink LED๋ฅผ ์—…๋กœ๋“œ ํ•ด๋ณด์ž.

ํŒŒ์ผ โžœ ์˜ˆ์ œ โžœ 01.Basics โžœ Blink ๋ฅผ ์—…๋กœ๋“œ ํ•ด๋ณด์ž.

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

๋‹ค์Œ๊ณผ ๊ฐ™์ด LED๊ฐ€ ๊นœ๋ฐ•์ด๋ฉด ์ž˜ ์—…๋กœ๋“œ ๋œ ๊ฑฐ๋‹ค.

09

3. AWS IoT ๋ž€??

10

์•„๋งˆ์กด ์›น ์„œ๋น„์Šค(์˜์–ด: Amazon Web Services; AWS)๋Š” ์•„๋งˆ์กด๋‹ท์ปด์˜ ํด๋ผ์šฐ๋“œ ์ปดํ“จํŒ… ์‚ฌ์—…๋ถ€๋‹ค.

์•„๋งˆ์กด ์›น ์„œ๋น„์Šค๋Š” ๋‹ค๋ฅธ ์›น ์‚ฌ์ดํŠธ๋‚˜ ํด๋ผ์ด์–ธํŠธ์ธก ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•ด ์˜จ๋ผ์ธ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์„œ๋น„์Šค์˜ ์ƒ๋‹น์ˆ˜๋Š” ์ตœ์ข… ์‚ฌ์šฉ์ž์— ์ง์ ‘ ๊ณต๊ฐœ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ณ , ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๊ฐ€ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” ํ”Œ๋žซํผ์„ ์ œ๊ณตํ•˜๋Š” PaaS์ด๋‹ค.

์ถœ์ฒ˜: ์œ„ํ‚ค๋ฐฑ๊ณผ ์•„๋งˆ์กด ์›น ์„œ๋น„์Šค

๊ฐœ๋ฐœ์ž ํ˜น์€ IT ๊ด€๋ จ ๊ฒฝํ—˜์ด ์žˆ๋Š” ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ๋žŒ๋“ค์€ AWS๋ฅผ ๋ชจ๋ฅด์ง€ ์•Š์„ ๊ฒƒ์ด๋‹ค. AWS๋ž€ ๋ง ๊ทธ๋Œ€๋กœ ์•„๋งˆ์กด ๋‹ท์ปด์—์„œ ์„œ๋น„์Šคํ•˜๋Š” ํด๋ผ์šฐ๋“œ ์ปดํ“จํŒ… ์„œ๋น„์Šค ์ด๋ฉฐ ๋‹ค์–‘ํ•œ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

๊ทธ ์ค‘์— IoT ๊ด€๋ จ ์„œ๋น„์Šค๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด AWS IoT์ด๋ฉฐ, AWS IoT ์—์„œ๋Š” ๊ฐ ๋‹จ๋ง์—์„œ ์„ผ์‹ฑํ•˜๋Š” ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ ๋ฐ ์ €์žฅ ํ•˜์—ฌ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์„ ๋ฟ ์•„๋‹ˆ๋ผ ๋ถ„์„ ๊ฐ์ง€ ๋“ฑ ์—ฌ๋Ÿฌ ์‚ฐ์—… ๋ถ„์•ผ์— ํ•„์š”ํ•œ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜ ๊ณ  ์žˆ๋‹ค.

๐Ÿ”— AWS IoT

๋ฌผ๋ก  AWS IoT ๋ฅผ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด์„  ์ผ์ •ํ•œ ๊ธˆ์•ก์„ ์ง€๋ถˆํ•ด์•ผํ•œ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ AWS๋ฅผ ๊ฐ€์ž…ํ–ˆ๋‹ค๋Š” ์ „์ œ ํ•˜์— ์ง„ํ–‰๋œ๋‹ค.(์นด๋“œ๋“ฑ๋ก๊นŒ์ง€ ํฌํ•จ)

๐Ÿ”— Connecting AWS with ESP32 Introduction

0๊ฐœ์˜ ๋Œ“๊ธ€