14
Youn-Hee Han, Chan-Myung Kim { yhhan , cmdr }@koreatech.ac.kr Laboratory of Intelligent Networks Advanced Technology Research Center Korea University of Technology http://link.koreatech.ac.kr Ubiquitous Computing Practice (Wi-Fi)

Youn-Hee Han, Chan-Myung Kim {yhhan, cmdr}@koreatech.ac.kr Laboratory of Intelligent Networks Advanced Technology Research Center Korea University of Technology

Embed Size (px)

Citation preview

Youn-Hee Han, Chan-Myung Kim{yhhan, cmdr}@koreatech.ac.kr

Laboratory of Intelligent NetworksAdvanced Technology Research Center

Korea University of Technologyhttp://link.koreatech.ac.kr

Ubiquitous Computing Practice(Wi-Fi)

/ 162

Introduction

Arduino – Wifi Shield (Recommended)

/ 163

Introduction

Arduino Wifi Shield (Recommended)

Sparkfun Wifly Shield

/ 164

Arduino WiFi Shield

http://arduino.cc/en/Main/ArduinoWiFiShield

/ 165

Wifi LibraryWifi

begin() disconnect() SSID() RSSI() …

Server begin() available() write() println() …

Client connected() connect() print() println() available() read() stop() …

http://arduino.cc/en/Reference/WiFi

/ 166

Post Tweet.

http://arduino-tweet.appspot.com/

/ 167

Setup

if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); while(true); } while ( status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); status = WiFi.begin(ssid, key); delay(5000); }

/ 168

EncryptionOpen (No Encryption)char ssid[] = "yourNetwork"; int status = WiFi.begin(ssid);

WPAchar ssid[] = "yourNetwork"; char pw[] = “yourPassword"; int status = WiFi.begin(ssid, pw);

WEPchar ssid[] = "yourNetwork"; char key[] = "D0D0DEADF00DABBADEAFBEADED"; // ascii code int keyIndex = 0; int status = WiFi.begin(ssid, keyIndex, key);

/ 169

Post Tweet.char server_adr[] = "arduino-tweet.appspot.com";

char[] token = “2E6p1VBvd7oA3S9xPjmHYB7f-B4xbEvIf8”; String tweet = “ 트윗 내용” ;if (twtclient.connect(server_adr, 80)) { Serial.println("connected"); twtclient.println("POST http://arduino-tweet-.appspot.com/update HTTP/1.0"); twtclient.print("Content-Length: "); twtclient.println(tweet.length()+strlen(token)+14); twtclient.println(); twtclient.print("token="); twtclient.print(token); twtclient.print("&status="); twtclient.println(tweet); }

/ 1610

Temperature + humidity

/ 1611

Temperature + humidity

int indata0;int indata1;float RH;float sRH;float temperatureC;

indata0 = analogRead(0); sRH = (indata0 / 1024.0) /0.0062 - 0.16 / 0.0062; temperatureC = analogRead(1) * 0.004882814; temperatureC = (temperatureC - 0.5) * 100; RH = sRH / (1.0546 - 0.00216 * temperatureC);

/ 1612

IndicesDiscomfort Index

1.8 * temperatureC - 0.55 * (1 - RH/100.0) * (1.8 * tem-peratureC - 26) + 32

Food Poisoning Index (1-exp(-exp(-

4.4946+0.0701*temperatureC+0.0152*RH)))*185.66+26.14

Deterioration Index ((RH-65)/14)*pow(1.054, temperatureC)

http://www.kma.go.kr/weather/lifenindustry/life_01.jsp?JISU_INFO=life3_03

/ 1613

Post Tweet.

/ 1614

Thank You