SlideShare a Scribd company logo
1 of 28
Download to read offline
Internet
Of
Thing
Group1: “หนึ่งหนวยกลุม”
Concept
วัดอุณหภูมิโดยใช dht11 สงคาเวลาและอุณภูมิผาน Webservice ซึ่ง
จะมีฟงกชันสงชวงเวลาปจจุบัน หรือชวงหนึ่งถึงอีกชวงหนึ่ง แลวคืน
คาเปนอุณหภูมิกับเวลาในชวงเวลานั้นๆ
Equipment
- dht11
DHT11
เปน Module สําหรับวัดอุณหภูมิกับความชื้นในอากาศโดยมี
● ยานวัดความชื้น 20-90% RH โดยมีคาความแมนยํา ± 5% RH
● ยานวัดอุณหภูมิ 0 -50 องศาเซลเซียส โดยมีคาความแมนยํา ± 2
● กินกระแส 0.5 - 2.5 mA (ขณะทําการวัดคา) ที่ระดับแรงดัน 3 - 5.5 VDC
● อานคาสัญญาณ (Sample Rate) ทุก 1 วินาที
● ใชการสงสัญญาณแบบ Single-wire Two-way Serial interface
Equipment
- Raspberry Pi 2
Raspberry pi
บอรดคอมพิวเตอรขนาดเล็กที่สามารถเชื่อมตอกับจอมอนิเตอร คียบอรด และเมาสได สามารถ
นํามาประยุกตใชงานตางๆเชนงานทางดานอิเล็กทรอนิกส การเขียนโปรแกรม รองรับระบบ
ปฏิบัติการลินุกซ (Linux Operating System) ไดหลายระบบ เชน Raspbian (Debian)
Pidora (Fedora) และ Arch Linux เปนตน
Amazon web services
เปนผลิตภัณฑที่ใหการบริการเครื่องคอมพิวเตอร (Cloud Computing) เพื่อใชงานในดาน
ตางๆ เชน Web Server, Database Server, File Server
การเชื่อมตอ
อานขอมูล
อุณหภูมิ
สงขอมูล
อุณหภูมิ
และเวลา
Web Service
ฟงกชั่น
add
- รับคาอุณหภูมิ วัน เดือน ป ชั่วโมง และนาทีเพื่อเก็บคาเขาไปในไฟล xml
temperature
- รับคาวันเดือนปชั่วโมงและนาที 2 ชวงแลวคืนคาเปนอุณหภูมิและชวงเวลาที่อยูในคาที่
สงมา
Xml
ผลลัพธ
การเพิ่มชวงอุณหภูมิในเวลา 6/11/2016 9:00น.
ผลลัพธ
การเรียกชวงเวลาในที่นี้เรียกชวง 6/11/2016 9:00 - 15:00น.
อุปกรณ
1.) Raspberry Pi
2.) DHT11 temperature and humidity sensor
3.) Breadboard
4.) Jumper wires
Setup the hardware
Prepare the Raspberry Pi hardware as follows:
DH11 Raspberry Pi
DATA GPIO#4
GND GND
VCC 3.3v
ภาพการตอวงจร
การสงคาขอมูล
import sys
import time
import datetime
import Adafruit_DHT
from SOAPpy import SOAPProxy
from SOAPpy import WSDL
serverUrl='http://35.162.15.38:8081'
namespace='xml'
server = SOAPProxy(serverUrl, namespace)
while(True):
now = datetime.datetime.now()
humidity , temperature = Adafruit_DHT .read_retry(22, 4)
if humidity is not None and temperature is not None:
server.add(temperature ,now.day,now.month,now.year,now.hour,now.minute)
else:
print 'Failed to get reading. Try again!'
time.sleep(120)
ผลลัพธ
ผลการเรียกเมื่อเวลาตั้งแต 7:54-8:11 โดยเก็บคาอุณหภูมิทุกๆ 2 นาที
ผลลัพธ
เมื่อใหเก็บคาขอมูลตั้งแต
13:19 - 19:19 วันที่ 19/11/2016
What’s Thingspeak?
Thingspeak เปนบริการ Platform as a Services ที่ใหบริการ เก็บขอมูลแบบ Real-time,
แสดงขอมูลกราฟ จากที่ใดก็ไดในโลก และ สามารถเปดดูจากที่ไหนก็ได อีกเชนกัน ซึ่งก็
คลายกับ data.sparkfun.com แตสิ่งที่ตางกัน คือ Thingspeak จะแสดงผลขอมูลผานกราฟได
และ ดึงขอมูล (PUT DATA) ไปใชแสดงผลที่เวปเราไดผาน <iframe> ซึ่งมัน update
realtime ดวย ซึ่งมีทั้งบริการทั้งแบบฟรี และ เสียเงิน แตในเวอรชั่นฟรี จะยอมใหเราบันทึก
ขอมูล ทุกๆ 15 วินาที
What’s Thingspeak?
Sending Data with Thingspeak.
HTTP Request
การสงขอมูลจะสงโดยใช GET Method รูปแบบของ HTTP Request แบบที่
data.sparkfun.com ใชงาน สําหรับ Thinkspeak จะใชรูปแบบดังรูป
Sending Data with Thingspeak.
REST API (Representational State Transfer)
เปน Web Service แบบเรียบงาย โดยเรียกใชผานทาง HTTP Method
GET/POST/PUT/DELETE ซึ่งมันออกแบบไวเปน เชื่อมตอกับจัดการฐานขอมูล แสดงผล,
เพิ่มรายการ, แกไขรายการ และ ลบรายการ ซึ่งมันทําไดมากกวา HTTP Request
Sending Data with Thingspeak.
REST API (Representational State Transfer)
Step by step with Thingspeak.
1. สมัครใชงานเพื่อขอเปดบัญชีผูใชใหม (Sign Up)
2. ยืนยันตัวตนเพื่อเขาใชงานสําหรับบัญชีที่สรางไวแลว (Sign In)
3. สราง New Channel หรือชองทางในการสงขอมูลใหม พรอมกําหนดคุณสมบัติของ
Channel
4. สราง API Key สําหรับเขียนขอมูล (API Key for Write) และอานขอมูล (API Key for
Read)
5. เขียนโคด Python และรันโปรแกรม เพื่อสงขอมูลไปยัง ThingSpeak.com ผาน Channel
ที่ไดสรางไว
6. ดูขอมูลในรูปของกราฟผานหนาเว็บ
ผลลัพธ
import sys
import Adafruit_DHT
import time
import urllib
while(True):
humidity, temperature = Adafruit_DHT.read_retry(22, 4)
params = urllib.urlencode({'key': '7XUS2L1NL265HEXE',
'field1': temperature})
f = urllib.urlopen("https://api.thingspeak.com/update",
data=params)
time.sleep(120)
วิดิโอสาธิตการทดลอง
Youtube: Raspberry Pi2 read data of DHT11 and send it to Cloud (IOT)
https://youtu.be/NpJU05GUnDQ
Member
Group1
นาย อภิวัฒธ วงศโทะ รหัสนักศึกษา 52-1116-530-2
นางสาว พัลลภา เขมรังสฤษฏ รหัสนักศึกษา 56-010126-2008-1
นางสาว อัญธิกา หนองบัว รหัสนักศึกษา 56-010126-3028-1
นาย ธีรวัฒน ผองสกุล รหัสนักศึกษา 56-010126-3015-9
นาย ธนดล เตชะวัชรีกุล รหัสนักศึกษา 56-010126-3009-4
นาย ภุมมิฑล ไชยเชิดเกียรติ รหัสนักศึกษา 56-010116-2131-8
Assignmet 2 selectedtopic Topic in Computer Engineer

More Related Content

More from Aey Unthika

To try and create DTD and XML Schema
To try and create DTD and XML SchemaTo try and create DTD and XML Schema
To try and create DTD and XML SchemaAey Unthika
 
Try to Use DOM and SAX API (python)
Try to Use DOM and SAX API (python)Try to Use DOM and SAX API (python)
Try to Use DOM and SAX API (python)Aey Unthika
 
Xml parser week2
Xml parser week2Xml parser week2
Xml parser week2Aey Unthika
 
Introduction to XML.
Introduction to XML.Introduction to XML.
Introduction to XML.Aey Unthika
 
Try PostgreSQL on linux
Try PostgreSQL on linuxTry PostgreSQL on linux
Try PostgreSQL on linuxAey Unthika
 
Example Database normal form
Example Database normal formExample Database normal form
Example Database normal formAey Unthika
 
Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Aey Unthika
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Aey Unthika
 

More from Aey Unthika (8)

To try and create DTD and XML Schema
To try and create DTD and XML SchemaTo try and create DTD and XML Schema
To try and create DTD and XML Schema
 
Try to Use DOM and SAX API (python)
Try to Use DOM and SAX API (python)Try to Use DOM and SAX API (python)
Try to Use DOM and SAX API (python)
 
Xml parser week2
Xml parser week2Xml parser week2
Xml parser week2
 
Introduction to XML.
Introduction to XML.Introduction to XML.
Introduction to XML.
 
Try PostgreSQL on linux
Try PostgreSQL on linuxTry PostgreSQL on linux
Try PostgreSQL on linux
 
Example Database normal form
Example Database normal formExample Database normal form
Example Database normal form
 
Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)Assignment 2 of Database (Database Security)
Assignment 2 of Database (Database Security)
 
Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3) Assignment 1 of Database (MySQL & Sqlite3)
Assignment 1 of Database (MySQL & Sqlite3)
 

Assignmet 2 selectedtopic Topic in Computer Engineer