developing a complete embedded iot solution using … › content › disha › workshop3...stm32...

47
Developing a Complete Embedded IoT Solution Using Mongoose OS Mubeen Jukaku and Syed Adil Emertxe, Bangalore

Upload: others

Post on 08-Jun-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Developing a Complete Embedded IoT Solution Using

Mongoose OS

Mubeen Jukakuand

Syed AdilEmertxe, Bangalore

Page 2: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

IoT Architecture

Page 3: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

IoT - Definition

Source: Gartner

“The network of physical objects that contain embedded technology to communicate and interact with their internal states

or the external environment.”

Page 4: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

IoT – Reference Architecture

Page 5: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Use Case

Page 6: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Lockers

●Somethings to ponder on

–Is my bank locker safe?

–Is it possible that lockers are accessed without our knowledge?

●Is it possible so how we come to know about it?

Page 7: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers

Page 8: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers

Device

Device

Device Device

Page 9: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers

Device

Device

Device DeviceAccessPoint

Page 10: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers

Device

Device

Device DeviceAccessPoint

Page 11: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart LockersDevice

AccessPoint

Page 12: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart LockersDevice

AccessPoint

Node

State : Open

State : Open

State : Open

State : ON

Brightness: 80%Mode : Auto

Page 13: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers - Actors

●Customers :-

–Every time the locker is opened the user gets an SMS / E-Mail

●Control Room :-

–Based on the access time the control room gets the SOS to take appropriate access

●Insurance Providers :-

–Upon subscribing to the required nodes the insurance providers get the intimation of theft or closure of the locker facility

Page 14: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

IoT Hardware / Software Selection

●Security requirements

●Ease of development

●Data acquisition, processing and storage requirements

●Connectivity requirements

●Power requirements

●Physical device design

●Cost requirements

Page 15: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

NodeMCU ESP32

Page 16: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

NodeMCU ESP32 - Architecture

GPIOs

USBInterface

LED

SWITCH

ESP32

●Espressif Systems

●32 Bit Core

●520 Kbyte SRAM●Ultra Low Pwr SOC

BLE Wi-Fi

Page 17: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

NodeMCU ESP32 - Peripherals

ESP32 Module

1

1

3

Power LED3

4

Serial-USB Converter Chip4

USB Interface

2

2

5

Reset Key5

6

Boot Key6

7

User LED7

8

GPIOs8

Page 18: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

NodeMCU ESP32 – Development Support

Arduino

Espressif IoT Development Framework

NodeMCU Lua

Mongoose OS

MicroPython, etc.,

Page 19: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Introduction to Mongoose OS

Page 20: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Introduction to Mongoose OS (MOS)

●An Open source OS for IoT

●Started as embedded web server. Expanded to an IoT OS

●Dual License, GPL or Commercial

●Development in C / C++ / JS

●Tool chain support on Windows, Linux, MacOS

Page 21: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Supported MCUs

●STMicro : STM32 F4, L4, F7

●TI : CC3200, CC3220

●Espressif : ESP32, ESP8266

Page 22: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – IoT Cloud Integration

●Amazon AWS IoT

●Microsoft Azure IoT

●Google IoT Core

●IBM Watson IoT

●Private MQTT / Rest Backends

Page 23: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Device Logic (Application Code)

Mongoose OS CoreTimers, Events, etc.,

Mongoose OS LibrariesNetwork, Cloud Support, Drivers, RPC, OTA, etc.,

Native SDKe.g, STM32 Cube, TI SDK, ESP-IDF, etc.,

STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266

Native OTA SupportRemote Management

TLS1.2, Mutual TLSHTTP, MQTT, Websoket, CoAP

Wifi, Ethernet, BLE

Firmware code can useAny functionality from

The native SDK

MOS – Architecture

AWS / Azure / Google etc.,(Cloud Backend)

Page 24: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Development Setup

Page 25: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Development Setup

●Download and Install MOS

●Understanding MOS User Interface

●Application (Blinky)

●mos.yml

●Building the firmware

●Flashing the firmware

●The output

Page 26: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Download

Page 27: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Application

mos clone https://github.com/mongoose-os-apps/demo-js app1

Page 28: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MOS – Application - Blinky

mos build

mos flash

Page 29: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS Overview

Page 30: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS

●Amazon Web Services

●Secure cloud services platform

●Offers to

–Compute power

–Database storage

–Content delivery

–and other functionality to help businesses scale and grow

Page 31: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS – Why?

Page 32: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS – Why?

Page 33: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS - Features

●A Platform for Virtually Every Use Case

●Deep Features and getting deeper by the day

●Security Recognized as Stronger than On-premises

●Deep Visibility into Compliance and Governance

Page 34: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS - Reason to Choose

●Flexible, Scalable and Reliable

●Good Pricing, and interesting free tiers!

●Good presence, with atleast 25 geographic locations

●Customization

●Security

●and many more ...

Page 35: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

AWS – Major Services

Compute Storage & Content Delivery

Database

Networking Administration & Security

Analytics Internet of AWS Overviews

Application Services Deployment & Management

Page 36: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MQTT Overview

Page 37: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MQTT – What?

●Machine-to-Machine(M2M) and IoT connectivity protocol

●Lightweight messaging protocol which works with a server-

based publish subscribe mechanism

●Runs on the top of TCP/IP protocol suite

●Lighter than HTTP 1.1 and HTTP/2 protocols

●Popular among IoT, M2M, Embedded Projects

Page 38: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MQTT – How?

Broker(Gateway)

Thing1(Station)

Thing2(Station)

Thing3(Station)

Publish

Page 39: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

MQTT – Why?

●One-to-many distribution

●Ideal for constrained networks

●Supports QoS (3 Levels)

●For lower footprint and low power devices

●Simple implementation with set of commands to CONNECT,

PUBLISH, SUBSCRIBE and DISCONNECT.

●Supports “Will” on abnormal disconnection

Page 40: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Use Case Implementation

Page 41: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

End to end IoT solution using Mongoose OSDevice

AccessPoint

Node

Router

Page 42: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Mongoose OS + AWS IoT Core: Steps

●Create an AWS Account / User

●Install AWS CLI and Setup credentials

●Setup NODEMCU device for AWS using mos

●Build an app using AWS IoT and AWS services

Page 43: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Application Architecture

Rules Engine

Invoke Rule

Trigger SNS

AWS SNS

Send Email

MQTT

IoT Device Gateway

Page 44: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

End to end IoT solution using Mongoose OS

R1R2

AD1_C0

GND

3.3V

VIN

GND

D13

D12

D14

D27

D26

D25

D33

D32

D35

D34

VN

VP

EN

D15

D2

D4

RX2

TX2

D5

D18

D19

D21

RX0

TX0

D22

3V3

GND

D23

EN BOOT

PIR

Page 45: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Smart Lockers - SummaryDevice

AccessPoint

Node

State : Open

State : Open

State : Open

State : ON

Brightness: 80%Mode : Auto

Page 46: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,
Page 47: Developing a Complete Embedded IoT Solution Using … › content › Disha › workshop3...STM32 L4, F4, F7 TI CC 3220, 3200 ESP32, ESP8266 Native OTA Support Remote Management TLS1.2,

Thank You