first commit
This commit is contained in:
BIN
Adafruit_Unified_Sensor-1.0.3.zip
Normal file
BIN
Adafruit_Unified_Sensor-1.0.3.zip
Normal file
Binary file not shown.
BIN
DHT-sensor-library-master.zip
Normal file
BIN
DHT-sensor-library-master.zip
Normal file
Binary file not shown.
69
DHT11_Server.ino
Normal file
69
DHT11_Server.ino
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include "DHT.h"
|
||||
|
||||
//Константы
|
||||
#define DHTPIN 2
|
||||
#define DHTTYPE DHT11
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
byte mac[] = {
|
||||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Мак адрес
|
||||
byte ip[]={192, 168, 71, 27};
|
||||
|
||||
EthernetClient client;
|
||||
EthernetServer server(80);
|
||||
|
||||
//Переменные
|
||||
unsigned long int timeConn = millis(); // Частота отправки данных о t/h на сервер
|
||||
float h; // Значение температуры
|
||||
float t; // Значение влажности
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
Необходимые настройки
|
||||
—------------------------------------------------------------*/
|
||||
void setup()
|
||||
{
|
||||
//Старт
|
||||
Serial.begin(9600);
|
||||
Ethernet.begin(mac,ip);
|
||||
server.begin();
|
||||
dht.begin();
|
||||
}
|
||||
/*--------------------------------------------------------------
|
||||
Основное тело программы
|
||||
—------------------------------------------------------------*/
|
||||
void loop()
|
||||
{
|
||||
h = dht.readHumidity();
|
||||
t = dht.readTemperature();
|
||||
if (millis() - timeConn > 2000) {
|
||||
//sendData(t,h);
|
||||
timeConn = millis();
|
||||
Serial.println("CONNECT SERVER: Send temp/hum");
|
||||
}
|
||||
//}
|
||||
/*--------------------------------------------------------------
|
||||
Функция отправляет данные о температуре и влажности на
|
||||
WEB сервер.
|
||||
—------------------------------------------------------------*/
|
||||
//void sendData(float t, float h) {
|
||||
client = server.available(); // ожидаем объект клиент
|
||||
|
||||
client.println("HTTP/1.1 200 OK"); // стартовая строка
|
||||
client.println("Content-Type: text/html; charset=utf-8"); // тело передается в коде HTML, кодировка UTF-8
|
||||
client.println(); // пустая строка отделяет тело сообщения
|
||||
client.println("<!DOCTYPE HTML>"); // тело сообщения
|
||||
client.println("<html>");
|
||||
client.print("t=");
|
||||
client.println(t);
|
||||
client.println("<br>");
|
||||
client.println();
|
||||
client.print("h=");
|
||||
client.println(h);
|
||||
client.println("</html>");
|
||||
//client.print(t);
|
||||
//client.print(h);
|
||||
client.stop();
|
||||
client.flush();
|
||||
}
|
||||
1
README.md
Normal file
1
README.md
Normal file
@@ -0,0 +1 @@
|
||||
Скетч для собранного на Arduino датчика температуры и влажности, обеспечивающего систему мониторинга данными по помещению М303.
|
||||
BIN
Scheme-1.jpg
Normal file
BIN
Scheme-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 290 KiB |
BIN
Scheme-2.jpg
Normal file
BIN
Scheme-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
Reference in New Issue
Block a user