IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start...
Transcript of IoT workshop IIT Bombay October 13, 2019asimtewari.com/IOT/IoT_ESP_32.pdfApplied just before start...
IoT workshop IIT Bombay
October 13, 2019 Asim Tewari
Chair Professor
Department of Mechanical Engineering
Indian Institute of Technology Bombay
www.asimtewari.com
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
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.
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
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
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
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
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.
• 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
ESP32 Function Block Diagram
ESP
ESP
ESP
Advantages Disadvantages
Source: http://arduinoinfo.mywikis.net/wiki/Esp32
www.ai-thinker.com
NodeMCU ESP-32S Pinout
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
Time to get your hands dirty!
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
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
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!
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!
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)
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.
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
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
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
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
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.
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