Код: Выделить всё
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>
// Настройки для сети
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,2);
IPAddress ip(192,168,1,10);
EthernetClient client;
//Настройки для ЛСиДи
LiquidCrystal lcd(3, 4, 25, 24, 23, 22);
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.print("Microklimat:");
//Старт датчика температуры
dht.begin();
// Ethernet
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: 192.168.1.2");
client.println("Connection: close");
client.println();
}
else {
Serial.println("connection failed");
}
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// print the number of seconds since reset:
//lcd.print(millis()/1000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (t<20){ lcd.setCursor(0, 0);lcd.clear();lcd.print("Xolodno");}
if (t>=20 && t<25){ lcd.setCursor(0, 0);lcd.clear();lcd.print("Teplo");}
if (t>=25){ lcd.setCursor(0, 0);lcd.clear();lcd.print("Garko");}
lcd.setCursor(0, 1);
if (isnan(t) || isnan(h)) {
lcd.print("Temp-ra error");
} else {
lcd.print("C=");
lcd.print(t);
lcd.print(" H=");
lcd.print(h);
}
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
Вот , что выдает порт
Failed to configure Ethernet using DHCP
connecting...
connected
HTTP/1.0 404 Not Found
disconnecting.