ESP8266WebServer.h - Installation & Troubleshooting Trang chủ » Thư Viện Esp8266webserver.h » ESP8266WebServer.h - Installation & Troubleshooting Có thể bạn quan tâm Thư Viện Esp8266wifi Thư Viện Esp8266wifi.h Thư Viện Eureka Thư Viện Evil Hunter Tycoon Thư Viện Excel Loading ESP8266WebServer.h Using Arduino IDE 1.x svedr January 10, 2017, 1:30pm 1 HI! I can not find library ESP8266WebServer.h I usually get zip file for library from GITHUB, but for ESP8266WebServer I can not find ZIP file. can you help me? pert January 10, 2017, 2:10pm 2 The ESP8266WebServer library is part of the esp8266 Arduino boards platform: GitHub - esp8266/Arduino: ESP8266 core for Arduino ESP8266 core for Arduino. Contribute to esp8266/Arduino development by creating an account on GitHub. So you only need to install that core via the Arduino IDE Boards Manager, following the instructions here: https://github.com/esp8266/Arduino#installing-with-boards-manager That will also install the "ESP8266WebServer" library. Note that library is written to run on the ESP8266 (not on a standard Arduino board communicating with an ESP8266 via serial) and is only available when you have one of the boards of the esp8266 platform selected in the Arduino IDE Tools > Board menu. svedr January 10, 2017, 5:13pm 3 :o hmmm With ethernet shield i have no problem... Wifi shield is programmed differently? Not directly on Arduino ? I have this wifi shield WIFI SHIELD I want to do a web server for reading temperature from ds18b20 sensors. ( With ehternet shield work fine ) Thankyou fpr help sterretje January 10, 2017, 6:53pm 4 GitHub - bportaluri/WiFiEsp: Arduino WiFi library for ESP8266 modules Arduino WiFi library for ESP8266 modules. Contribute to bportaluri/WiFiEsp development by creating an account on GitHub. pert January 10, 2017, 9:58pm 5 You need to understand there are two ways of using an ESP8266 with Arduino: Programming the ESP8266 directly using the esp8266 core. Typically this will be done with a board such as WeMos D1 Mini, Adafruit Huzzah ESP8266, or NodeMCU. Technically it would be possible to use your shield in this way by connecting an FTDI breakout or cable to the "Debug Port" pins but that's not the typical usage of that shield. Controlling the ESP8266, which is running a firmware such as AT, via serial commands from a standard Arduino board(Uno, Mega, Leonardo, etc.). In this usage you will be programming the board that the shield is plugged into, rather than the ESP8266, and thus should use the hardware package and libraries written for that board. Therefore since you're likely using the ESP8266 in the latter manner the ESP8266WebServer library and the esp8266 core won't work for you. For that purpose I recommend the WiFiEsp library suggested by sterretje. svedr: With ethernet shield i have no problem... That's because the Ethernet library is written for use with the Ethernet shield, the ESP8266WebServer is not written for use with your ESP8266 shield as you are using it. svedr: Wifi shield is programmed differently? The shield comes preprogrammed with the AT firmware. Unless you want to update that firmware you won't be programming it at all. Instead you are programming the board that the shield is on top of. svedr January 12, 2017, 6:45am 6 Thank you for the explanation... Do you have maybe an example code for web server for my WifiShield ? Regards sterretje January 12, 2017, 6:59am 7 The library that I linked comes with examples svedr January 16, 2017, 8:13am 8 Ok.. i see link... I try "scan network" with arduino mega, change rx,tx to SoftwareSerial Serial1(10, 11); // RX, TX But no luck... In serial monitor : TIMEOUT WIFI SHIELD NOT PRESENT Any idea what is wrong = Wifi shield is connected on Arduino Mega ( like ethernet shield) Regards pert January 16, 2017, 8:59am 9 svedr: change rx,tx to SoftwareSerial Serial1(10, 11); // RX, TX Please explain what you mean by that. Unless you have connected it differently, your shield communicates with the ESP8266 via pins 0 and 1 (hardware serial's Serial). The WebServer example included with that library assumes that if you're using an Arduino Mega you will have the ESP8266 connected to pins 18 and 19(hardware serial's Serial1). The sketch can be easily modified to other wiring configurations. svedr January 16, 2017, 12:50pm 10 The code used pin 6 and 7 in softwareserial. I read that Arduino Mega does not work on these pins so I changed to 10 and 11 code example /* WiFiEsp example: ScanNetworks This example prints the Wifi shield's MAC address, and scans for available Wifi networks using the Wifi shield. Every ten seconds, it scans again. It doesn't actually connect to any network, so no encryption scheme is specified. For more details see: http://yaab-arduino.blogspot.com/p/wifiesp.html */ #include "WiFiEsp.h" // Emulate Serial1 on pins 6/7 if not present #ifndef HAVE_HWSERIAL1 #include "SoftwareSerial.h" SoftwareSerial Serial1(6, 7); // RX, TX #endif void setup() { // initialize serial for debugging Serial.begin(115200); // initialize serial for ESP module Serial1.begin(9600); // initialize ESP module WiFi.init(&Serial1); // check for the presence of the shield if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); // don't continue while (true); } // Print WiFi MAC address printMacAddress(); } void loop() { // scan for existing networks Serial.println(); Serial.println("Scanning available networks..."); listNetworks(); delay(10000); } void printMacAddress() { // get your MAC address byte mac[6]; WiFi.macAddress(mac); // print MAC address char buf[20]; sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); Serial.print("MAC address: "); Serial.println(buf); } void listNetworks() { // scan for nearby networks int numSsid = WiFi.scanNetworks(); if (numSsid == -1) { Serial.println("Couldn't get a wifi connection"); while (true); } // print the list of networks seen Serial.print("Number of available networks:"); Serial.println(numSsid); // print the network number and name for each network found for (int thisNet = 0; thisNet < numSsid; thisNet++) { Serial.print(thisNet); Serial.print(") "); Serial.print(WiFi.SSID(thisNet)); Serial.print("\tSignal: "); Serial.print(WiFi.RSSI(thisNet)); Serial.print(" dBm"); Serial.print("\tEncryption: "); printEncryptionType(WiFi.encryptionType(thisNet)); } } void printEncryptionType(int thisType) { // read the encryption type and print out the name switch (thisType) { case ENC_TYPE_WEP: Serial.print("WEP"); break; case ENC_TYPE_WPA_PSK: Serial.print("WPA_PSK"); break; case ENC_TYPE_WPA2_PSK: Serial.print("WPA2_PSK"); break; case ENC_TYPE_WPA_WPA2_PSK: Serial.print("WPA_WPA2_PSK"); break; case ENC_TYPE_NONE: Serial.print("None"); break; } Serial.println(); } My wifi shield is mounted on arduino mega. What should I change in code that will work ? pert January 16, 2017, 1:04pm 11 svedr: The code used pin 6 and 7 in softwareserial. I read that Arduino Mega does not work on these pins so I changed to 10 and 11 That's correct but the problem is two things. First of all the way the sketch is written: #ifndef HAVE_HWSERIAL1 #include "SoftwareSerial.h" SoftwareSerial Serial1(6, 7); // RX, TX #endif Means that since the Mega has multiple hardware serial ports, HAVE_HWSERIAL1 is defined, and thus the lines dealing with SoftwareSerial will never be run. Instead hardware serial Serial1 will be used. Second, as I said, on the Mega hardware serial Serial1 is pins 18 and 19 but unless you have changed the wiring your shield is not connected to pins 18 and 19, it's connected to pins 0 and 1. So ignore the SoftwareSerial stuff and change every reference to Serial1 in that sketch to Serial. Next problem, your shield runs at 115200 baud by default but the sketch is written for 9600 baud so unless you 've changed the baud rate of your shield you need to change the sketch to communicate at 115200 baud. So here's the updated sketch: /* WiFiEsp example: ScanNetworks This example prints the Wifi shield's MAC address, and scans for available Wifi networks using the Wifi shield. Every ten seconds, it scans again. It doesn't actually connect to any network, so no encryption scheme is specified. For more details see: http://yaab-arduino.blogspot.com/p/wifiesp.html */ #include "WiFiEsp.h" // Emulate Serial1 on pins 6/7 if not present #ifndef HAVE_HWSERIAL1 #include "SoftwareSerial.h" SoftwareSerial Serial1(6, 7); // RX, TX #endif void setup() { // initialize serial for debugging // Serial.begin(115200); // initialize serial for ESP module Serial.begin(9600); // initialize ESP module WiFi.init(&Serial); // check for the presence of the shield if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); // don't continue while (true); } // Print WiFi MAC address printMacAddress(); } void loop() { // scan for existing networks Serial.println(); Serial.println("Scanning available networks..."); listNetworks(); delay(10000); } void printMacAddress() { // get your MAC address byte mac[6]; WiFi.macAddress(mac); // print MAC address char buf[20]; sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); Serial.print("MAC address: "); Serial.println(buf); } void listNetworks() { // scan for nearby networks int numSsid = WiFi.scanNetworks(); if (numSsid == -1) { Serial.println("Couldn't get a wifi connection"); while (true); } // print the list of networks seen Serial.print("Number of available networks:"); Serial.println(numSsid); // print the network number and name for each network found for (int thisNet = 0; thisNet < numSsid; thisNet++) { Serial.print(thisNet); Serial.print(") "); Serial.print(WiFi.SSID(thisNet)); Serial.print("\tSignal: "); Serial.print(WiFi.RSSI(thisNet)); Serial.print(" dBm"); Serial.print("\tEncryption: "); printEncryptionType(WiFi.encryptionType(thisNet)); } } void printEncryptionType(int thisType) { // read the encryption type and print out the name switch (thisType) { case ENC_TYPE_WEP: Serial.print("WEP"); break; case ENC_TYPE_WPA_PSK: Serial.print("WPA_PSK"); break; case ENC_TYPE_WPA2_PSK: Serial.print("WPA2_PSK"); break; case ENC_TYPE_WPA_WPA2_PSK: Serial.print("WPA_WPA2_PSK"); break; case ENC_TYPE_NONE: Serial.print("None"); break; } Serial.println(); } Now my experience with this library is that all the debug output interferes with communication with the ESP8266 since they are also sent via Serial and thus make the library not work. This is unfortunate because without debug output you are basically working blind until you can actually get network communication going. So give the sketch I provided a try as is just to make sure I'm not wrong about that and if it doesn't work come back and I'll instruct you on how to disable the debug output. svedr January 16, 2017, 7:01pm 12 I try with arduino uno, arduino mega....diferent pins, hw, serial....nothing work. Time out..... in serial monitor.... Can write someone exactly how to connect and attach code, please? svedr January 17, 2017, 4:33pm 13 I found manual for wifi shield. My phone find this Wifi Shield ?? :o :o :o But page for config is not available.... Any help ? Manual : Manual pert January 17, 2017, 4:38pm 14 That's a completely different shield. The instructions in that manual won't apply to your shield. I haven't forgotten about you but I had a work deadline so I haven't been able to finish my response to your last post in this thread. I need to get a few hours sleep before I have to get up and go back to work but it's on my to do list still. svedr January 17, 2017, 5:22pm 15 OK.... go to sleep then help me please.... Again.... here is photo of my shield: ESP8266 ESP-12 ARDUINO WIFI SHIELD I spent three days in forums and blogs.... Again my resoults. ardiono mega , uno and wifi shield .... nothing, a huge variety of binding and sketch USB-TTL 3v, tx,rx,gnd... in putty see only this: (115200 baudrate ) l`rl-n't use rtc mem data rl--rl-- Ai-Thinker Technology Co.,Ltd. ready AT command not work I found wifi network on my mobile with name AI-THINKER_D483FD Found also some manual, which describes a procedure settup on 192.168.4.1 but the site is not accessible I'm very grateful for help...... sterretje January 18, 2017, 2:20am 16 @pert is far more a specialist in this than I am (I don't have the shield, he seems to have / had one). Dig a bit on the web and search for elecshop.ml; it seems some people have succeeded to use it on an Uno. This seems to be the latest. Maybe it helps. svedr January 18, 2017, 11:31am 17 HI! Finally, I have some success. i have programmed wifi modul directly from the Arduino Sotware. i use usb-ttl . i I have chosen NodeMCU ESP-12E module ) example: advancewebserver and work ! :o :o :o Does this mean that they do not need arduino ??? Work independently ??? Can I connect sensor ds18b20 like on arduino and craate my home webserver with temperature ?? Why then has the base for Arduino ? Better cut it ? Still not clear to me why not work mounted on arduino and and why would I use Arduino if i do not need.... For begginer like me is this big shock. First i finnaly create arduino+ethernet shield temperature webserver, but when I want to do the same with arduino+wifishield is completely different story. >:( pert January 18, 2017, 1:08pm 18 svedr: Finally, I have some success. Glad to hear! svedr: Does this mean that they do not need arduino ??? Work independently ??? Sure, you can program the ESP8266 directly using the esp8266 Arduino core (as I pointed out in reply #1) and not use the Mega at all. Obviously your shield is not intended for that purpose but there's no reason you can't use it that way. Typically you would use a board such as WeMos D1 Mini, NodeMCU, or Adafruit Huzzah, etc. for that usage of ESP8266. svedr: Can I connect sensor ds18b20 like on arduino and craate my home webserver with temperature ?? I don't see why not. svedr: Why then has the base for Arduino ? Better cut it ? Still not clear to me why not work mounted on arduino and and why would I use Arduino if i do not need.... There are some significant benefits of using the ESP8266 alone. The processor runs at 5-10X faster than the Mega. It has 16X the flash memory. It has 10X the SRAM. Connecting an ESP8266 to an AVR is kind of like towing a sports car with a bicycle. However, there are some differences to the ESP8266 that may be a disadvantage also. The ESP8266 runs at 3.3V, which may make it a bit more difficult to interface with 5V devices. Some libraries and example sketches are written specifically for the AVR architecture of the standard Arduino boards and are not compatible with ESP8266. There are some differences in programming the ESP8266 and the documentation of the esp8266 core is not quite so good as the Arduino AVR Boards core (though it has gotten much better recently). The WiFi stack is running in the background on the ESP8266 so that needs to be continually serviced. In fact there is a watchdog timer that will cause the ESP8266 to reset if you write any blocking code (though you can safely use delay()) so there is something to be said for letting the ESP8266 just do WiFi and do everything else on a connected AVR. The Mega (or even the smaller boards such as Uno) have more I/O pins than the ESP8266. The ESP8266 GPIO has an absolute maximum of 12mA, on the AVR boards this is 40mA. So I'm not really sure which option is more beginner friendly. Programming the ESP8266 is significantly more difficult than AVR boards. However, for some reason some people seem to have a huge difficulty understanding how communication between the AVR and ESP8266 via serial works. svedr January 18, 2017, 3:46pm 19 Pert, thankyou for your help. I try change my code for arduino+ethernet server for esp8288. I thing i have enough pin. For finish, this wifi shield is realy accidental version. For upload code is needed dip switch 1 and 2 ON, for working 1 and 2 OFF. For write firmware the third option, I forgot. confusion is because I have two wifi shield and not having the same mounted dip switch, one is turned upside down second up. I hope ,that they are other models more user-friendly Regards!! Related topics Topic Replies Views Activity ESP8266 library Project Guidance 18 3686 May 5, 2021 ESP32 .h files missing from the IDE IDE 1.x 7 2260 May 5, 2021 I cant seem to upload the ESP8266 library. IDE 1.x 5 2768 May 5, 2021 DNSServer.h ? Programming Questions 2 10827 May 5, 2021 Can't find libraries for ESP8266 IDE 1.x 5 3211 May 5, 2021 Từ khóa » Thư Viện Esp8266webserver.h Phần 2: Kết Nối Internet → ESP8266 Làm Web Server - Ohtech Master - GitHub Esp8266/ESPWebServer: HTTP Server Library For ESP8266 ... - GitHub ESP8266 Làm Web Server - Lập Trình Arduino Kết Nối Wifi - OhStem Hướng Dẫn ESP8266 #3: Sử Dụng Thư Viện WiFi Manager - MTE Cài đặt Thư Viện - Lập Trình ESP8266 Arduino ESP8266: Thư Viện WiFi Manager - Quản Lý Kết Nối Wifi [IoT] Bài 5: Tạo WebServer Với ESP8266 Và Lập Trình Cho Esp8266 ... ESP8266WiFi Library - ESP8266 Arduino Core Documentation Sử Dụng Thư Viện WiFi Manager Smart Config - VLOGS CHIPKOOL Sử Dụng Thư Viện WiFi Manager Smart Config - ECHIPKOOL SHOP Cài đặt Kết Nối Wifi Cho ESP8266 - Viblo [Phần 2] Lập Trình Trực Tiếp Trên ESP8266 Bật/Tắt LED Hướng Dẫn điều Khiển động Cơ Bằng ESP8266