Zalo bán hàng : 0981 949 841
Email: sales@dientubachviet.com
Kít thu phát Wifi ESP8266 NodeMCU Oled 0.96inch là sự kết hợp giữa Module Wifi ESP8266 NodeMCU và Oled 0.96 inch, có thiết kế nhỏ gọn, màn hình Oled hiển thị chuyên nghiệp và thiết kế tối ưu cho độ bền, độ ổn định cao.
Chip nạp và giao tiếp : CP2102
Kit thu phát Wifi ESP8266 Oled D-duino có thiết kế nhỏ gọn, được tích hợp màn hình Oled 0.96 inch hiển thị chuyên nghiệp, IC nạp và giao tiếp UART tốc độ cao chuyên dụng Silicon Labs CP2102
———————CODE THAM KHẢO———————
/* Cắm cable kết nối * Mở Device Manger để xem port * Vào Tools -> Board -> NodeMCU 1.0 (ESP-12E Module) * Vào Tools -> Port -> Chọn Port kết nối. * Nạp code. */ #include <ESP8266WiFi.h> #include <Wire.h> #include <EEPROM.h> #include "SSD1306.h" #include "SH1106.h" extern "C" { #include "user_interface.h" } /*===== SETTINGS =====*/ /* create display(Adr, SDA-pin, SCL-pin) */ SSD1306 display(0x3c, 5, 4); // GPIO 5 = D1, GPIO 4 = D2 //SH1106 display(0x3c, 5, 4); /* select the button for your board */ #define btn D3 // GPIO 0 = FLASH BUTTON #define maxCh 13 // max Channel -> US = 11, EU = 13, Japan = 14 #define ledPin 2 // led pin ( 2 = built-in LED) #define packetRate 5 // min. packets before it gets recognized as an attack #define flipDisplay true /* Display settings */ #define minRow 0 /* default = 0 */ #define maxRow 127 /* default = 127 */ #define minLine 0 /* default = 0 */ #define maxLine 63 /* default = 63 */ /* render settings */ #define Row1 0 #define Row2 30 #define Row3 35 #define Row4 80 #define Row5 85 #define Row6 125 #define LineText 0 #define Line 12 #define LineVal 47 //===== Run-Time variables =====// unsigned long prevTime = 0; unsigned long curTime = 0; unsigned long pkts = 0; unsigned long no_deauths = 0; unsigned long deauths = 0; int curChannel = 1; unsigned long maxVal = 0; double multiplicator = 0.0; bool canBtnPress = true; unsigned int val[128]; void sniffer(uint8_t *buf, uint16_t len) { pkts++; if (buf[12] == 0xA0 || buf[12] == 0xC0) { deauths++; } } void getMultiplicator() { maxVal = 1; for (int i = 0; i < maxRow; i++) { if (val[i] > maxVal) maxVal = val[i]; } if (maxVal > LineVal) multiplicator = (double)LineVal / (double)maxVal; else multiplicator = 1; } const char* ssid = "Linh Kien Dien Tu NSHOP";// wifi muốn kết nối------------------------------------------ const char* password = "dientuchatluong"; //int ledPin = 13; // GPIO13 WiFiServer server(80); void setup() { display.init(); if (flipDisplay) display.flipScreenVertically(); /* show start screen */ display.clear(); display.setFont(ArialMT_Plain_16); display.drawString(0, 0, "DienTu"); display.drawString(0, 16, " NSHOP "); display.setFont(ArialMT_Plain_10); display.drawString(0, 40, "1 Bui Xuan Phai"); display.drawString(0, 50, "Tay Thanh, Tan Phu"); display.display(); delay(2500); display.clear(); Serial.begin(115200); delay(10); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.print("Use this URL to connect: "); Serial.print("http://"); Serial.print(WiFi.localIP()); Serial.println("/"); display.drawString(0, 20, "Connecting to: "); display.drawString(0, 30, (String)ssid); display.display(); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("new client"); while(!client.available()){ delay(1); } // Read the first line of the request String request = client.readStringUntil('r'); Serial.println(request); client.flush(); // Match the request int value = LOW; if (request.indexOf("/LED=ON") != -1) { digitalWrite(ledPin, HIGH); value = HIGH; } if (request.indexOf("/LED=OFF") != -1) { digitalWrite(ledPin, LOW); value = LOW; } // Set ledPin according to the request //digitalWrite(ledPin, value); // Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.print("Led pin is now: "); if(value == HIGH) { client.print("On"); } else { client.print("Off"); } client.println("<br><br>"); client.println("<a href="/LED=ON""><button>Turn On </button></a>"); client.println("<a href="/LED=OFF""><button>Turn Off </button></a><br />"); client.println("</html>"); delay(1); Serial.println("Client disonnected"); Serial.println(""); }