68
Internet of Things(IoT) workshop through wifi chip บท เยลไอ Mr. Pairoch Julrat roiet.io FACULTY OF INFORMATICS MAHASARAKHAM UNIVERSITY 17 February 2017 1

Internet of Things (IoT) - workshop with wifi chip

Embed Size (px)

Citation preview

Internet of Things(IoT)

workshop through wifi chip

บริษัท เรียลไอที จำกัด Mr. Pairoch Julratroiet.io

FACULTY OF INFORMATICSMAHASARAKHAM UNIVERSITY

17 February 2017

1

Agenda

roiet.io

What is IoT

Impact

Workshop

Apply

2

What is Internet of Things

Source: OpenSAP

Internet of Things (IoT) or Internet of Everything (IoE) refers to devices or objects that are connected to the Internet, like your smartwatch, lamp, or even your refrigerator. These devices are able to collect and transmit data via the Internet, contributing to our big data world.

roiet.io3

Evolution of IoT

roiet.io4

Trend

Source: OpenSAP

Source: Gartnerroiet.io5

Note: Gartner Hype Cycle

Source: thailibrary.in.th

1

2

3

45

roiet.io6

How Big is the IoT?Some analysts estimate the number of connected devices by 2020.

Gartner — 20 billion

Cisco — 50 billion

Intel — 200 billion

World Population: 7.5 Billion (2017)

roiet.io7

Economic Impact

McKinsey believes that the market for IoT could reach

$11.1 trillion by 2025roiet.io8

IP Address Needs• IPv4, handle a maximum 4.3 billion

unique IP addresses

• IPv6, expands from 32 bits (IPv4) to 128 bits

• IPv6, we will have 340,282,366,920,938,463,463,374,607,431,768,211,456 unique IP addresses.

Source: Cisco

roiet.io9

Make things connected

Wireless Wire

roiet.io10

Wireless Wire

Make things connected

roiet.io11

Make things connected

Wifi Chip

10101101

roiet.io12

Wifi chip

ESP Photon

roiet.io13

Wifi chip

ESP Photon

roiet.io14

ESP8266 wifi chip

Hardware:

1. CPU

2. Memory (RAM/ROM)

3. General Purpose I/O (GPIO)

1 2

3ESP-01

roiet.io15

ESP8266 Models

roiet.io16

ESP8266 Models

Flash = 512KB

Flash = 4MB

roiet.io17

ESP-01Pinout

roiet.io18

ESP-01GPIO

roiet.io19

ESP-01How to program/flashing that chip.

roiet.io20

ESP-01Breakout Board

roiet.io21

ESP-12Pinout

roiet.io22

ESP-12GPIO

roiet.io23

ESP-12Breakout Board

EspressoLite NodeMCU WeMos(ESP-WROOM-02)

roiet.io24

Programing Platform

AT command Arduino (C) MicroPython

roiet.io25

Work Shop!

26

Set EnvironmentDownload then Install ArduinoIDE (www.arduino.cc)

Start Arduino and open Preferences window.

• Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field.

• Open Board Manager from Tools > Board > Board Manager and then install esp8266 by ESP8266 Community

roiet.io27

Set EnvironmentInstall dependency libraries

• Open Library Manager (menu Sketch > Include Library > Manage Libraries…) then install libraries you want.

DHT sensor library by Adafruit Adafruit GFX Library by Adafruit ESP8266 Oled Driver for SSD1306 display by Daniel Eichborn HttpClient by Adrian McEwen PubSubClient by Nick O'Leary

roiet.io28

Set EnvironmentUSB-Serial communication

Most microcontrollers these days have built in UARTs (universally asynchronous receiver/transmitter) that can be used to receive and transmit data serially. UARTs transmit one bit at a time at a specified data rate (i.e. 9600bps, 115200bps, etc.). This method of serial communication is sometimes referred to as TTL serial (transistor-transistor logic). Serial communication at a TTL level will always remain between the limits of 0V and Vcc, which is often 5V or 3.3V.

The RS-232 standard a logic high ('1') is represented by a negative voltage from -3 to -25V, while a logic low ('0') transmits a positive voltage that can be anywhere from +3 to +25V. On most PCs these signals swing from -13 to +13V.

Source: sparkfun.com

TTL / UART

RS-232

Sending 0b01010101

roiet.io29

Set EnvironmentUSB-TTL chip (ie. FTDI, CH340, CP2102 )

roiet.io30

Set EnvironmentInstall driver for USB-TTL chip

Mac / Linux:

Download: http://www.realitlimited.com/training/msu/2017-02-17/IoT101/CH340_Mac.zip

roiet.io31

Set EnvironmentInstall driver for USB-TTL chip

Windows: Download: http://www.realitlimited.com/training/msu/2017-02-17/IoT101/CH34x_Windows.zip or http://www.wch.cn/download/CH341SER_EXE.html

roiet.io32

Flashing Firmware1. Download Firmware (.bin)

www.realitlimited.com/training/msu/2017-02-17/IoT101/Firmware.zip

roiet.io33

Flashing Firmware2. Download Flasher

2.1 Mac / Linux: #pull the source code from git repository $git clone https://github.com/themadinventor/esptool.git $cd esptool $sudo python setup.py install

2.2 Windows: www.realitlimited.com/training/msu/2017-02-17/IoT101/Flasher.zip or https://github.com/nodemcu/nodemcu-flasher

roiet.io34

Flashing Firmware3. Upload Firmware into Chip

3.1 Mac / Linux: esptool.py -b [baud-rate] -p [device] write_flash [address] [firmware-file-name] Example: esptool.py -p /dev/ttyUSB0 erase_flash esptool.py -b 115200 -p /dev/ttyUSB0 write_flash 0x00000 Official-v1.3.0.2_AT_Firmware.bin

roiet.io35

Flashing Firmware3. Upload Firmware into Chip

3.2 Windows:

roiet.io36

First TestOpen Arduino IDE. Select Board & Port

roiet.io37

First TestSelect Baud Rate (Upload Speed): 115200

roiet.io38

Serial Monitor

Talking with Chip

roiet.io39

AT Command

Talking with Chip

roiet.io

ATAT+GMR (version firmware)AT+CWMODE? (Check mode) 1=Client 2=Server(AP) 3=AP+ClientAT+CWMODE=1 AT+CWLAP (list the Access Point nearly) AT+CWJAP=“ชื่อ AP”,”ระบุ password”AT+CIFSR (list the obtained IP & Mac address)

40

1.1 Coding Structure

Lab1: Hello World

roiet.io41

1.1 Wiring

Lab1: Hello World

roiet.io

Breadboard

LED

Resister

42

Pin IdentificationWeMos Pin Mapping with Arduino / MicroPython

roiet.io

>Digital pins 6—11 are not shown on this diagram because they are used to connect flash memory chip on most modules. Trying to use these pins as IOs will likely cause the program to crash.

>Note that some boards and modules (ESP-12ED, NodeMCU 1.0) also break out pins 9 and 11. These may be used as IO if flash chip works in DIO mode (as opposed to QIO, which is the default one). >Pin interrupts are supported through attachInterrupt, detachInterrupt functions. Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt types are supported: CHANGE, RISING, FALLING.

43

2.1 Analog read

Lab2: Analog

roiet.io44

2.1 Wiring

Lab2: Analog

roiet.io

Breadboard

Joy StickLED

Resister

45

2.2 Analog read condition to turn on LED

Lab2: Analog

roiet.io46

2.3 Analog Write to dimming LED

Lab2: Analog

roiet.io47

3.1 Hello World same as Lab1

Lab3: Arduino

roiet.io48

3.1 Hello World same as lab01-Blink

Lab3: Hello Arduino

roiet.io49

I2C Wiring Master and Slave

Lab4: I2C

roiet.io50

Pin IdentificationArduino Nano Pin Mapping

roiet.io51

Pin IdentificationArduino UNO Pin Mapping

roiet.io52

4.1 OLED (lab04.1-OLED-I2C-Polygon)

4.2 OLED (lab04.2-OLED-My-Name)

Lab4: I2C

roiet.io53

5.1 Connect to internet as Wifi Client.

(lab05.1-Go-Internet)

Lab5: Go Internet

roiet.io54

http://www.blynk.cc/getting-started

Blynk is an Internet of Things platform with a drag-n-drop mobile application builder that allows to visualize sensor data and control electronics remotely.

Lab6: Blynk

roiet.io55

Authentication by Token.

Lab6: Blynk

roiet.io56

6.1 Wiring

Lab6: Blynk

roiet.io

Breadboard

LED

Resister

57

6.1 Wiring Enhance with Relay

Lab6: Blynk

roiet.io

Breadboard

LED

Resister Relay

58

6.1 Wiring Enhance with Relay

Lab6: Blynk

roiet.io59

Temperature & Humidity Sensor

Lab7: DHT

roiet.io

Breadboard

DTH11/22

LED

Resister

60

8.1 Send DHT data to Thingspeak

Lab8: Thingspeak

roiet.io61

• A machine-to-machine (M2M)/ IoT protocol.

• Lightweight publish/subscribe messaging.

• Small sensors and mobile devices.

• mqtt.org

roiet.io

MQTT

62

roiet.io

IFTTT

Source: IFTTT.COM

63

Real World Applications Wireless Emergency Whistle

roiet.io64

Real World Applications Smart Socks for Diabetics

roiet.io65

End

ATMs are considered some of the first IoT objects, and went online as far back as 1974.

roiet.io66

THANK YOU

[email protected]

realitlimited.com095-931-4050

roiet.io67

68