This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projekty:projektsystemupomiarowokontrolnegonabaziearduino [2025/05/07 12:31] – administrator | projekty:projektsystemupomiarowokontrolnegonabaziearduino [2025/05/16 15:30] (current) – administrator | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Jeżeli chcesz zacytować tą pracę to wejdź na zenodo.org:\\ | + | Jeżeli chcesz zacytować tą pracę to użyj indetyfikatora DOI:\\ |
| - | [[https:// | + | Ostrowski, K. (2025). Projekt systemu pomiarowo-kontrolnego na bazie Arduino (Wersja 1). Zenodo. |
| - | **Projekt Systemu pomiarowo-kontrolnego | + | ======= Arduino: |
| ****\\ | ****\\ | ||
| **Kacper Ostrowski**\\ | **Kacper Ostrowski**\\ | ||
| Line 598: | Line 598: | ||
| ===== Wykaz załączników ===== | ===== Wykaz załączników ===== | ||
| - | - Kod dla platformy Arduino MEGA {{ : | ||
| - Skrypt bazy danych oraz dane które system zebrał {{ : | - Skrypt bazy danych oraz dane które system zebrał {{ : | ||
| + | - Kod dla platformy Arduino MEGA | ||
| + | <code cpp arduino.ino> | ||
| + | #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); | ||
| + | // | ||
| + | |||
| + | // | ||
| + | //while (!Serial) { | ||
| + | // ; // wait for serial port to connect. Needed for native USB port only | ||
| + | //} | ||
| + | |||
| + | Ethernet.begin(mac, | ||
| + | server.begin(); | ||
| + | // | ||
| + | // | ||
| + | |||
| + | } | ||
| + | |||
| + | 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/ | ||
| + | // | ||
| + | |||
| + | 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, | ||
| + | // | ||
| + | // | ||
| + | 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) { | ||
| + | // | ||
| + | bool currentLineIsBlank = true; | ||
| + | while (client.connected()) { | ||
| + | // | ||
| + | if (client.available()) { | ||
| + | // | ||
| + | char c = client.read(); | ||
| + | // | ||
| + | HTTP_req += c; | ||
| + | if (c == ' | ||
| + | // | ||
| + | if (HTTP_req.indexOf(" | ||
| + | if (HTTP_req.indexOf(" | ||
| + | if (HTTP_req.indexOf(" | ||
| + | if (HTTP_req.indexOf(" | ||
| + | if (HTTP_req.indexOf(" | ||
| + | if (HTTP_req.indexOf(" | ||
| + | |||
| + | client.println(F(" | ||
| + | client.println(" | ||
| + | client.println(" | ||
| + | // | ||
| + | client.println(); | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | // client.println("< | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println(" | ||
| + | // client.println("</ | ||
| + | client.println("</ | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | |||
| + | client.println("< | ||
| + | client.println("< | ||
| + | |||
| + | client.println("< | ||
| + | client.println("</ | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | client.print("< | ||
| + | client.print(digitalRead(22)); | ||
| + | client.println("</ | ||
| + | client.print("< | ||
| + | client.print(digitalRead(24)); | ||
| + | client.println("</ | ||
| + | client.print("< | ||
| + | client.print(digitalRead(26)); | ||
| + | client.println("</ | ||
| + | client.print("< | ||
| + | client.print(digitalRead(28)); | ||
| + | client.println("</ | ||
| + | client.print("< | ||
| + | client.print(digitalRead(30)); | ||
| + | client.println("</ | ||
| + | client.println("</ | ||
| + | client.println("< | ||
| + | client.println(" | ||
| + | client.println("< | ||
| + | | ||
| + | // LED4 control and mode selection | ||
| + | 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("< | ||
| + | // | ||
| + | |||
| + | | ||
| + | if (LED_status3) { | ||
| + | myBoard.ledOn(3); | ||
| + | delay(3000); | ||
| + | myBoard.ledOff(3); | ||
| + | delay(3000); | ||
| + | } else { | ||
| + | myBoard.ledOff(3); | ||
| + | } | ||
| + | |||
| + | // LED2 control and mode selection | ||
| + | client.println("< | ||
| + | client.println("< | ||
| + | |||
| + | |||
| + | if (LED_status2) { | ||
| + | myBoard.ledOn(2); | ||
| + | client.println("< | ||
| + | } else { | ||
| + | myBoard.ledOff(2); | ||
| + | client.println("< | ||
| + | } | ||
| + | |||
| + | client.println("</ | ||
| + | client.println("</ | ||
| + | client.println("</ | ||
| + | client.println("</ | ||
| + | | ||
| + | HTTP_req = ""; | ||
| + | break; | ||
| + | } | ||
| + | if (c == ' | ||
| + | currentLineIsBlank = true; | ||
| + | } else if (c != ' | ||
| + | currentLineIsBlank = false; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | client.stop(); | ||
| + | |||
| + | // | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||