배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
아두이노 이더넷 Ethernet W5100 micro SD소켓 쉴드 | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #include <SPI.h> #include <Ethernet.h> // Enter a MAC address for your controller below. // Newer Ethernet shields have a MAC address printed on a sticker on the shield byte mac[] = { 0x74,0x69,0x69,0x2D,0x30,0x5}; // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); // this check is only needed on the Leonardo: while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: for (;;) ; } // print your local IP address: printIPAddress(); } void loop() { switch (Ethernet.maintain()) { case 1: //renewed fail Serial.println("Error: renewed fail"); break; case 2: //renewed success Serial.println("Renewed success"); //print your local IP address: printIPAddress(); break; case 3: //rebind fail Serial.println("Error: rebind fail"); break; case 4: //rebind success Serial.println("Rebind success"); //print your local IP address: printIPAddress(); break; default: //nothing happened break; } } void printIPAddress() { Serial.print("My IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | #include <DHT.h> #define DHTPIN A2 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); #include <Wire.h> #include <SPI.h> #include <Ethernet.h> byte mac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x5}; IPAddress ip(DHCP IP주소 찾기 예제 검색 후 아이피주소 입력); // IP 주소는 " XXX,XXX,XXX,XXX " ',' 주의해주세요. // 이더넷 라이브러리 초기화 // 사용할 IP 주소 와 포트 입력 // ('port 80' 은 HTTP 의 기본 값 입니다.): EthernetServer server(80); void client(); void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // 포트 연결까지 기다리기. 레오나르도에만 필요합니다. } // 이더넷 서버 연결 시작: Ethernet.begin(mac, ip); server.begin(); Serial.print("server is at "); Serial.println(Ethernet.localIP()); } void loop() { EthernetClient client = server.available(); if (client) { Serial.println("new client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connnection: close"); client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); // 브라우저 5초마다 새로고침 client.println("<meta http-equiv="refresh" content="5">"); client.println("<title>"); client.print("Welcome EDUINO"); client.println("</title>"); int h = dht.readHumidity(); int t = dht. readTemperature(); // 온습도센서(DHT-11)로부터 값 출력 client.println("<center>"); client.println("<h1>"); client.print("EDUINO Office"); client.println("</h1>"); client.println("<h2>"); client.print("Office Temperature and Humidity"); client.println("</h2>"); client.println("<h4>"); client.print("Temperature : "); client.print(t); client.print("<sup>0</sup>"); client.print("C"); client.println("<br />"); client.print("Humidity : "); client.print(h); client.print("%"); client.println("</h4>"); client.println("</center>"); client.println("</html>"); break; } if (c == '\n') { currentLineIsBlank = true; } else if (c != '\r') { currentLineIsBlank = false; } } } //브라우저 데이터 받는 시간 delay(1); //연결 종료: client.stop(); Serial.println("client disonnected"); } } | cs |
11,000원