0% found this document useful (0 votes)
88 views92 pages

Ets Iot

Iot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views92 pages

Ets Iot

Iot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 92

SL.N LIST OF EXPERIMENTS PAGE.

NO
O
1. LED BLINKING USING ETS IOT KIT 2
2. PUSH BUTTON BASED LED CONTROL USING ETS IOT KIT 6
3. PUSH BUTTON BASED BUZZER CONTROL USING ETS IOT KIT 10
4. OLED DISPLAY CONFIGURATION USING ETS IOT KIT 14
5. MONITORING TEMPERATURE, PRESSURE & HUMIDITY OF 18
ENVIRONMENT USING BME280 SENSOR, THINGSPEAK CLOUD &
ETS IOT KIT AND DISPLAY IT IN OLED DISPLAY
6. MONITORING ACC, GYR USING BMI160 SENSOR, THINGSPEAK 22
CLOUD & ETS IOT KIT AND DISPLAY IT IN OLED DISPLAY
7. CONTROL RELAY OF ETS IOT KIT USING TINGSPEAK COLUD 26
8. MONITORING THREE AXIS ACCELEROMETER SENSOR DATA
USING THINGSPEAK CLOUD & ETS IOT KIT
9. MONITORING LM35 TEMPERATURE SENSOR DATA USING 34
THINGSPEAK CLOUD & ETS IOT KIT
10. INTERFACING RF TRANSMITTER AND RECEIVER IN ETS IOT KIT 38
11. MONITORING LIGHT DEPENDENT RESISTOR DATA USING 42
THINGSPEAK & ETS IOT KIT
12. MONITORING DISTANCE OF AN OBJECT USING ULTRASONIC 50
SENSOR, THINGSPEAK & ETS IOT KIT
13. CONTROL ROTATION OF 180 DEGREE SERVO MOTOR USING 54
THINGSPEAK & ETS IOT KIT
14. CONTROL ROTATION OF 360 DEGREE SERVO MOTOR USING 58
THINGSPEAK & ETS IOT KIT
15. INTERFACE GPS MODULE AND PRINT LATITUDE LONGITUDE IN 62
OLED DISPLAY OF ETS IOT KIT
16. INTERFACING INERTIAL MEASUREMENT UNIT WITH ETS IOT KIT 66
AND SEND DATA TO THINGSPEAK CLOUD
17. INTERFACING HALL SENSOR WITH ETS IOT KIT AND SEND DATA 72
TO THINGSPEAK CLOUD
18. INTERFACING DIGITAL GYROSCOPE UNIT WITH ETS IOT KIT AND 76
SEND DATA TO THINGSPEAK CLOUD
19. INTERFACING LiDAR WITH ETS IOT KIT AND SEND DATA TO 80
THINGSPEAK CLOUD
20. DISPLAY ULTRASONIC SENSOR DATA BY INTERFACING LCD 84
DISPLAY WITH STM32 DEVELOPMENT BOARD USING ARDUINO
IDE
21. INTERFACING COLOR DISPLAY WITH ESP8266 DEVELOPMENT 88
BOARD USING ARDUINO IDE
22. INTERFACING MICRO SD CARD MODULE WITH ESP8266 98
DEVELOPMENT BOARD USING ARDUINO IDE

0|Page
1|Page
LED BLINKING USING ETS IOT KIT
Aim:
 This project is used to blink the RGB LEDs in the ETS IoT Trainer kit

Components Required:

 ETS IoT Trainer Kit


 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

RGB LED:

 RGB LED means red, blue and green LEDs.


 RGB LED products combine three colors to produce over 16 million hues of light
 Also, pigment colors such as brown or pink are difficult, or impossible, to achieve.
 RGB LED controllers work on a much simpler principal.
 They alter the power on each of the three channels (red, green and blue) to create a
specific color mix.
 To generate a purple color, for example, the red and blue channels would be wound
up, and the green channel turned off completely.

Fig : RGB LED Array

Procedure:

 Here we are working with the RGB LEDs that are varying with different types of the
colours in the with the combination of red, green and blue
 In this use the annexure I for how to run the python code for blink the LEDs
 In the blink below given program used to blink the LED 1 as RED, LED 2 as Green
and LED 3 as Blue

2|Page
Connection Diagram:

Fig : MCP23017 IC pin diagram

Fig : MCP23017 with Raspberry pi ( On Board)


Program
#mcp23017 library path
import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/Adafruit_MCP230xx')
from Adafruit_MCP230XX import Adafruit_MCP230XX
import time

#mcp IC configuration
mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16) # MCP23017

#mcp input/output configuration


mcp.config(0, mcp.OUTPUT)
mcp.config(1, mcp.OUTPUT)
mcp.config(2, mcp.OUTPUT)
mcp.config(3, mcp.OUTPUT)
mcp.config(4, mcp.OUTPUT)

3|Page
mcp.config(5, mcp.OUTPUT)
mcp.config(6, mcp.OUTPUT)
mcp.config(7, mcp.OUTPUT)
mcp.config(8, mcp.OUTPUT)

try:
while True:
#RGB LED blink
mcp.output(0, 1)
mcp.output(4, 1)
mcp.output(8, 1)
time.sleep(1)
mcp.output(0, 0)
mcp.output(4, 0)
mcp.output(8, 0)
time.sleep(1)

except KeyboardInterrupt:
#Ctrl+C and stop the program
mcp.output(0, 0)
mcp.output(1, 0)
mcp.output(2, 0)
mcp.output(3, 0)
mcp.output(4, 0)
mcp.output(5, 0)
mcp.output(6, 0)
mcp.output(7, 0)
mcp.output(8, 0)

Result:

4|Page
PUSH BUTTON BASED LED CONTROL USING ETS IOT KIT

Aim:
 In this project the is study about control the RGB LEDs by pressing the Pushbutton

Components Required:
 ETS IoT Trainer Kit
 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

Switch:
 Push-Buttons are normally-open tactile switches.
 Push buttons allow us to power the circuit or make any particular connection only
when we press the button.
 Simply, it makes the circuit connected when pressed and breaks when released.
 A push button is also used for triggering of the SCR by gate terminal

Fig : Push Button

 ETS IoT KIT has 2 PUSH BUTTON which has been connected to raspberry pi
through MCP23017.

5|Page
Fig : Push button Board connection

Program:

Procedure:
 Here we used the push button to ON and OFF the LEDs in the ETS IoT Kit
 In the below program if we press the Switch 1 all the three RGB LEDs as glow in that
LED 1 as RED , LED 2 as GREEN and LED 3 as BLUE
 All the LEDs and switch are connected in the I2C manner with help of the MCP23017
IC
 Refer the Annexure I how to run the python code in the ETS IoT Kit

Connection Diagram:

Fig : MCP23017 connection with Raspberry Pi


Program
import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/Adafruit_MCP230xx')

from Adafruit_MCP230XX import Adafruit_MCP230XX


import time

6|Page
mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16) # MCP23017

# Set pin 3 to input with the pullup resistor enabled


mcp.config(9, mcp.INPUT)
mcp.pullup(9, 1)
mcp.config(10, mcp.INPUT)
mcp.pullup(10, 1)
mcp.config(0, mcp.OUTPUT)
mcp.config(1, mcp.OUTPUT)
mcp.config(2, mcp.OUTPUT)
mcp.config(3, mcp.OUTPUT)
mcp.config(4, mcp.OUTPUT)
mcp.config(5, mcp.OUTPUT)
mcp.config(6, mcp.OUTPUT)
mcp.config(7, mcp.OUTPUT)
mcp.config(8, mcp.OUTPUT)

while (True):
print "Pin 9 = %d" % (mcp.input(9))
print "Pin 10 = %d" % (mcp.input(10))
pin9=mcp.input(9)
pin10=mcp.input(10)
#time.sleep(2)
if (pin9==0):
mcp.output(0,1)
elif (pin10==0):
mcp.output(4,1)
else:
mcp.output(0,0)
mcp.output(4,0)

Result:

7|Page
PUSH BUTTON BASED BUZZER CONTROL USING ETS IOT
KIT

Aim:
 This project is study about the control the Buzzer on and off using the push button

Components Required:
 ETS IoT Trainer Kit
 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

Buzzer:
 A buzzer or beeper is an audio signaling device, which may be mechanical,
electromechanical, or piezoelectric (piezo for short).
 Buzzer is a kind of voice device that converts audio model into sound signal. It is
mainly used to prompt or alarm
 It is widely used in household appliances, alarm system, automatic production line,
low-voltage electrical equipment, electronic toys, game machines and other products
and industries

Fig : Buzzer on Board


Procedure:
 Here we used the push button to ON and OFF the Buzzer in the ETS IoT Kit
 In the below program if we press the Switch 2 Buzzer will Starts beeping and if we
release it will stops beeping
 All the Buzzer and switch are connected in the I2C manner with help of the
MCP23017 IC
 Refer the Annexure I how to run the python code in the ETS IoT Kit

8|Page
Connection Diagram:

Fig : MCP23017 connection with Raspberry Pi


Program:

import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/Adafruit_MCP230xx')

from Adafruit_MCP230XX import Adafruit_MCP230XX


import time

mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16) # MCP23017

# Set pin 3 to input with the pullup resistor enabled


mcp.config(10, mcp.INPUT)
mcp.pullup(10, 1)
mcp.config(11, mcp.OUTPUT)

while (True):
print "Pin 10 = %d" % (mcp.input(10))
pin10=mcp.input(10)
#time.sleep(2)
if (pin10==0):
mcp.output(11,1)
else:
mcp.output(11,0)
Result:

OLED DISPLAY CONFIGURATION USING ETS IOT KIT


9|Page
Aim:
 This project is study about the OLED Display and its functionality

Components Required:
 ETS IoT Trainer Kit
 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

OLED Display:
 The acronym 'OLED' stands for Organic Light-Emitting Diode - a technology that
uses LEDs in which the light is produced by organic molecules.
 These organic LEDs are used to create what are considered to be the world's best
display panels.
 Besides the noted advantages of OLED display, some of the disadvantages include:
Shorter lifetime then some other display technologies.
 This shorter lifetime is mainly due to the blue organic material but lifetime gets better
all the time but is also due to moisture migration
 Poor sunlight readability

Fig : OLED Display


Connection Diagram:

Fig : OLED connection with Raspberry Pi

10 | P a g e
Program:
import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/BME280')
import BME280 as BME
import time

import Adafruit_SSD1306

from PIL import Image


from PIL import ImageDraw
from PIL import ImageFont

# Raspberry Pi pin configuration:


RST = 24

# Note you can change the I2C address by passing an i2c_address parameter like:
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)

# Initialize library.
disp.begin()
ImageDraw
# Clear display.
disp.clear()
disp.display()

#Create blank image for drawing.


#Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new('1', (width, height))

# Get drawing object to draw on image.


draw = ImageDraw.Draw(image)

# Draw a black filled box to clear the image.


draw.rectangle((0,0,width,height), outline=0, fill=0)

# Draw some shapes.


### First define some constants to allow easy resizing of shapes.
padding = 2

11 | P a g e
top = padding

# Move left to right keeping track of the current x position for drawing shapes.
x = padding

# Load default font.


font = ImageFont.load_default()

#Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as the
python script!
#Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8)

temperature,pressure,humidity = BME.readBME280All()
#Write two lines of text.
draw.text((x, top), "Temperature: "+str(temperature), font=font, fill=1)
draw.text((x, top+20), "Pressure: "+str(pressure), font=font, fill=1)
draw.text((x, top+40), "Humidity: "+str(humidity), font=font, fill=1)
#Display image.
disp.image(image)
disp.display()
time.sleep(5)

Procedure:
 The experiment is used to work with the OLED Display in the ETS IoT Kit
 The OLED display is connected in the I2C manner to the Raspberry pi
 The OLED displays the temperature, humidity and pressure of the room with the help
of the BME 280 sensor is connected in the ETS IoT Kit
 We will study about the BME 280 about the following experiment
 Refer the Annexure I for how to run the below python program in the ETS IoT kit

Result:

MONITORING TEMPERATURE, PRESSURE & HUMIDITY OF


ENVIRONMENT USING BME280 SENSOR, THINGSPEAK CLOUD
& ETS IOT KIT AND DISPLAY IT IN OLED DISPLAY

12 | P a g e
Aim:
 This project is used to monitor the temperature, humidity and pressure in OLE display
screen as well as ThingSpeak cloud platform

Components Required:

 ETS IoT Trainer Kit


 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

BME 280:

 The BME280 is a humidity sensor especially developed for mobile applications and
wearables where size and low power consumption are key design parameters.
 The unit combines high linearity and high accuracy sensors and is perfectly feasible
for low current consumption, long-term stability and high EMC robustness.
 This precision sensor can measure relative humidity from 0 to 100% with ±3%
accuracy, barometric pressure from 300Pa to 1100 hPa with ±1 hPa absolute
accuracy, and temperature from -40°C to 85°C with ±1.0°C accuracy.
 The BME280 sensor module reads barometric pressure, temperature, and humidity.
Because pressure changes with altitude, you can also estimate altitude.
 The BME280 sensor uses I2C or SPI communication protocol to exchange data with a
microcontroller.

Fig : BME280 Sensor on board

Connection Diagram:

13 | P a g e
Fig : BME280 sensor connection with Raspberry Pi
Program

BME280 Data Uploading to Thingspeak


import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/BME280')
import BME280 as BME
import time
import urllib
while True:
(chip_id, chip_version) = BME.readBME280ID()
print "Chip ID :", chip_id
print "Version :", chip_version
temperature,pressure,humidity = BME.readBME280All()
print "Temperature : ", temperature, "C"
print "Pressure : ", pressure, "hPa"
print "Humidity : ", humidity, "%"
urllib.urlopen("https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1="+str(temperature))
time.sleep(2)

BME280 data on OLED

import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/BME280')
import BME280 as BME
import time

import Adafruit_SSD1306

from PIL import Image


from PIL import ImageDraw
from PIL import ImageFont

14 | P a g e
# Raspberry Pi pin configuration:
RST = 24

# Note you can change the I2C address by passing an i2c_address parameter like:
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)

# Initialize library.
disp.begin()
ImageDraw
# Clear display.
disp.clear()
disp.display()

#Create blank image for drawing.


#Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new('1', (width, height))

# Get drawing object to draw on image.


draw = ImageDraw.Draw(image)

# Draw a black filled box to clear the image.


draw.rectangle((0,0,width,height), outline=0, fill=0)

# Draw some shapes.


### First define some constants to allow easy resizing of shapes.
padding = 2
top = padding

# Move left to right keeping track of the current x position for drawing shapes.
x = padding

# Load default font.


font = ImageFont.load_default()

#Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as the
python script!

15 | P a g e
#Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8)

temperature,pressure,humidity = BME.readBME280All()
#Write two lines of text.
draw.text((x, top), "Temperature: "+str(temperature), font=font, fill=1)
draw.text((x, top+20), "Pressure: "+str(pressure), font=font, fill=1)
draw.text((x, top+40), "Humidity: "+str(humidity), font=font, fill=1)
#Display image.
disp.image(image)
disp.display()
time.sleep(5)

Procedure:
 Here we are working with the BME280 that will give the Temperature, Humidity and
Pressure of the atmosphere
 And also monitor the temperature, humidity and pressure in the atmosphere in the
OLED display present in the ETS IoT Kit and also analyse the variation occur in the
atmosphere with the ThingSpeak Cloud platform
 The above connection diagram how the BME 280 sensor is connected with the
Raspberry pi present in the ETS IoT Kit
 Refer the Annexure I for how to run the python program in the ETS IoT Kit

Result:

MONITORING ACC, GYR USING BMI160 SENSOR,


THINGSPEAK CLOUD & ETS IOT KIT AND DISPLAY IT IN
OLED DISPLAY
16 | P a g e
Aim:
 This Project is used to determine the Acceleration and gyroscope direction by
displaying in the OLE display and as well as upload in the thing speak cloud platform
also
Components Required:
 ETS IoT Trainer Kit
 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

BMI 160:
 BMI160 is small, low-power, low noise IMU (Inertial measurement unit) which used
for measurement of acceleration and angular rate.
 It can be interfaced using I2C and SPI.
 The accelerometer and gyroscope of BMI160 both have 16-bit digital resolution.
 It has user selectable acceleration measurement range of ±2g/±4g/±8g/±16g.
 It also has user selectable angular rate measurement range of
±125/±250/±500/±1000/±2000 dps (Degrees per second).
 It has a built-in temperature sensor which can use for a temperature range of -40 0C
and +85 0C.
 It operates on supply voltage range of 1.71 V to 3.6 V.
 Its targeted device such as mobile phone and tablets, wearable devices, toys.
 It is used in the application such as augmented reality and immersive gaming, indoor
navigation, step-counting, 6-axis and 9 axis sensor fusion, OSI (Optical image
stabilization) etc.

Fig : BMI160 sensor on board

Connection Diagram:

17 | P a g e
Fig : BMI160 connection with Raspberry Pi
Program
import sys
sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/BMI160')
import BMI160 as BMI
import time

while True:
# read sensor value
Ax,Ay,Az = BMI.ReadSensor()
print "ACC X",Ax
print "ACC Y",Ay
print "ACC Z",Az
print"\n"
Gx,Gy,Gz = BMI.Read1Sensor()
print "GCC X",Gx
print "GCC Y",Gy
print "GCC Z",Gz
print"\n"
time.sleep(1)

Procedure:
 The experiment is used to study about the Acceleration and Gyroscopic value with the
help of the BMI 160
 Here we monitor the Acceleration and Gyroscopic of the particular place and also
monitor and view the values in the OLED display present in the ETS IoT Kit and also
analyse the acceleration and gyroscopic changes in the ThingSpeak Cloud
 Refer Annexure I for how to run the below code in the ETS IoT Kit

Result:

18 | P a g e
CONTROL RELAY OF ETS IOT KIT USING TINGSPEAK
COLUD
Aim:
 In this project used to control the relay using ThingSpeak cloud Platform

Components Required:
 ETS IoT Trainer Kit
 Power adaptor
 Monitor
 HDMI to VGI converter
 Mouse and Keyboard

Relay:
 Relay is also a switch that connects or disconnects two circuits.
 But instead of manual operation a relay is applied with electrical signal, which in turn
connects or disconnects another circuit.
 Relays can be of different types like electromechanical, solid state. Electromechanical
relays are frequently used
 It consists of a set of input terminals for a single or multiple control signals, and a set
of operating contact terminals.
 The switch may have any number of contacts in multiple contact forms, such as make
contacts, break contacts, or combinations
 They are also used as automatic change over. Microprocessors use relays to control a
heavy electrical load.
 Overload relays are used for protection of motor from overload & electrical failure

Fig : Relay on board

19 | P a g e
Connection Diagram:

Fig : Relay connection with Raspberry pi


Program:

import RPi.GPIO as GPIO


import time
import time
import urllib
CHANNEL_ID=”14456”
READ_API_KEY=”AC123F123456”

#RPi input/output configuration


GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(36, GPIO.OUT)

20 | P a g e
while True:
conn = urllib.urlopen("http://api.thingspeak.com/channels/%s/feeds/last.json?
api_key=%s" \% (CHANNEL_ID,READ_API_KEY))
response = conn.read()

if( response == ‘1’):


#Relay1 ON
GPIO.output(36, 1)
print "Relay ON"
time.sleep(2)

else if( response == ‘0’):


#Relay1 OFF
GPIO.output(36, 0)
print "Relay OFF"
time.sleep(2)

Procedure:
 Here we used to control the relays present in the ETS IoT Kit by the ThingSpeak
Cloud
 In the ETS IoT Kit has the Three 12V Relays they are internally connected with the
Raspberry Pi present in the ETS IoT Kit
 The relays controlled by the ThingSpeak Cloud sending the commands from cloud to
ON and OFF the Relay
 If data send form the cloud is ‘1’the Relay one will be ON or if the data is ‘0’the relay
will be OFF
 Refer the Annexure I for how to run the below program in the ETS IoT Kit

Result:

21 | P a g e
MONITORING THREE AXIS ACCELEROMETER SENSOR
DATA USING THINGSPEAK CLOUD & ETS IOT KIT
Aim:

 This Project is used to determine the 3-axis accelerometer values, X,Y and Z axis to
detect the motion and acceleration sensor

Components Required:

 ETS IoT Trainer Kit


 ADXL345 sensor
 Power Adaptor

ADXL345 SENSOR:

 The ADXL345 digital 3-axis accelerometer module is used for motion and
acceleration sensing applications.
 This module contains an on-board ADXL345 accelerometer with digital data output
formatted as 16-bit two’s complement and accessible through either an I2C or SPI
interface.
 It measures static acceleration due to gravity as well as dynamic acceleration resulting
from motion or shock
 It also supports flexible interrupt modes that can be mapped to either of its two
interrupt pins.
 It has free-fall detection and tap detection functions, etc. It also detect the lack of
motion by comparing acceleration values to user-defined thresholds.
 The ADXL345 features 4 sensitivity ranges from +/- 2G to +/- 16G. And it
supports output data rates ranging from 10Hz to 3200Hz.

Program:

22 | P a g e
import smbus
import time
import urllib

# Get I2C bus


bus = smbus.SMBus(1)

# ADXL345 address, 0x53(83)


# Select bandwidth rate register, 0x2C(44)
# 0x0A(10) Normal mode, Output data rate = 100 Hz
bus.write_byte_data(0x53, 0x2C, 0x0A)
# ADXL345 address, 0x53(83)
# Select power control register, 0x2D(45)
# 0x08(08) Auto Sleep disable
bus.write_byte_data(0x53, 0x2D, 0x08)
# ADXL345 address, 0x53(83)
# Select data format register, 0x31(49)
# 0x08(08) Self test disabled, 4-wire interface
# Full resolution, Range = +/-2g
bus.write_byte_data(0x53, 0x31, 0x08)

time.sleep(0.5)

# ADXL345 address, 0x53(83)


# Read data back from 0x32(50), 2 bytes
# X-Axis LSB, X-Axis MSB
while True:

data0 = bus.read_byte_data(0x53, 0x32)


data1 = bus.read_byte_data(0x53, 0x33)

# Convert the data to 10-bits


xAccl = ((data1 & 0x03) * 256) + data0
if xAccl > 511 :
xAccl -= 1024

# ADXL345 address, 0x53(83)


# Read data back from 0x34(52), 2 bytes
# Y-Axis LSB, Y-Axis MSB
data0 = bus.read_byte_data(0x53, 0x34)
data1 = bus.read_byte_data(0x53, 0x35)

# Convert the data to 10-bits


yAccl = ((data1 & 0x03) * 256) + data0

23 | P a g e
if yAccl > 511 :
yAccl -= 1024

# ADXL345 address, 0x53(83)


# Read data back from 0x36(54), 2 bytes
# Z-Axis LSB, Z-Axis MSB
data0 = bus.read_byte_data(0x53, 0x36)
data1 = bus.read_byte_data(0x53, 0x37)

# Convert the data to 10-bits


zAccl = ((data1 & 0x03) * 256) + data0
if zAccl > 511 :
zAccl -= 1024

# Output data to screen


print "Acceleration in X-Axis : %d" %xAccl
print "Acceleration in Y-Axis : %d" %yAccl
print "Acceleration in Z-Axis : %d" %zAccl
time.sleep(5)
urllib.urlopen("https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1=+str(xAccl,yAccl,zAccl)")

Connection Diagram:

Fig : Circuit Diagram

24 | P a g e
Fig : Connection Diagram

Pin mapping:

ETS-IoT Kit SENSOR


3.3V VCC
SDA SDA
SCL SCL
GND GND
Procedure:

 In this project we use thee external Three Axis sensor to determine and monitor the
acceleration and gyroscopic value in the ThingSpeak cloud

 The external ADXL 345 sensor is connected with the ETS IoT kit to determine the
acceleration and gyroscopic value and monitor them inthe ThingSpeak cloud

 Connect the ADXL 345 sensor with the ETS IoT kit as per in the above connection
diagram and pin mapping

 Refer Annexure I for how to run the below program in the ETS IoT Kit.

 Refer Annexure III for how to install libraries.

Result:

25 | P a g e
MONITORING LM35 TEMPERATURE SENSOR DATA
USING THINGSPEAK CLOUD & ETS IOT KIT
Aim:

 This Project is used to determine the Room temperature using the LM35 Temperature
sensor

Component Required:

 ETS IoT Trainer Kit


 LM35 Temperature sensor
 Power Adaptor

LM35 Sensor:

 LM35 is a precision IC temperature sensor with its output proportional to the


temperature (in ℃ ).
 The sensor circuitry is sealed and therefore it is not subjected to oxidation and other
processes.
 With LM35, temperature can be measured more accurately than with a thermistor.
 It also possess low self heating and does not cause more than 0.1 oC temperature rise
in still air.
 The LM35 device is rated to operate over a −55°C to 150°C temperature range

Fig : LM35 Temperature Sensor

26 | P a g e
Program:

import RPi.GPIO as GPIO


import spidev
import time
import urllib

spi = spidev.SpiDev()
spi.open(0,0)

def ReadChannel(channel):
adc = spi.xfer2([1,(8+channel)<<4,0])
data= ((adc[1]&3) << 8) + adc[2]
return data

def ConvertVolts(data,places):
volts = (data * 3.3) / float(1023)
volts = round(volts,places)
return volts

def ConvertTemp(data,places):
temp = ((data * 330)/float(1023))-5
temp = round(temp,places)
return temp

temp_channel = 0
delay = 3

while True:
temp_level = ReadChannel(temp_channel)
temp_volts = ConvertVolts(temp_level,2)
temp = ConvertTemp(temp_level,2)
print ("Temp : {} ({}V) {} deg C".format(temp_level,temp_volts,temp))
time.sleep(delay)

urllib.urlopen("https://api.thingspeak.com/update?api_key=JECTKF4RJR44LGVY&field1="
+str(temp))
time.sleep(5)

27 | P a g e
Connection Diagram:

Pin mapping:

ETS-IoT Kit SENSOR

5V VCC
A0 A0
GND GND

Procedure:

 In this experiment we used to determine the atmospheric temperature with the help of
the LM 35 sensor and ETS IoT Kit

 The LM 35 sensor has the three pin they are connected with the ETS IoT Kit asper the
above circuit diagram and pin mapping

 And the sensor is connected to the Ets iot kit the sensor sense the temperature of the
atmosphere and gives the analog value to the ETS IoT kit

 The received analog value is converted to the celsius and send the value to the
ThingSpeak Cloud

 Refer Annexure I for how to sun the below program in the ETS IoT Kit

Result:

28 | P a g e
INTERFACING RF TRANSMITTER AND RECEIVER IN ETS
IOT KIT
Aim:

 This project determines how the RF Transmitter and Receiver works with their
required frequency

Components Required:

 ETS IoT Trainer Kit


 RF Transmitter Receiver Module
 Power Adaptor
 HDMI to VGA Converter
 Monitor

RF Transmitter Receiver Module:

 RF module is a small electronic device used to transmit and receive radio signals
between two devices
 It operates at 315Mhz.
 They can easily fit into a breadboard and work well with microcontrollers to create a
very simple wireless Receiving frequency (MHz)ss data link.
 These are only transmitters, they will only work communicating data one-way, you
would need two pairs (of different frequencies) to act as a transmitter/receiver pair.
 This Radio Transmitter & Receiver pair is perfectly matched to allow you to control
items from a distance up to 500 feet wirelessly
 Both the transmitter and receiver are in tune to the same Radio Frequency so that
when the transmitter emits a signal, the receiver will hear it wirelessly

RF Transmitter Module Working and Procedure:


 The transmitter combines the information signal to be carried with the radio frequency
signal which generates the radio waves, which is called the carrier signal
 The radio signal from the transmitter is applied to the antenna, which radiates the
energy as radio waves.

29 | P a g e
Program:
import time
import sys
import RPi.GPIO as GPIO

a_on = '1111111111111010101011101'
a_off = '1111111111111010101010111'
b_on = '1111111111101110101011101'
b_off = '1111111111101110101010111'
c_on = '1111111111101011101011101'
c_off = '1111111111101011101010111'
d_on = '1111111111101010111011101'
d_off = '1111111111101010111010111'

short_delay = 0.00045
long_delay = 0.00090
extended_delay = 0.0096

NUM_ATTEMPTS = 10
TRANSMIT_PIN = 18

def transmit_code(code):
##Transmit a chosen code string using the GPIO transmitter
GPIO.setmode(GPIO.BOARD)
GPIO.setup(TRANSMIT_PIN, GPIO.OUT)

for t in range(NUM_ATTEMPTS):

for i in code:

if i == '1':
GPIO.output(TRANSMIT_PIN, 1)
time.sleep(short_delay)
GPIO.output(TRANSMIT_PIN, 0)
time.sleep(long_delay)
elif i == '0':
GPIO.output(TRANSMIT_PIN, 1)
time.sleep(long_delay)
GPIO.output(TRANSMIT_PIN, 0)
time.sleep(short_delay)

30 | P a g e
Fig : RF Transmitter

Connection Diagram:

Fig : RF Transmitter Circuit


Pin Mapping:
ETS-IoT Kit RF Transmitter
Module
3.3V VCC
RPI 18 DATA
GND GND
Procedure:
 The RF transmitter transmits the data to receive side with frequency 455Mhz
 The RF transmitter transmitting the data by encoding original data to the receiver side
 Here we send the binary values to the receiver send as the encoded data
 Give the connection to the RF transmitter with ETS IoT Kit as per the above
connection diagram and pin mapping
 Refer Annexure I for how to run the below code in the ETS IoT Ki

31 | P a g e
RF Receiver Module Working and Procedure:
 The simplest type of radio receiver, called a tuned radio frequency (TRF) receiver,
 Mixture of radio signals from the antenna is filtered to extract the signal of the
desired transmitter
 Oscillating voltage is sent through a radio frequency (RF)
 The received signal is demodulated with the required demodulation technique like
AM demodulation, FM demodulation, PM demodulation

Fig : RF receiver Module

Connection Diagram:

Fig : RF Receiver circuit

32 | P a g e
Program:

from datetime import datetime


import RPi.GPIO as GPIO

RECEIVED_SIGNAL = [[], []] #[[time of reading], [signal reading]]


MAX_DURATION = 5
RECEIVE_PIN = 23

if __name__ == '__main__':
GPIO.setmode(GPIO.BCM)
GPIO.setup(RECEIVE_PIN, GPIO.IN)
cumulative_time = 0
beginning_time = datetime.now()
print '**Started recording**'
while cumulative_time < MAX_DURATION:
time_delta = datetime.now() - beginning_time
RECEIVED_SIGNAL[0].append(time_delta)
RECEIVED_SIGNAL[1].append(GPIO.input(RECEIVE_PIN))
cumulative_time = time_delta.seconds
print '**Ended recording**'
print len(RECEIVED_SIGNAL[0]), 'samples recorded'
GPIO.cleanup()

print '**Processing results**'


for i in range(len(RECEIVED_SIGNAL[0])):
RECEIVED_SIGNAL[0][i] = RECEIVED_SIGNAL[0][i].seconds +
RECEIVED_SIGNAL[0][i].microseconds/1000000.0
print RECEIVED_SIGNAL[0][i]

Pin Mapping:

ETS-IoT Kit RF Receiver Module

3.3V VCC
RPI 11 DATA
GND GND

Procedure:
 In the receiver side the received encoded data collected from the transmitter is
decoded
 The decoded data is displayed in the python shell
 The connection is given as per the above connection diagram and pin mapping
 Refer Annexure I for how to run the below program in ETS IoT Kit

33 | P a g e
Result:

34 | P a g e
MONITORING LIGHT DEPENDENT RESISTOR DATA
USING THINGSPEAK & ETS IOT KIT
Aim:

 This Project is used to determine the varying the resistance with the help of light by
using the Light Dependent Resistor

Components Required:

 ETS IoT Trainer Kit


 Light Dependent Resistor Module
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Light Dependent Resistor (LDR):

 An LDR or light dependent resistor is also known as photo resistor, photocell,


photoconductor.
 It is a one type of resistor whose resistance varies depending on the amount of light
falling on its surface.
 When the light falls on the resistor, then the resistance changes.
 The sensitivity of light dependent resistors or photoresistors also varies with the
wavelength of the incident light.
 LDRs are made from semiconductor materials to enable them to have their light
sensitive properties
 When the light level decreases, the resistance of the LDR increases.
 As this resistance increases in relation to the other Resistor, which has a fixed
resistance, it causes the voltage dropped across the LDR to also increase

Fig: LDR

35 | P a g e
Connection Diagram:

Fig: Circuit Diagram

Fig : Connection Diagram

Pin Mapping:

ETS-IoT Kit SENSOR


5V/3.3V VCC
A0 AO

36 | P a g e
GND GND
Program:

import time
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
import urllib
CLK = 23
MISO = 21
MOSI = 19
CS = 24
mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
SPI_PORT = 0
SPI_DEVICE = 0
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
# Main program loop.
while True:
i=mcp.read_adc(0)
print "LDR Value:", i
urllib.urlopen("https://api.thingspeak.com/update?api_key=8NGROYPVG3A1X3JE
&field1="+str(i))
time.sleep(5)

Procedure:

 In this we determine the Light dependence of the atmosphere with the help of the
LDR module and ETS IoT Kit

 Here we measure the strength of the light with and various the resistance of the
module

 We read the analog value from the LDR module and publish the data to the
ThingSpeak cloud to analyse the value light dependence in the room

 Give the connection as per the above connection diagram and pin mapping

 Refer Annexure I how to run the below program in the ETS IoT Kit

Result:

37 | P a g e
MONITORING DISTANCE OF AN OBJECT USING
ULTRASONIC SENSOR, THINGSPEAK & ETS IOT KIT
Aim:

 This Project is used to measure the distance and also detection using ultrasonic sensor

Components Required:

 ETS IoT Trainer Kit


 Ultrasonic sensor
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Ultrasonic sensor:

 An ultrasonic sensor is an electronic device that measures the distance of a target


object by emitting ultrasonic sound waves, and converts the reflected sound into an
electrical signal.
 They typically operate by generating a high-frequency pulse of sound, and then
receiving and evaluating the properties of the echo pulse.
 Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that
humans can hear).
 The most widely used range is 40 to 70 kHz. The frequency determines range and
resolution; the lower frequencies produce the greatest sensing range.
 This economical sensor provides 2cm to 400cm of non-contact measurement
functionality
 The sensor module includes an ultrasonic transmitter, a receiver and a control circuit.

Fig:Ultrasonic Sensor

38 | P a g e
Connection Diagram:

Fig : Circuit Diagram

Pin mapping:

ETS-IoT Kit SENSOR


5V VCC
RPi16 TRIG
RPi18 ECHO
GND GND
Program:

import time
import RPi.GPIO as GPIO
import urllib

# Use BCM GPIO references


GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

# Define GPIO to use on Pi


GPIO_TRIGGER = 16 ##connect with RPI16
GPIO_ECHO = 18 ##connect with RPI18

print "Ultrasonic Measurement"

# Set pins as output and input

39 | P a g e
GPIO.setup(GPIO_TRIGGER,GPIO.OUT) # Trigger
GPIO.setup(GPIO_ECHO,GPIO.IN) # Echo

# Set trigger to False (Low)


GPIO.output(GPIO_TRIGGER, False)

# Allow module to settle


time.sleep(0.5)

while True:
# Send 10us pulse to trigger
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)

while GPIO.input(GPIO_ECHO)==0:
start = time.time()

while GPIO.input(GPIO_ECHO)==1:
stop = time.time()

# Calculate pulse length


elapsed = stop-start

# Distance pulse travelled in that time is time


# multiplied by the speed of sound (cm/s)
distance = elapsed * 34300

# That was the distance there and back so halve the value
distance = distance / 2

print "Distance : %.1f cm" % distance


time.sleep(1)
urllib.urlopen("https://api.thingspeak.com/update?api_key=8NGROYPVG3A1X3JE
&field1="+str(distance))

Procedure:

 Here the ultrasonic sensor is used to measure the distance of the objects with help of
the ETS IoT kit

 We send the distance read from the sensor is send to the ThingSpeak cloud

 In the Ultrasonic sensor the Trig pin produces the ultrasonic wave and the waves are
reflected back to the sensor the Echo pin receives the reflected waves

 The time difference between the transmission and the received ultrasonic waves

40 | P a g e
 The calculated distance is send to the ThingSpeak cloud

 Give the connection as per the above connection diagram and pin mapping

 Refer Annexure I how to run the below program in the ETS IoT Kit

Result:

41 | P a g e
CONTROL ROTATION OF 180 DEGREE SERVO MOTOR
USING THINGSPEAK & ETS IOT KIT
Aim:

 In this project rotation speed and angle of rotation of the servo motor can be
controlled

Components Required:

 ETS IoT Trainer Kit


 Servo Motor (SG90)
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Servo Motor:

 Servo motor are controlled by sending an electrical pulse of variable width, or pulse
width modulation (PWM), through the control wire
 The desired position is sent via electrical pulses through the signal wire.
 The motor's speed is proportional to the difference between its actual position and
desired position.
 If the motor is near the desired position, it will turn slowly, otherwise it will turn fast
 The servo motor is most commonly used for high technology devices in the industrial
application like automation technology.
 It is a self-contained electrical device that rotate parts of a machine with high
efficiency and great precision.
 The output shaft of this motor can be moved to a particular angle.
 Servo motors are mainly used in home electronics, toys, cars, airplanes, etc

Fig : Servo motor

42 | P a g e
Connection Diagram:

Fig : Circuit diagram

Pin Mapping:

ETS-IoT Kit SENSOR


5V VCC
RPi22 INPUT
GND GND

Program:

import RPi.GPIO as GPIO


import time
import urllib
CHANNEL_ID ='15917'
READ_API_KEY ='ND9QG4LWFZB0Q4PU'

GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.setwarnings(False)

p = GPIO.PWM(12, 50)
p.start(7.5)
print "Servo Activated"
while True:

43 | P a g e
conn = urllib.urlopen("http://api.thingspeak.com/channels/%s/feeds/last.json?api_key=
%s" % (CHANNEL_ID,READ_API_KEY))
response = conn.read()
if response == '90':
p.ChangeDutyCycle(7.5) # turn towards 90 degree
time.sleep(1) # sleep 1 second
elif response == '180':
p.ChangeDutyCycle(12.5) # turn towards 180 degree
time.sleep(1) # sleep 1 second

p.stop()
Procedure:

 Here we used the servor motor rotated in 180 degree with the help of the ETS IoT Kit

 The servor motor is controlled by the ThingSpeak cloud

 The received data is ‘90’ the servor motor rotates at 90 degree or if the data is ‘180;
the motor rotates at 180 degree

 Give the connection as per the connection diagra and pin mapping

 Refer Annexure I how to run the below code in the ETS IoT Kit

Result:

44 | P a g e
CONTROL ROTATION OF 360 DEGREE SERVO MOTOR
USING THINGSPEAK & ETS IOT KIT
Aim:

 In this project rotation speed and angle of rotation of the servo motor can be
controlled

Components Required:

 ETS IoT Trainer Kit


 Servo Motor (MG995)
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Servo Motor:

 Servo motor are controlled by sending an electrical pulse of variable width, or pulse
width modulation (PWM), through the control wire
 The desired position is sent via electrical pulses through the signal wire.
 The motor's speed is proportional to the difference between its actual position and
desired position.
 If the motor is near the desired position, it will turn slowly, otherwise it will turn fast
 The servo motor is most commonly used for high technology devices in the industrial
application like automation technology.
 It is a self-contained electrical device that rotate parts of a machine with high
efficiency and great precision.
 The output shaft of this motor can be moved to a particular angle.
 Servo motors are mainly used in home electronics, toys, cars, airplanes, etc

Fig : MG995 Servo motor

45 | P a g e
Connection Diagram:

Pin Mapping:

ETS-IoT Kit SENSOR


5V VCC
RPi22 INPUT
GND GND

46 | P a g e
Program:

import RPi.GPIO as GPIO


import time
import urllib
CHANNEL_ID ='559174'
READ_API_KEY ='ND9QG4LWFZB0Q4PU'

GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.setwarnings(False)

p = GPIO.PWM(12, 50)
p.start(7.5)
print "Servo Activated"
while True:
conn = urllib.urlopen("http://api.thingspeak.com/channels/%s/feeds/last.json?api_key=
%s" % (CHANNEL_ID,READ_API_KEY))
response = conn.read()
if response == '360':
p.ChangeDutyCycle(2.5) # turn towards 360 degree
time.sleep(1) # sleep 1 second
elif response == '180':
p.ChangeDutyCycle(12.5) # turn towards 180 degree
time.sleep(1) # sleep 1 second
elif response == '90':
p.ChangeDutyCycle(7.5) # turn towards 90 degree
time.sleep(1) # sleep 1 second

p.stop()

Procedure:

 Here we used the servor motor rotated in 180 degree with the help of the ETS IoT Kit

 The servor motor is controlled by the ThingSpeak cloud

 The received data is ‘90’ the servor motor rotates at 90 degree or if the data is ‘180;
the motor rotates at 180 degree if the received value is 360 motor rotates at 360
degree

 Give the connection as per the connection diagram and pin mapping

 Refer Annexure I how to run the below code in the ETS IoT Kit

Result:

47 | P a g e
48 | P a g e
INTERFACE GPS MODULE AND PRINT LATITUDE
LONGITUDE IN OLED DISPLAY OF ETS IOT KIT
Aim:

 This Project is used to get the latitude and longitude of the particular location with the
help of GPS Module

Components Required:

 ETS IoT Trainer Kit


 GPS Module (NEO-6M)
 Power Adaptor
 HDMI to VGA Converter
 Monitor

GPS Module:

 GPS Module (NEO-6M) is a very popular, cost-effective, high-performance GPS


module.
 This GPS module comes with a ceramic patch antenna and an on-board memory chip
and a backup battery that is conveniently integrate with a broad range of the micro
controllers. .
 This unit uses the latest technology to give the best possible positioning information
and includes a larger built-in 25 x 25mm active GPS antenna with a UART TTL
socket.
 This GPS module gives the best possible position information, allowing for better
performance
 The GPS module has serial TTL output, it has four pins: TX, RX, VCC, and GND
 NEO-6 modem is pre-configured to output data using the serial (UART) interface and
encode GPS data to the NMEA protocol.
 When the GPS module is supplied power, it initially takes some time to get ready.
This will depend on the configuration of the module

49 | P a g e
Features:

 5Hz position update rate


 Operating temperature range: -40 TO 85°CUART TTL socket
 EEPROM to save configuration settings
 The cold start time of 38 s and Hot start time of 1 s
 Supply voltage: 3.3 V
 Configurable from 4800 Baud to 115200 Baud rates. (default 9600)
 SuperSense ® Indoor GPS: -162 dBm tracking sensitivity
 Support SBAS (WAAS, EGNOS, MSAS, GAGAN)
 Separated 18X18mm GPS antenna

Fig : GPS Module


Connection Diagram:

Fig : Circuit diagram

50 | P a g e
Pin Mapping:

ETS-IoT Kit GPS Module

5V VCC
TX RX
RX TX
GND GND

Program:
import serial
import time
import string
import pynmea2
while True:
port="/dev/ttyS0"
ser=serial.Serial(port, baudrate=9600, timeout=0.5)
dataout =pynmea2.NMEAStreamReader()
newdata=ser.readline()
if newdata[0:6] == "$GPRMC":
newmsg=pynmea2.parse(newdata)
lat=newmsg.latitude
lng=newmsg.longitude
gps = "Latitude=" + str(lat) + " and Longitude=" +str(lng)
print(gps)

Procedure:
 The GPS module is used to determine the latitude, longitude and altitude of the
landmark is determined
 The analysed latitude, longitude and altitude are display in the OLED display present
in the ETS IoT Kit
 Give the connection as per the connection diagram and pin mapping
 Refer Annexure I how to run the below program in the ETS IoT Kit.
 Refer Annexure IV for enable serial port.

Result:

51 | P a g e
INTERFACING INERTIAL MEASUREMENT UNIT WITH
ETS IOT KIT AND SEND DATA TO THINGSPEAK CLOUD

Aim:
 In this project is learn about the how to interface the inertial measurement unit with
ETS IoT Kit and also send data to the ThingSpeak cloud

Components Required:
 ETS IoT Trainer Kit
 Inertial Measurement Unit Sensor (IMU)
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Inertial Measurement Unit Sensor (IMU):

 An IMU is a specific type of sensor that measures angular rate, force and sometimes
magnetic field
 An inertial measurement unit (IMU) measures and reports raw or filtered angular rate
and specific force/acceleration experience by the object it is attached to.
 Data outputs for an IMU are typically body-frame accelerations, angular rates and
(optionally) magnetic field measurements.
 Once attached to an object, IMU sensors can provide information on the body’s
angular rate, orientation, and even force applied to it by measuring the linear and
angular motion using the combination of accelerometer, gyroscope, and
magnetometer.
 They are used inside all modern smartphones, AR and VR headsets and any other
product that requires tracking in three-dimensional space.

Fig : MPU9250 Module ( Inertial Measurement Unit)

52 | P a g e
Connection Diagram:

Fig : Circuit Diagram

Fig : Connection Diagram

Pin Mapping:

53 | P a g e
ETS-IoT Kit GPS Module

3.3V VCC
SCL SCL
SDA SDA
GND GND
Program:
import FaBo9Axis_MPU9250
import time
import sys
import urllib
mpu9250= FaBo9Axis_MPU9250.MPU9250()
#import sys mpu9250 = FaBo9Axis_MPU9250.MPU9250()

while True:
accel = mpu9250.readAccel()
print " ax = " , ( accel['x'] )
print " ay = " , ( accel['y'] )
print " az = " , ( accel['z'] )

gyro = mpu9250.readGyro()
print " gx = " , ( gyro['x'] )
print " gy = " , ( gyro['y'] )
print " gz = " , ( gyro['z'] )

mag = mpu9250.readMagnet()
print " mx = " , ( mag['x'] )
print " mz = " , ( mag['z'] )

urllib.urlopen("https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1=+str(accel['x'],accel['y'],accel[z'])&field2=+
str(gyro['x'],gyro['y'],gyro[z'])&field3=+str( mag['x'],mag['y'])")
time.sleep(5)

Procedure:
 The inertial measurement unit module is used to determine the angular rate and
magnetic field
 The read value is published to the ThingSpeak cloud
 The IMU module connected to the ETS IoT Kit as refer the above connection diagram
and pin mapping
 Refer Annexure I for how to run the below program in the ETS IoT Kit.
 Refer Annexure V.

Result:

54 | P a g e
INTERFACING HALL SENSOR WITH ETS IOT KIT AND
SEND DATA TO THINGSPEAK CLOUD

Aim:
 In this project learn about how interface the Digital Magnetometer unit with ETS IoT
kit

Components Required:

 ETS IoT Trainer Kit


 Digital Magnetometer
 Power Adaptor
 HDMI to VGA Converter
 Monitor

DIGITAL MAGNETOMETER:

 The KY-024 Linear Magnetic Hall Effect Sensor Module and a digital interface, built-
in 13 LED build a simple circuit to produce a magnetic field warning lamp comes with
digital interfaces of the LED,
 The linear Hall sensor magnetometer access number 3 interface, when linear Hall
magnetometer Sensor senses a key signal, LED lights, otherwise off.
 Hall switch integrated circuit using hall effect principle, Uses the semiconductor
integrated technology manufacturing magnetic susceptibility of the circuit, it is by the
voltage regulator, hall voltage generator, differential amplifier, Schmitt triggers,
temperature compensation,
 The open collector output stage circuit composed of magnetic sensitive sensor circuit,
its input for the magnetic induction intensity, the output is a digital voltage signal.
 A magnetic field is detected by the sensor and will be printed as an analog voltage
value. You can control the sensitivity of the sensor with the potentiometer.

55 | P a g e
Fig :Hall sensor module

Connection Diagram:

Pin Mapping:

ETS-IoT Kit GPS Module

3.3V VCC
RPI 7 D0
GND GND

Program:
import RPi.GPIO as GPIO
import urllib
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

56 | P a g e
hallpin = 7
GPIO.setup( hallpin, GPIO.IN)

while True:
if(GPIO.input(hallpin) == False):
urllib.urlopen(“https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1=+str(0)”)
print “magnetic field not detected”
else:
urllib.urlopen(“https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1=+str(1)”)
print “magnetic field detected”
time.sleep(5)

Procedure:
 The digital magnetometer to find the magnetic field detection in the electronic devices
 In the digital magnetometer output of the module is 0 or 1
 If the magnetic field is detected the magnetometer value is 1 and if not detected the
value is 0
 The magnetic field is detected the value is send to the ThingSpeak cloud
 Give connection as per the connection diagram and pin mapping
 Refer Annexure I how to run the below program in the ETS IoT Kit

Result:

INTERFACING DIGITAL GYROSCOPE UNIT WITH ETS


IOT KIT AND SEND DATA TO THINGSPEAK CLOUD

57 | P a g e
Aim:

 In this project learn about how to interface Digital Gyroscope with ETS IoT Kit

Components Required:

 ETS IoT Trainer Kit


 Digital Gyroscope Unit
 Power Adaptor
 HDMI to VGA Converter
 Monitor

Digital Gyroscope:

 MPU6050 module uses the popular MPU6050 Sensor which includes both a 3 axis
accelerometer and a 3 axis gyroscope in a single package.
 The sensor can be interfaced through a I2C connection which allows an easy and
direct interface between the sensor and a micro controller.
 The MPU-6000/MPU-6050 family of parts are the world’s first and only 6-axis
Motion Tracking devices designed for the low power, low cost, and high performance
requirements of smartphones, tablets and wearable sensors.
 The 6 Degree of Freedom sensor breakout integrate with the MPU6050 sensor and the
low noise 3.3v regulator and pull-up resistors for the I2C bus.
 Digital I2C interface to read the output of the sensor
 Selectable Solder Jumpers on CLK, FSYNC and AD0
 Tri-Axis angular rate sensor (gyro) with a sensitivity up to 131 LSBs/dps and a full-
scale range of ±250, ±500, ±1000, and ±2000dps
 Tri-Axis accelerometer with a programmable full scale range of ±2g, ±4g, ±8g and
±16g

Connection Diagram:

58 | P a g e
Fig : Circuit Diagram

Fig : Connection Diagram

Pin Mapping:

59 | P a g e
ETS-IoT Kit Magnetometer

3.3V VCC
SCL SCL
SDA SDA
GND GND

Program:

import smbus #import SMBus module of I2C


from time import sleep #import
import urllib

#some MPU6050 Registers and their Address


PWR_MGMT_1 = 0x6B
SMPLRT_DIV = 0x19
CONFIG = 0x1A
GYRO_CONFIG = 0x1B
INT_ENABLE = 0x38
ACCEL_XOUT_H = 0x3B
ACCEL_YOUT_H = 0x3D
ACCEL_ZOUT_H = 0x3F
GYRO_XOUT_H = 0x43
GYRO_YOUT_H = 0x45
GYRO_ZOUT_H = 0x47

def MPU_Init():
#write to sample rate register
bus.write_byte_data(Device_Address, SMPLRT_DIV, 7)

#Write to power management register


bus.write_byte_data(Device_Address, PWR_MGMT_1, 1)

#Write to Configuration register


bus.write_byte_data(Device_Address, CONFIG, 0)

#Write to Gyro configuration register


bus.write_byte_data(Device_Address, GYRO_CONFIG, 24)

#Write to interrupt enable register


bus.write_byte_data(Device_Address, INT_ENABLE, 1)

def read_raw_data(addr):

60 | P a g e
#Accelero and Gyro value are 16-bit
high = bus.read_byte_data(Device_Address, addr)
low = bus.read_byte_data(Device_Address, addr+1)

#concatenate higher and lower value


value = ((high << 8) | low)

#to get signed value from mpu6050


if(value > 32768):
value = value – 65536
return value

bus = smbus.SMBus(1) # or bus = smbus.SMBus(0) for older version boards


Device_Address = 0x68 # MPU6050 device address

MPU_Init()

print (“ Reading Data of Gyroscope and Accelerometer”)

while True:

#Read Accelerometer raw value


acc_x = read_raw_data(ACCEL_XOUT_H)
acc_y = read_raw_data(ACCEL_YOUT_H)
acc_z = read_raw_data(ACCEL_ZOUT_H)

#Read Gyroscope raw value


gyro_x = read_raw_data(GYRO_XOUT_H)
gyro_y = read_raw_data(GYRO_YOUT_H)
gyro_z = read_raw_data(GYRO_ZOUT_H)

#Full scale range +/- 250 degree/C as per sensitivity scale factor
Ax = acc_x/16384.0
Ay = acc_y/16384.0
Az = acc_z/16384.0

Gx = gyro_x/131.0
Gy = gyro_y/131.0
Gz = gyro_z/131.0

61 | P a g e
print (“Gx=%.2f” %Gx, u’\u00b0’+ “/s”, “\tGy=%.2f” %Gy, u’\u00b0’+
“/s”, “\tGz=%.2f” %Gz, u’\u00b0’+ “/s”, “\tAx=%.2f g” %Ax, “\tAy=%.2f g” %Ay,
“\tAz=%.2f g” %Az)
urllib.urlopen(“https://api.thingspeak.com/update?
api_key=JECTKF4RJR44LGVY&field1=+str(Ax,Ay,Az)&field2=+str(Gx,Gy,Gz)”)
sleep(1)

Procedure:
 The digital gyroscope module is used to determine the gyroscopic and Accelerometer
values
 The gyroscopic value and the Accelerometer is send to the ThingSpeak cloud
 Give the connection ass per the above connection diagram and pin mapping
 Refer Annexure I how to run the below program in the ETS IoT Kit

Result:

62 | P a g e
INTERFACING LiDAR WITH ETS IOT KIT AND SEND
DATA TO THINGSPEAK CLOUD
Aim:

 In this project is used to learn about how to interface the LiDAR Distance sensor with
the ETS IoT Kit monitoring the value in the ThingSpeak Cloud

Components Required:

 ETS IoT Trainer Kit


 LiDAR Distance Sensor
 Power Adaptor
 HDMI to VGA Converter
 Monitor

LiDAR Distance Sensor:

 LiDAR is based on the TOF principle.


 With unique optical and electrical design, it can achieve stable, accurate and highly
sensitive range measurement. .
 The TF Luna is suitable for its technical specifications and its ultra-compact size
perfect for identification applications of all kinds.
 This includes, for example, level measurements, lift systems or applications in
intrusion detection.
 The product is built with algorithms adapted to various application environments and
adopts multiple adjustable configurations and parameters so as to offer excellent
distance measurement performances in complex application fields and scenarios.
 The TF-Luna adopts serial communication protocol so that it can connect to any
control board supporting serial port communication like Arduino, Raspberry Pi, etc.

Program:

63 | P a g e
import serial,time
import numpy as np
import urllib

# TFLuna Lidar #
ser = serial.Serial(“/dev/serial0”, 115200,timeout=0) # mini UART serial device

# read ToF data from TF-Luna #


def read_tfluna_data():
while True:
counter = ser.in_waiting # count the number of bytes of the serial port

if counter > 8:
bytes_serial = ser.read(9) # read 9 bytes
ser.reset_input_buffer() # reset buffer

# check first two bytes


if bytes_serial[0] == 0x59 and bytes_serial[1] == 0x59:
# distance in next two bytes
distance = bytes_serial[2] + bytes_serial[3]*256
# signal strength in next two bytes
strength = bytes_serial[4] + bytes_serial[5]*256
# temp in next two bytes
temperature = bytes_serial[6] + bytes_serial[7]*256
# temp scaling and offset
temperature = (temperature/8.0) – 256.0
return distance/100.0,strength,temperature

while True:
if ser.isOpen() == False:
ser.open() # open serial port if not open
distance,strength,temperature = read_tfluna_data() # read values
print(‘Distance: {0:2.2f} m, Strength: {1:2.0f} / 65535 (16-bit), Chip Temperature:
{2:2.1f} C’.\ format(distance,strength,temperature)) # print sample data
ser.close() # close serial port

urllib.urlopen(“https://api.thingspeak.com/update?api_key=JECTKF4RJR44LGVY&
field1= +str(distance)&field2=+str(strength)&field3=+str(temperature))
time.sleep(5)

Connection Diagram:

64 | P a g e
Fig : Circuit Diagram

Fig : Connection Diagram


Pin Mapping:

ETS-IoT Kit LiDAR Color

5V VCC Green
TX RX Yellow
RX TX Orange

65 | P a g e
GND GND Red
Program:
import serial
import urllib

ser = serial.Serial(“/dev/ttyS0”, 115200)

def getTFminiData():
while True:
count = ser.in_waiting
if count > 8:
recv = ser.read(9)
ser.reset_input_buffer()
if recv[0] == ‘Y’ and recv[1] == ‘Y’: # 0x59 is ‘Y’
low = int(recv[2].encode(‘hex’), 16)
high = int(recv[3].encode(‘hex’), 16)
distance = low + high * 256
print(distance)

if __name__ == ‘__main__’:
try:
if ser.is_open == False:
ser.open()
getTFminiData()
except KeyboardInterrupt: # Ctrl+C
if ser != None:
ser.close()

Procedure:
 In this we used to measure the distance, strength and temperature of the object with
the help of the LiDAR distance sensor
 The LiDAR sensor is connected in the UART method to the ETS IoT Kit the
connection is given as per the below connection diagram
 The below given python program is used to define the distance, strength and
temperature and publish them in the ThingSpeak cloud
 Give the connection as the per the connection diagram
 Refer the Annexure I for how to run the python code
 Refer Annexure IV for enable serial port.

Result:

66 | P a g e
DISPLAY ULTRASONIC SENSOR DATA BY INTERFACING
LCD DISPLAY WITH STM32 DEVELOPMENT BOARD
USING ARDUINO IDE
Aim:

 In this project how to use the STM 32 development board and how to interface the
LCD display with it

Components Required:

 STM32 Nucle Board

 Type A Micro USB Cable

 LCD Display

 Ultrasonic Sensor

STM32 Development Board:

 The NUCLEO-L476RG is a STM32 Nucleo-64 Development Board with


STM32F410RB microcontroller.
 The board provides a flexible way for users to try out new ideas and build prototypes
with any STM32 microcontroller line, choosing from the various combinations of
performance, power consumption and features.
 The Arduino connectivity support and ST Morpho headers make it easy to expand the
functionality of the STM32 Nucleo open development platform with a wide choice of
specialized shields.

67 | P a g e
 The board does not require any separate probe as it integrates the ST-LINK/V2-1
debugger and programmer.
 The board comes with the STM32 comprehensive software HAL library together with
various packaged software examples, as well as direct access to mbed online
resources.

68 | P a g e
69 | P a g e
70 | P a g e
Programming STM32 Nucleo Board with Arduino IDE:

• The STM32 Development Board can be easily programmed with Arduino IDE since it
is easy to use.
• Programming STM32 with the Arduino IDE will hardly take 5-10 minutes. All you
need is the Arduino IDE, a USB cable and the STM32 Development board itself.
• Let us Set up the Arduino IDE for STM32 module and program it to blink a LED
light.
• Go to File -> Preferences to open the below dialog box. In the “Additional Board
managers URL” paste the below link as shown in the image. Then press OK
https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/
package_stm_index.json

71 | P a g e
• Now, go to Tool -> Boards -> Board Managers. Search for STM32 in search box the
STM32 boards are shown in the list and click on install as shown in the below image

72 | P a g e
LCD Display:

 This is a basic 16 character by 2 line Alphanumeric display. Black text on Green


background.
 Utilizes the extremely common HD44780 parallel interface chipset .
 Interface code is freely available.
 It requires Minimum 6 general I/O pins to interface to this LCD screen. Includes LED
backlight. Works in 4bit and 8 bit Mode.
 Each character can either be an alphabet or number or even a custom character.
 This particular LCD gas a green backlight, we can also get a Blue Backlight LCD

Program:

73 | P a g e
#include <LiquidCrystal.h>// includes the LiquidCrystal Library

// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(1, 2, 4, 5, 6, 7 );

constint trigPin = 9; //D9


constint echoPin = 10; //D10
long duration;
int distanceCm, distanceInch;

void setup(){
// Initializes the interface to the LCD screen, and specifies the dimensions (width and height)
of the display
lcd.begin(16,2);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

voidloop(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
// Sets the location at which subsequent text written to the LCD will be displayed
lcd.setCursor(0,0);
lcd.print(“Distance: “);// Prints string “Distance” on the LCD
lcd.print(distanceCm);// Prints the distance value from the sensor
lcd.print(“ cm”);
delay(10);
lcd.setCursor(0,1);
lcd.print(“Distance: “);
lcd.print(distanceInch);
lcd.print(“ inch”);
delay(10);
}

74 | P a g e
Connection Diagram:

Pin Mapping:

STM32 Nucleo board Ultrasonic sensor

5V VCC
D9 Echo
D10 Trig
GND GND

STM32 Nucleo board LCD display

5V VDD, LED A
D1 RS
D2 Enable
D4 D4
D5 D5
D6 D6
D7 D7
GND VSS, RW, LED K
Procedure:
 Give the connection as per the connection diagram
 The distance is measured by the distance with help of the ultrasonic sensor
 The measured distance is displayed in the LCD display
 For this run the below coding in the arduino IDE for refer the above STM32 board
programming

75 | P a g e
76 | P a g e
INTERFACING COLOR DISPLAY WITH ESP8266
DEVELOPMENT BOARD USING ARDUINO IDE
Aim:

 In this project is used to learn about the ESP8266 and how to interface the color
display with it and display the ultrasonic sensor value in the display

Components Required:

 Esp8266 (Node MCU)

 Color Display

 Ultrasonic Sensor

 USB cable

 Connecting Wires

ESP8266 (NODE MCU):

• NodeMCU is an open-source Lua based firmware and development board specially


targeted for IoT based Applications
• The board is based on the highly popular ESP8266 WiFi Module chip with the
ESP8266 SMD footprint.
• This WiFi development board already embeds in its board all the necessary
components for the ESP8266 to program and uploade code.
• It has a built-in USB to serial chip upload codes, 3.3V regulator and logic level
converter circuit so you can immediately upload codes and connect your circuits.
• This board contains the ESP8266 chip with a 4MB flash memory
• The ESP8266 NodeMCU development board – a true plug-and-play solution for
inexpensive projects using WiFi.
• The module arrives pre-flashed with NodeMCU firmware so just install your USB
driver.
• The NodeMCU is an open-source project and you can find all the design files and so
on from their github page.
• This microcontroller board can easily be programmed using the Arduino IDE
programming software.

Program:

77 | P a g e
NodeMCU Development Board Pinout Configuration:

78 | P a g e
Programming NodeMCU ESP8266 with Arduino IDE:
• The NodeMCU Development Board can be easily programmed with Arduino IDE
since it is easy to use.
• Programming NodeMCU with the Arduino IDE will hardly take 5-10 minutes. All
you need is the Arduino IDE, a USB cable and the NodeMCU board itself.
• Let us Set up the Arduino IDE for ESP8266-1module and program it to blink a LED
light.
• Go to File -> Preferences to open the below dialog box. In the “Additional Board
managers URL” paste the below link as shown in the image. Then press OK
• http://arduino.esp8266.com/stable/package_esp8266com_index.json

79 | P a g e
• Now, go to Tool -> Boards -> Board Managers. Search for ESP8266 by esp8266
community and click on install as shown in the below image

• Now, go to Tools -> Boards -> NodeMCU. You should see the below screen.

80 | P a g e
Color Display:

 This lovely little display breakout is the best way to add a small, colorful and bright
display to any project.

 The 2.0 Inch SPI TFT LCD Color Screen Module display uses 4-wire SPI to
communicate and has its own pixel-addressable frame buffer

 It can be used with every kind of microcontroller. Even a very small one with low
memory and few pins available

 The 2.0 display has 176220 color pixels. Similar LCD displays, which are CSTN type
and thus have poor color and slow refresh,

 This display is a true TFT! The TFT driver (ILI9225) can display full 18-bit color
(262,144 shades).

 The LCD will always come with the same driver chip so there are no worries that
your code will not work from one to the other.

 The breakout has the TFT display soldered on (it uses a delicate flex-circuit
connector) as well as an ultra-low-dropout 3.3V regulator and a 3/5V level shifter so
you can use it with 3.3V or 5V power and logic.

 We also had a little space so we placed a micro SD card holder so you can easily load
full-color bitmaps from a FAT16/FAT32 formatted micro SD card.

81 | P a g e
Connection Diagram:

Fig : Circuit Diagram

Pin Mapping:

ESP8266 Color display

3.3V VCC
D8 CS
D4 RST
D2 RS
D5 SCK
D7 MOSI/SDA
GND GND

82 | P a g e
Program

// Include application, user and local libraries


#include "SPI.h"
#include "TFT_22_ILI9225.h"
#include "math.h"

#if defined (ARDUINO_ARCH_STM32F1)


#define TFT_RST PA1
#define TFT_RS PA2
#define TFT_CS PA0 // SS
#define TFT_SDI PA7 // MOSI
#define TFT_CLK PA5 // SCK
#define TFT_LED 0 // 0 if wired to +5V directly
#elif defined(ESP8266)
#define TFT_RST 4 // D2
#define TFT_RS 5 // D1
#define TFT_CLK 14 // D5 SCK
//#define TFT_SDO 12 // D6 MISO
#define TFT_SDI 13 // D7 MOSI
#define TFT_CS 15 // D8 SS
#define TFT_LED 2 // D4 set 0 if wired to +5V directly -> D3=0 is not possible !!
#elif defined(ESP32)
#define TFT_RST 26 // IO 26
#define TFT_RS 25 // IO 25
#define TFT_CLK 14 // HSPI-SCK
//#define TFT_SDO 12 // HSPI-MISO
#define TFT_SDI 13 // HSPI-MOSI
#define TFT_CS 15 // HSPI-SS0
#define TFT_LED 0 // 0 if wired to +5V directly
#else
#define TFT_RST 8
#define TFT_RS 9
#define TFT_CS 10 // SS
#define TFT_SDI 11 // MOSI
#define TFT_CLK 13 // SCK
#define TFT_LED 3 // 0 if wired to +5V directly
#endif

#define TFT_BRIGHTNESS 200 // Initial brightness of TFT backlight (optional)

#define ROTATE_ANGLE 10 // Angle in degrees to rotate the triangle

struct _point
{
int16_t x;
int16_t y;
};

// Use hardware SPI (faster - on Uno: 13-SCK, 12-MISO, 11-MOSI)

83 | P a g e
TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_LED,
TFT_BRIGHTNESS);

// Variables and constants


_point c1, c2, c3, cc;

// Setup
void setup() {
tft.begin();

// Define triangle start coordinates


c1.x = 30; c1.y = 30;
c2.x = 120; c2.y = 80;
c3.x = 80; c3.y = 130;

// Determine the rotation point, i.e. the center of the triangle


cc = getCoordCentroid(c1, c2, c3);

tft.clear();
}

// Loop
void loop() {
// Calculate the number of steps to rotate the triangle a full rotation
int16_t steps = (int16_t)(360 / ROTATE_ANGLE);

// Draw solid triangle


tft.fillTriangle(30, 190, 80, 150, 130, 210, COLOR_BLUE);

for (int8_t i = 0; i < steps; i++) {


// Draw triangle
tft.drawTriangle(c1.x, c1.y, c2.x, c2.y, c3.x, c3.y, COLOR_GREEN);
// Rotate triangle
rotateTriangle(c1, c2, c3, cc, ROTATE_ANGLE);
delay(50);
}
delay(5000);
tft.clear();
}

// Get centroid of triangle


_point getCoordCentroid( _point a, _point b, _point c ) {
_point o;

o.x = (int16_t)((a.x + b.x + c.x) / 3);


o.y = (int16_t)((a.y + b.y + c.y) / 3);

return o;
}

84 | P a g e
// Rotate triangle around point r
void rotateTriangle( _point &a, _point &b, _point &c, _point r, int16_t deg ) {

// Convert degrees to radians


float angle = (float)deg * 1000 / 57296;

// Rotate each individual point


a = rotatePoint( r, angle, a);
b = rotatePoint( r, angle, b);
c = rotatePoint( r, angle, c);
}

// Rotate each point p around c


_point rotatePoint( _point c, float angle, _point p ) {
_point r;

// 1. translate point back to origin


// 2. rotate point
// 3. translate point back

r.x = cos(angle) * (p.x - c.x) - sin(angle) * (p.y - c.y) + c.x;


r.y = sin(angle) * (p.x - c.x) + cos(angle) * (p.y - c.y) + c.y;

return r;
}
Procedure:

 Give the connection as per the connection diagram

 The distance is measured by the distance with help of the ultrasonic sensor

 The measured distance is displayed in the Color display

 For this run the below coding in the Arduino IDE for refer the above ESP8266 board
programming

 Refer Annexure VI

Result:

85 | P a g e
INTERFACING MICRO SD CARD MODULE WITH ESP8266 DEVELOPMENT
BOARD USING ARDUINO IDE

Aim:

 In this project is used to learn about the ESP8266 and how to interface the SD card
with ESP8266 for writing and reading data.

Components Required:

 Esp8266 (Node MCU)

 Micro SD card module

 USB cable

 Connecting Wires

SD card

This Mini Micro SD Card Reader Module also called Micro SD Adaptor which is designed
for dual I/O voltages. The Module is a simple solution for transferring data to and from a
standard SD card. The pinout is directly compatible with Not only with Arduino but can also
be used with other microcontrollers development boards.

Micro SD Card Reader Module has an SPI interface which is compatible with any sd card
and it uses 3.3V power supply which is compatible with Arduino UNO/Mega.SD module has
various applications such as data logger, audio, video, graphics.

There are total of six pins (GND, VCC, MISO, MOSI, SCK, CS), GND to ground, VCC is
the power supply, MISO, MOSI, SCK is the SPI bus, CS is the chip select signal pin; 3.3V
regulator circuit: LDO regulator output 3.3V as level converter chip, Micro SD card supply.

 Input Voltage: 3.3V/5V


 With all SD SPI Pins out :MOSI, SCK, MISO and CS ,for further connection
 Through programming, you can read and write to the SD card using your arduino
 Make your SD application more easier and simple
 Communicate with Arduino using SPI interface
 Push-pop socket with card slightly over the edge of the PCB so its easy to insert and
remove
 4 mounting holes with 2.2mm diameter

86 | P a g e
Pin Diagram

Micro SD card module ESP 32


3V3 3.3 V
CS D8
MOSI D7
CLK D5
MISO D6
GND GND

Procedure

1. Insert the microSD card into your computer. Go to My Computer and right-click on
the SD card. Select Format as shown in the figure below.
2. A new window pops up. Select FAT32, press Start to initialize the formatting process
and follow the onscreen instructions.

3. Give the connection as per the connection diagram

4. For this run the below coding in the Arduino IDE for refer the above ESP8266 board
programming

5. Refer Annexure VII

Circuit Diagram

Fig: Circuit diagram

87 | P a g e
Program

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);

Serial.print("Initializing SD card...");

if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:


if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}

// re-open the file for reading:


myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");

// read from the file until there's nothing else in it:


while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();

88 | P a g e
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

void loop() {
// nothing happens after setup
}

Result

89 | P a g e
ANNEXURE I

How to run the program in the ETS IoT Kit:

Step1: Go to Menu -> Programming -> Python 2.7 IDLE -> File -> New

Step2: Write your program

Step3: Save & Run the program (Run -> Run Module)

ANNEXURE II

How to sign up in the ThingSpeak cloud

 You have to sign up with thingspeak


 Create a new channel
 Define the channel name
 Add the fields you want to update
 And copy the write API Key to write the data into Thinngspeak (Cloud)
 Copy the Read API key to Read the Data from the Thingspeak (Cloud)

ANNEXURE III
ADXL 345

Step 1 : Open Terminal


Step 2 : sudo raspi-config
Step 3 : Enable i2c and reboot
Step 4: sudo reboot
Step 5 : Open terminal

Step 6 : sudo apt-get update


Step 7 : sudo apt-get install python-smbus python3-smbus python-dev python3-dev i2c-tools

Step 8 : sudo i2cdetect –y 1

Step 8 : Check address

ANNEXURE IV
Serial Port Enable

90 | P a g e
Step 1 : Enable Serial Port
>>>sudo nano /boot/config.txt
Step 2 : Scroll to the Bottom of the Boot File and Add ‘enable_uart=1’
>>> sudo reboot
Step 3 : Verify Enabled mini UART with /dev/serial0 -> ttyS0, enter the following command
>>>ls –l /dev/serial
Step 4 : >>>python –m pip install pyserial

Step 5 :>>> sudo apt-get install minicom

Step 6 : >>>pip install pynmea2

ANNEXURE V
Inertial Measurement
Open terminal

>>> pip install FaBo9Axis_MPU9250


>>> sudo reboot

ANNEXURE VI
Step 1 : go to the link : https://github.com/Nkawu/TFT_22_ILI9225
Step 2 : Install the library
Step 3: Open examples and select the program
Step 4: Make connections
Step 5: Run the program

ANNEXURE VII

Step1: Format the memory card in “ FAT32” format


Step 2 :Create a file inside the memory (test.txt)
Step 3 : Enter some content inside the file

91 | P a g e

You might also like