#include #include #include #include #include #include #include AVT5636 myBoard; Servo myServo; SimpleDHT11 dht11; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 80, 53); // Initialize the Ethernet server library EthernetServer server(8080); float temperature; float humidity; int term2=0; int term3=0; int term4=0; int term5=0; uint32_t prevMillis = millis(); void setup() { pinMode(22, INPUT_PULLUP); pinMode(24, INPUT_PULLUP); pinMode(26, INPUT_PULLUP); pinMode(28, INPUT_PULLUP); pinMode(30, INPUT_PULLUP); myBoard.init(); myServo.attach(PULSE2_PIN); //delay(3000); //Serial.begin(9600); //while (!Serial) { // ; // wait for serial port to connect. Needed for native USB port only //} Ethernet.begin(mac, ip); server.begin(); //Serial.print("server is at "); //Serial.println(Ethernet.localIP()); } String HTTP_req; bool LED_status4 = 0; bool LED_status3 = 0; bool LED_status2 = 0; int IntTemperature; int IntHumidity; unsigned long previousMillis = 0; float CurrentSensor = 0; void loop() { CurrentSensor = ((5.0/1024.0)*analogRead(10))*10; //Serial.println(CurrentSensor); LED_status4 = 0; LED_status3 = 0; unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= 60000) { previousMillis = currentMillis; delay(2000); byte temperature = 0; byte humidity = 0; byte err = SimpleDHTErrSuccess; if ((err = dht11.read(31, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { //Serial.print("Failed to read from DHT sensor, err="); //Serial.println(err); return; } IntTemperature = temperature; IntHumidity = humidity; term2 = temperature; term3 = humidity; } term4 = 444; term5 = 555; EthernetClient a = server.available(); serveWebsite(a); } EthernetClient serveWebsite(EthernetClient client){ if (client) { //Serial.println("new client"); bool currentLineIsBlank = true; while (client.connected()) { //Serial.println("test1"); if (client.available()) { //Serial.println("test2"); char c = client.read(); //Serial.write(c); HTTP_req += c; if (c == '\n' && currentLineIsBlank) { //Serial.println("test3"); if (HTTP_req.indexOf("LED4=On") > -1) { LED_status4 = 1; } if (HTTP_req.indexOf("LED4=Off") > -1) { LED_status4 = 0; } if (HTTP_req.indexOf("LED3=On") > -1) { LED_status3 = 1; } if (HTTP_req.indexOf("LED3=Off") > -1) { LED_status3 = 0; } if (HTTP_req.indexOf("LED2=On") > -1) { LED_status2 = 1; } if (HTTP_req.indexOf("LED2=Off") > -1) { LED_status2 = 0; } client.println(F("HTTP/1.1 200 OK")); client.println("Content-Type: text/html"); client.println("Connection: close"); //client.println("Refresh: 10; URL=/"); client.println(); client.println(""); client.println(""); client.println(""); client.println(""); // client.println(""); client.println(""); client.println(""); client.println("
"); client.println("

System Pomiarowo-Kontrolny TTCOMM Sp.z.o.o.

"); client.println("

Opracowano przez: Kacper Ostrowski

"); client.println("

Wersja z dnia: 11.06.2024

"); client.println("

Analog Sensor Readings

"); client.println(""); client.println(""); client.println(""); client.println(""); client.println(""); client.println("
SensorValue
Temperature" + String(IntTemperature) + " C
Humidity" + String(IntHumidity) + " %
Electric Current "+String(CurrentSensor)+" A
"); client.println("

Digital Input Readings

"); client.println(""); client.println(""); client.print(""); client.print(""); client.print(""); client.print(""); client.print(""); client.println("
SensorValue
Door Open/Closed"); client.print(digitalRead(22)); client.println("
Flood sensor"); client.print(digitalRead(24)); client.println("
Waveguide Position 1"); client.print(digitalRead(26)); client.println("
Waveguide Position 2"); client.print(digitalRead(28)); client.println("
Waveguide Power Supply"); client.print(digitalRead(30)); client.println("
"); client.println("

Control Buttons

"); client.println("Override Control Buttons:"); client.println("
"); // LED4 control and mode selection client.println("

Waveguide position 1: Please check afterwards the status of position in the above table"); //client.println(""); if (LED_status4) { myBoard.ledOn(4); delay(3000); myBoard.ledOff(4); delay(3000); } else { myBoard.ledOff(4); } // LED3 control and mode selection client.println("

Waveguide position 2: Please check afterwards the status of position in the above table"); //client.println(""); if (LED_status3) { myBoard.ledOn(3); delay(3000); myBoard.ledOff(3); delay(3000); } else { myBoard.ledOff(3); } // LED2 control and mode selection client.println("

Room Heater: "); client.println(""); if (LED_status2) { myBoard.ledOn(2); client.println("

Status: ON"); } else { myBoard.ledOff(2); client.println("

Status: OFF"); } client.println("

"); client.println("
"); client.println(""); client.println(""); HTTP_req = ""; break; } if (c == '\n') { currentLineIsBlank = true; } else if (c != '\r') { currentLineIsBlank = false; } } } client.stop(); //Serial.println("client disconnected"); } }