You are on page 1of 71

Wearable Electronics

MBCET, Trivandrum
3-4 Feb 2018
About Us
• Neo Green Labs : Research & Development

• NGLTraining :Hands-On workshops, In-house Trainings

– Circuit Simulation & Analysis


– Linux Shell Scripting
– Analog Circuit Design
– Raspberry Pi & Python
– Single Sided PCB Designing
– Internet of Things with ESP8266
– Single Sided PCB Fabrication
– Internet of Things with Raspberry Pi
– Embedded C
– Real Time OS: FreeRTOS
– Electronics Application Development using
– Texas Instruments MSP430
Arduino
– Introduction to Power Electronics
– Microchip PIC Microcontroller (16/18/24)
– Wearable Electronics
– ARM Processors (ARM7 & ARMcortex)
– Light Fidelity
– Robotics
– Wireless Technology Interfacing with
Microcontrollers
Contents
• Understanding Wearable Electronics

• Applications

• Challenges

• Development hardware Platforms

• Our focus: ESP8266 & Raspberry

• Development using ESP8266

• I/O PORT, UART & ADC

• Reading body temperature

• Communication with Smart phone

• App development using MIT App inventor


Wearable Electronics
Wearable Electronics
• Electronics that can be worn on the body,
either as an accessory or as part of material
used in clothing.
• One of the major features of wearable
technology is its ability to connect to the
Internet, enabling data to be exchanged
between a network and the device.
Applications
• Smart Watches
• Smart Shoes
• Fitness Bands
• Wearable Textiles
• Smart glasses
• Wearable Bags
ADVANTAGES
• Portability
• Comfortable
• Always on for the task it is designed
• Quick accessibility
• Fashionable
DISADVANTAGES
• Ambient noise
• Expensive
• Side-effects(headaches)
Wearables for Health Monitoring
• Body Temperature
• Heartbeat
• Blood Pressure
• ECG
• EEG
Fitness or Health bands

Wearable Device
(UC, Sensors,
Smart Phone Battery,
APP connectivity)
Our Demo Band: Body Temperature
Monitor

Wearable Body
Temperature
Smart Phone Monitor
APP
Our Microcontroller

• ESP12f
ESP8266
ESP8266

• Wifi module with 32 bit processor

• Espressif , China

• Famous – 2013

• Why ESP8266?

– Cost

– Capabilities & Features


ESP8266 Hardware
• 3.3V device, operating current ~ 215 mA, Standby <1mA, 12uA sleep.

• CPU: Tensilca Xtensa LX3: 32-bit, 80 MHz

• ESP8266 SOC: Espressif

• PCB Antenna

• RAM 32Kb, Flash 200Kb

• Wi-Fi 802.11 b/g/n 2.4 GHz radio (station or AP),

• Built in TCP/IP Stack

• Timers, deep sleep mode

• Peripherals …

– GPIO (upto 16), PWM (3), ADC (one)

– UART, I2C, SPI


ESP- Software Development

• AT Commands via Serial Port with a microcontroller

• ESP Standalone Programming


– C using Espressif SDK

– Lua: Node MCU

– ESP8266 Arduino plugin (C Based) ( Our Focus)


ESP-12F

• 16 pin Device

• 9 GPIO

• ADC

• Reset

• Enable (Ch-PD

• GPIO0 low for firmware flash

• 3.3V
How do you start?
Let’s Start!

• Interfacing with our Computer

– Hardware Circuit

• Power Supply
Power Supply

U1 VCC
J3 U2
LM7805
1 1 3 3 2
2 VI VO VIN VOUT

GND

ADJ
3 C1 C2 C3
100uF 10uF 0.1uF R1
LM317

390R
Adapter 12V
2

1
R2
C4 680R
1uF
Let’s Start!

• Interfacing with our Computer

– Hardware Circuit

• Power Supply

• Communication
Communication
Let’s Start!

• Interfacing with our Computer

– Hardware Circuit

• Power Supply

• Communication

• Driver Installation
Let’s Start!

• Interfacing with our Computer

– Hardware Circuit

• Power Supply

• Communication

• Driver Installation

– Software Installation
• Installing Arduino Software
Let’s Start!

• Interfacing with our Computer

– Hardware Circuit

• Power Supply

• Communication

• Driver Installation

– Software Installation
• Installing Arduino Software

• Installing ESP package


Arduino Sketch
void setup()
{
initiations
}
void loop()
{
logic
{
GPIO of ESP
• 9 GPIO Pins

• Applications
– Reading a Digital Sensor or switches

– Driving Devices (led, relay, motor etc )


Turn On the LED Connected to GPIO13
Functions

pinMode(<pin>,<I/O>);

Eg: pinMode(13,OUTPUT);

digitalWrite(<pin>,<H/L>);
Eg: digitalWrite(13,HIGH);
void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
}
Uploading /Flashing
• GPIO15 should be LOW

• GPIO0 should be ground

• Press reset button

• Select Com port

• And upload
Blink the LED Connected to GPIO13
Functions

delay(<milliseconds>);

Eg: delay(1000);
void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);
}
Control LED connected to GPIO13 using
and external switch connected to GPIO4
Functions

digitalRead(<pin>);

Eg: char stat=digitalRead(12);


void setup()

pinMode(13,OUTPUT);

pinMode(14,INPUT);

void loop()

char sta=digitalRead(14);

if(sta==1)

digitalWrite(13,HIGH);

else

digitalWrite(13,LOW);
}

}
void setup()

Serial.begin(9600);

pinMode(5,INPUT);

void loop()

char sta=digitalRead(5);

if(sta==1)

Serial.println(“pin 5 is high”);

else

Serial.println(“pin 5 is low”); }

}
Serial Communication (UART)
Functions

Serial.begin(<baudrate>);

Serial.println(<>);
Write a program to send hello
continuously to your computer
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println(“hello, I am esp12”);
}
Make GPIO5 as input
Send the status of GPIO5 to the computer
and view in your serial monitor
Analog to Digital Converter
Functions

analogRead(<pin>);

Eg: int sta=analogRead(A0);


Read the Analog pin A0 and print
the Digital value on the serial
monitor
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sta= analogRead(A0);
Serial.println(sta);
}
Can you convert the Digital value
to Voltage???
void setup()
{
Serial.begin(9600);
}
void loop()
{
float temp= analogRead(A0);
temp= temp*0.00098 ;
Serial.println(temp);
}
Interface Temperature Sensor
LM35

• Learn the Datasheet


• Understand the pin diagram and
connections
• Connect with ESP
• Write the code
void setup()
{
Serial.begin(9600);
}
void loop()
{
float temp= analogRead(A0);
temp= temp*0.098 ;
Serial.println(temp);
}
Doubts???
Connectivity
ESP connectivity
• WiFi
• TCP / IP Stack
Some Basics
• Access Point
• ssid, password
• Station
• IP Address
• Server
• Client
Creating an access point
• Header file: #include <ESP8266WiFi.h>
• WiFi.mode(WIFI_AP)
• WiFi.softAP(<ssid>,<pswd>)
• WiFi.softAPIP()
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAP(“MBCET”, “12345678”);
Serial.println(WiFi.softAPIP());
}
Creating a Server
• Can be either Access point or Client
• Header file: #include <ESP8266WiFi.h>
• WiFiServer <server name>(port);
• <Servername>.begin();
Make your ESP as an access point
and setup it as a server
#include <ESP8266WiFi.h>
WiFiServer wearable(80);

void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAP(“RIT”, “12345678”);
Serial.println(WiFi.softAPIP());
wearable.begin();
}
How do you find the details of
client?
• WiFiClient <client name>;
• <clientname>=<Servername>.available()
• <clientname>.remoteIP();`

Now, write the code to identify the ip address


of a client connected to your server
void loop()
{
WiFiClient client1;
while((client1=wearable.available( ))==0);
Serial.println(client1.remoteIP());
}
HTTP Requests
• GET
– Eg:www.thomassabu.in/?switch1=1
– www.thomassabu.in/?switch1=1&switch2=0
• POST
– HTTP/1.1 200 OK
HTTP Responses
• Replies / Acknowledgements to HTTP
Requests
• Request format
– HTTP/1.1 <Status code>
• Status Codes
– 200: OK
– 202: Accepted
– 403: Forbidden
– 404: Not found
Process request sending from
client
• <clientname>.connected() // client is
connected
• <clientname>.available() // data is available
• <clientname>. readStringUntil(‘ ’)
• <clientname>.flush
• <clientname>.println()
• String request = client1.readStringUntil('\r');

• if (request.indexOf(“hello") != -1)
while(client1.available() ==0 && client1.connected()==1)
{
delay(10);
}
String request = client1.readStringUntil('\r');
Serial.println(request);
if (request.indexOf(“temp”) != -1)
{
client1.println(“request received”);
}
client1.flush();
Read the temperature and send it to
your mobile
while(client1.available() ==0 && client1.connected()==1)
{
delay(10);
}
String request = client1.readStringUntil('\r');
Serial.println(request);
if (request.indexOf(“temp”) != -1)
{
// read temperature here
}
client1.flush();
App Development
• Using MIT AppInventor
Thank You

Thomas Sabu
www.ngltraining.in
thomas@neogreenlabs.com
9495242563

You might also like