Professional Documents
Culture Documents
RM 191 - TUTUNARU - VLADINA - Lucrarea de Laborator Nr. 1
RM 191 - TUTUNARU - VLADINA - Lucrarea de Laborator Nr. 1
al Republicii Moldova
RAPORT
despre lucrarea de laborator nr. 1
Chișinău – 2022
SARCINA TEHNICA:
Ghidarea sistemelor robotice in spatii de orientare Wi-Fi (ESP8266 +
RSSI);
HARDWARE NECESAR :
SOFTWARE NERCESAR:
SPECIFICATII:
● ESP8266 CP2102 NodeMCU LUA ESP-12E WIFI Serial Wireless Module
● Built-in Micro-USB, with flash and reset switches, easy to program
● Full I/O port and Wireless 802.11 supported, direct download no need to reset
● Arduino compatible works great with the latest Arduino IDE/Mongoose IoT/Micro python
CONECTARE LA CIRCUIT:
COD:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
void setup() {
Serial.begin(9600);
delay(100);
pinMode(D4, OUTPUT);
Serial.println("Connecting to ");
Serial.println(ssid);
server.on("/", handle_OnConnect);
server.on("/ledon", handle_ledon);
server.on("/ledoff", handle_ledoff);
server.onNotFound(handle_NotFound);
server.begin();
Serial.println("HTTP Server Started");
}
void loop() {
server.handleClient();
if(LEDstatus)
{
digitalWrite(D4, HIGH);}
else
{
digitalWrite(D4, LOW);}
}
void handle_OnConnect() {
LEDstatus = LOW;
Serial.println("LED: OFF");
server.send(200, "text/html", updateWebpage(LEDstatus));
}
void handle_ledon() {
LEDstatus = HIGH;
Serial.println("LED: ON");
server.send(200, "text/html", updateWebpage(LEDstatus));
}
void handle_ledoff() {
LEDstatus = LOW;
Serial.println("LED: OFF");
server.send(200, "text/html", updateWebpage(LEDstatus));
}
void handle_NotFound(){
server.send(404, "text/plain", "Not found");
}
if(LEDstatus){
ptr +="<p>BLUE LED: ON</p><a class=\"button button-off\" href=\"/ledoff\">OFF</a>\n";
}else{
ptr +="<p>BLUE LED: OFF</p><a class=\"button button-on\" href=\"/ledon\">ON</a>\n";
}
ptr +="</body>\n";
ptr +="</html>\n";
return ptr;
}
FUNCȚIONARE ȘI RESULTARE: