27
IoT workshop IIT Bombay October 13, 2019 Asim Tewari Chair Professor Department of Mechanical Engineering Indian Institute of Technology Bombay www.asimtewari.com

IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

IoT workshop IIT Bombay

October 13, 2019 Asim Tewari

Chair Professor

Department of Mechanical Engineering

Indian Institute of Technology Bombay

www.asimtewari.com

Page 2: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

CYBER PHYSICAL SYSTEM & DATA ANALYTICS GROUP (2019-20)

A.Shrivastava V. Kulkarni S. Tripathi A. Tewari M. Kulkarni

Group Faculty

Yogesh Nakhate

Aniket Adsule

M.Tech, D.D., B.Tech Students and researchers

Bhupendra Solanki

A. Guha

Mohanish

Verma

Aadarsh

Pratik Chandak

Rajesh

Meghana

Verma

S. Mishra

Amey Suryawanshi

Piyush Shukla Sourabh Wagale Kiran Patil

Chawda Darshan

Nikunj Shah

Swapnil Kumar

Franklin Varghese

Sumit Ruparel

Lov Kush

Vishali palav Rajkumar Prajapati

Nikhil Jose

Ankit Katariya

Abhninav Jain

Divya Pattisapu

Shefali Gokarn

Yash Sanghvi

Page 3: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

3

• Information-based Learning – Decision Trees

– Shannon’s Entropy

– Information Gain

• Similarity-based Learning – Feature Space

– Distance Metrics

• Probability-based Learning – Naïve Bayes Model

– Markovian model

• Error-based Learning – Multivariable Regression

– Linear discriminate analysis

– Multinomial Logistic Regression

– Support Vector Machines

• Expert-system based learning

• Deep Learning – Convolutional neural network

– Recurrent neural network

Machine Learning Techniques in Data analytics

Data Analytics is the discovery, interpretation, and communication of meaningful patterns in data.

Page 4: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

4

Equipment condition

monitoring

Plant Operations Monitoring

Industry

4.0

Tool wear monitoring

Adaptive control

Quality prediction/ Monitoring

Smart Factory: Machine Monitoring and Analytics for

Total Productive Maintenance (TPM)

Smart machines facilitate productioncontrol on the shop-floor

Reactive control:Opportunistic maintenanceReactive schedulingReactive quality control plans

Smart Mach[i]nes

Informative control:Performance assessment

In-advance ControlApplied just before start

Predictive ControlApplied much in advance

Reactive ControlApplied while in progress

Informative ControlApplied after completion

Predictive control:Machine PrognosticsTool life prediction

In-advance control:Selective maintenanceProduction schedulingQuality control plans

Smart Mach[i]nesAssessment

Data Processing

Data Acquisition

IIoT Devices

ML based Process-control

advisements

Monitor equipment performance

metrics

Non-intrusive

sensorization

Page 5: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

5

Smart machines facilitate productioncontrol on the shop-floor

Reactive control:Opportunistic maintenanceReactive schedulingReactive quality control plans

Smart Mach[i]nes

Informative control:Performance assessment

In-advance ControlApplied just before start

Predictive ControlApplied much in advance

Reactive ControlApplied while in progress

Informative ControlApplied after completion

Predictive control:Machine PrognosticsTool life prediction

In-advance control:Selective maintenanceProduction schedulingQuality control plans

Smart Mach[i]nesAssessment

Data Processing

Data Acquisition

STREAMING DATA

IIOT Devices

Data from Controllers

PERSISTENT DATA

System architecture

Ontology

IOT DATA SERVER

WEB SERVER

PHP, HTML, CSS,

Shiny- R

ANALYTICS WORKSTATION

Python, R, C++

SQL server

TCP/IP

UDP/IP

Event trigger module

DOMAIN

CONTROLLER

System Admin

ANALYTICS EXPERT

Designer

Programmer

WEB BROWSER

JavaScript

Canvas

MACHINE FEEDBACK

Machine Controllers

Actuators

HUMAN INPUTS

NCAIRIoT

NCAIRIoT

NCAIRIoT

IoT ServerData analytics works stationWeb server

Shop Floor OperationsShop Floor

Plant Management

Grid view

Machine On and Cutting

Machine OFF

• Machine ranking

• Weekly/Monthly Statistics

Smart Factory: IIoT network architecture

Page 6: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Non-intrusive IoT • Indigenously developed H/W • Need based customizable • Universal language protocol

Advanced analytics backend • M/C State detection • Diagnostics

Single Window Interface • Authentication level based access • Management: Plant overview & status

report • Shop Floor/Operations: Interactive

interface

Integrated with plant ERP • Shift calendar • Operator ID/ Job ID

Operations statistics – Weekly monthly quarterly statistics – M/C wise and plant wise statistics

Causes of Production Losses – Ranking of causes and % loss

Event driven SMS – Communication with maintenance

staff – Escalation of unattended open issues

SMS on Demand – Phone number based authentication – M/C Plant status report

OEE and TPM

Smart Factory: Salient features

Page 7: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Video Analytics

• Face detection, unique persons

• Classify based on gender, age, dress color, etc.

• Face recognition: Similar persons in other cameras

• Track a person across many cameras

Page 8: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Acknowledgement

This presentation is an assimilated of information gathered from various sources in open literature and web. The presenter acknowledge all such references used in the work.

Page 9: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

• Created by Espressif Systems

• Low-cost system on a chip (SoC) series

• Wi-Fi & dual-mode Bluetooth capabilities

• Dual-core Tensilica Xtensa LX6 microprocessor with a clock rate of up to 240 MHz

• Highly integrated with built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules

• Engineered for mobile devices, wearable electronics and IoT

Introduction to ESP32

Page 10: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

ESP32 Function Block Diagram

Page 11: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

ESP

ESP

ESP

Page 12: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Advantages Disadvantages

Page 13: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Source: http://arduinoinfo.mywikis.net/wiki/Esp32

www.ai-thinker.com

NodeMCU ESP-32S Pinout

Page 14: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Additional Boards Managers URLs

• https://dl.espressif.com/dl/package_esp32_index.json

• http://arduino.esp8266.com/stable/package_esp8266com_index.json

Boards Manager

• Esp32 by Espressif Systems

Page 15: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Time to get your hands dirty!

Page 16: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Things we’ll hopefully cover today

• Serial Transmission + LED Blinking

Gathering Data

• Interfacing with MPU6050 (I2C)

• Interfacing LDR with ESP32 (ADC)

• Timer based data collection (fixed frequency data collection)

Processing Data

• Using ESP’s Dual Core Functionality

• FFT on ESP32

• Preferences on ESP32 (non-volatile storage)

Transmitting Data

• WiFi • A simple HTTP Client • HTTPS transmission

• BlueTooth • Transmitting Data via BlueTooth Classic

• ESP32 WiFi server

• ESP32 SoftAP

• UDP with ESP32

• LoRa with ESP32

• Interfacing LCD Screen with ESP32

• Interfacing GSM module with ESP32

• Over The Air (OTA) update of the ESP32 firmware

• ESP32 Touch Sensor

• Interfacing ESP32 with Hall Sensor

And a lot more…

Things we’ll not cover today but you should explore

Page 17: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Serial Transmission + LED Blinking

• Connect the positive (longer) pin of the LED to the pin D5 on ESP32 and the other end to one end of the resistor

• Connect the other end of the resistor to the Ground Pin on ESP32

• Watch the LED and the Serial Monitor

Page 18: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

MPU6050

• Connections (MPU -> ESP): • Vcc –> 3.3V

• GND -> GND

• SDA -> D21

• SCL -> D22

• Program and see that the data is streaming well on the serial monitor

• Then open the serial plotter and have fun!

Page 19: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

LDR

• Connections • Vcc of ESP32 -> One end of LDR

• Other End of LDR -> One end of Resistor

• Other end of Resistor -> GND of ESP32

• Common end of LDR and resistor -> Vp pin of ESP32

• Program and see that the data is streaming well on the serial monitor

• Then open the serial plotter and have fun!

Page 20: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Timer based Data Collection

• Program the ESP32

• Reset the ESP on programming (EN button)

• Enter the value of the sampling rate in Hz

• Observe the data stream and verify that the ESP is sounding the interrupt exactly at the desired frequency

• Note: Time difference in ms = 1000/(Sampling Rate in Hz)

Page 21: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Dual Core Functionality

• In this particular sketch, the syntax is of more importance. Understand it well.

• Program and observe both the cores in simultaneous operation on the serial monitor.

Page 22: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

FFT on ESP32

• Install the Adafruit ZeroFFT library • Tools -> Manage Libraries

• Search for FFT

• Find the Adafruit Zero FFT Library and click install

• Program the ESP and reset it. Enter a character to start the sketch.

• Observe that the peak of the FFT signal are observed at 200 Hz and 800 Hz as expected

Page 23: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

Preferences

• Program the ESP32

• See that it retains the value of the count even on restarting, indicating that the count is stored in non-volatile memory

Page 24: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

HTTP Client

• Go through the code, it is mostly self-explanatory

• Change the ssid and password according to the WiFi sources available in the room

• See the response received from the server using the serial monitor

• Note that content-length header is mandatory for POST

For understanding the differences between GET and POST, you can visit: https://www.diffen.com/difference/GET-vs-POST-HTTP-Requests

Page 25: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

HTTPS Client

• This sketch will try to do the same thing as the HTTP Client sketch

• Go through the code and see the main differences: • WiFiClient -> WiFiClientSecure

• CA Certificate check

• Port change from 80 to 443

• URL change from http to https

Page 26: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

BlueTooth Classic

• Open the sketch.

• Set and unique name for your ESP32. You don’t want several ESP32_1 devices to spam your mobile BlueTooth.

• Program your ESP32.

• Go to your mobile BlueTooth settings. See that your device’s BlueTooth name is visible in the list of available devices. Pair with it.

Page 27: IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start Predictive Control Applied much in advance Reactive Control Applied while in progress

BlueTooth Classic - 2

• Download the ‘Serial Bluetooth Terminal’ App from playstore.

• Open the app

• Go to devices in the menu, find your device and pair with it

• Observe the data coming from the device

• Send some messages to your ESP32 and observe on your serial terminal