140 likes | 265 Views
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 http://link.koreatech.ac.kr. Introduction.
E N D
Ubiquitous Computing Practice(Wi-Fi) Youn-Hee Han, Chan-Myung Kim {yhhan, cmdr}@koreatech.ac.kr Laboratory of Intelligent NetworksAdvanced Technology Research CenterKorea University of Technology http://link.koreatech.ac.kr
Introduction Arduino – Wifi Shield (Recommended)
Introduction SparkfunWifly Shield ArduinoWifi Shield (Recommended)
ArduinoWiFi Shield http://arduino.cc/en/Main/ArduinoWiFiShield
Wifi Library • Wifi • begin() • disconnect() • SSID() • RSSI() • … • Server • begin() • available() • write() • println() • … • Client • connected() • connect() • print() • println() • available() • read() • stop() • … http://arduino.cc/en/Reference/WiFi
Post Tweet • . http://arduino-tweet.appspot.com/
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); }
Encryption • Open (No Encryption) char ssid[] = "yourNetwork"; int status = WiFi.begin(ssid); • WPA char ssid[] = "yourNetwork"; char pw[] = “yourPassword"; intstatus = WiFi.begin(ssid, pw); • WEP char ssid[] = "yourNetwork"; char key[] = "D0D0DEADF00DABBADEAFBEADED"; // asciicode intkeyIndex = 0; intstatus = WiFi.begin(ssid, keyIndex, key);
Post Tweet • . char server_adr[] = "arduino-tweet.appspot.com"; char[] token = “2E6p1VBvd7oA3S9xPjmHYB7fB4xbEvIf8”; 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); }
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);
Indices • Discomfort Index • 1.8 * temperatureC - 0.55 * (1 - RH/100.0) * (1.8 * temperatureC - 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
Post Tweet • .