ESP8266-12F (Trouble Getting Started) - Page 1
Forum section: electronics / general

author: metrologist
author_rank: Super Contributor
timestamp: April 04, 2018, 05:43:02 pm
content: To program this bare module, I'm using a failed Nano board with a CH340G USB-TTL chip. The AVR got taken out so I removed that chip. The board passes a serial loopback test.The Arduino IDE is set up for this board, I think. I'm just not sure if I should select a generic 8266 or some other particular board?One puzzlement, when compiling Blink, the IDE reports the sketch size ~200,000 bytes. That's huge for a few lines of code?I connect Rx/Tx lines from the module direct to the Nano pins. I use an external power supply. The module only draws 30-60mA.I've connected:EN to VCC via 10kGPIO15 to GND via 10kGPIO0 to GNDI also tried connecting GPIO2 to VCC.When I try to upload, the Tx LED blinks slow and then I get a few error messages, something like (from memory):warning: espcomm_sync failederror: espcomm_open failedI'm not sure what to look for next? I've also read some conflicting info about if some pins need pull-down vs. pull-up. Does RST need a pull-up?

author: mdijkens
author_rank: Regular Contributor
timestamp: April 04, 2018, 06:47:01 pm
content: Sounds like not enough powerThe ESP12F consumes on average 75mA but the 1ms spikes are above 300mAAt least you need a big (>=220uF) cap right between the VCC and GNDAlso check that TX>RX and RX>TX

author: metrologist
author_rank: Super Contributor
timestamp: April 04, 2018, 07:35:17 pm
content: I tried swapping the Rx/Tx pins with same result.The power supply is a RuiDang step down converter and should be able to supply many amps. I think I'll solder a cap between the leads anyway.I've read some reports of stability problems (i.e., programs 1 out of 5 tries) if the resistors are more than ~5k.

author: Naguissa
author_rank: Regular Contributor
timestamp: April 05, 2018, 06:59:55 am
content: I don't fully understand the connections. Nano is 5V and ESP needs 3.3VAbout flash mode, you can check it here (the "F" model adds some extra pins but connections are the same):https://translate.google.es/translate?sl=es&tl=en&js=y&prev=_t&hl=es&ie=UTF-8&u=https%3A%2F%2Fwww.foroelectro.net%2Felectronica-digital-microcontroladores-f8%2Fpinout-y-conexion-normal-y-modo-flash-para-modelos-t130-s10.html%23p308&edit-text=Also check power supply and, if you are using the nano as bridge, check if nano's sketch has same baud rate as PC's programmer.

author: Nusa
author_rank: Super Contributor
timestamp: April 05, 2018, 08:09:26 am
content: Make sure the power supply going to VCC is 3.3V! The I/O pins areunofficiallytolerant of 5V, but that doesn't extend to VCC itself! If you've been using 5V its possible you've already killed it. You may get lucky.

author: TJ232
author_rank: Frequent Contributor
timestamp: April 06, 2018, 05:25:16 am
content: Take a look atesp8266-projects.com.You will find there a lot about, from theCBDB ghetto style programmerto more complex ESP8266 boards likeBLMSornEXTEVO,MPRSx8 Home Automation,MPDMv7.5 MAINS AC Dimmer,etc.

author: metrologist
author_rank: Super Contributor
timestamp: April 06, 2018, 01:19:29 pm
content: OK, I did not apply more than 3.3V and am using an external supply. I tried a USB-serial CH340G based converter with same behaviour. I think I'll take off the resistors and verify connections as presented on the foroelectro forum linked above.

author: mdijkens
author_rank: Regular Contributor
timestamp: April 06, 2018, 03:07:45 pm
content: Quote from: metrologist on April 06, 2018, 01:19:29 pmHave you tried adding a 220uF or more cap close to VCC & GND ?The fact you use an external power supply doesn't take away the need for a big cap

author: Naguissa
author_rank: Regular Contributor
timestamp: April 06, 2018, 11:48:48 pm
content: Quote from: metrologist on April 06, 2018, 01:19:29 pmStill, RX and TX are being driven at 3.3 or 5V?

author: westfw
author_rank: Super Contributor
timestamp: April 07, 2018, 12:18:45 am
content: The ESP8266 needs some relatively complicated boot sequence involving GPIO pins beyond Rx/Tx/Reset.Seehttps://github.com/espressif/esptool/wiki/ESP8266-Boot-Mode-Selection

author: metrologist
author_rank: Super Contributor
timestamp: April 07, 2018, 12:58:35 am
content: If it's not hardware, what about software?I read one post about baud rate. 115200What about clock, memory, spiffs, and the rest that changes in the footer of the IDE when selecting various esp boards. I think mine is 80M 4M, which is not the generic 8266...maybe my config is not listed?Also, why is blink 246kB? Aside from setup and loop, that's 5 lines

author: mdijkens
author_rank: Regular Contributor
timestamp: April 07, 2018, 06:17:48 am
content: It is 'normal' that the sketch has that size. There are lots of libs going in there alsoSo use:3.3V power220uF or more cap3.3V RX/TX (GPIO3/GPIO1)EN to VCCGPIO0 and GPIO15 to GNDIn AIDE use:Generic ESP8266Flashmode QIOIwIP 1.4 prebuiltreset ckcrystal 26MHzFlash 40MHzSpeed 115kbps (very rare somteimes 57600)

author: westfw
author_rank: Super Contributor
timestamp: April 07, 2018, 09:12:06 am
content: QuoteI believe the "ROM" of the ESP has only the radio driver support. that means that each sketch contains the entire LWIP TCP/IP stack, 802.11 stuff, and a mini-OS to wrap it all...Here's some of the top memory consumers (the "interesting" ones) from "nm":4020e0cc 00000281 T ip4_input402091ec 00000285 t dns_recv40228a60 0000029a T register_chipv6_phy_init_param4022da24 000002a7 T pm_onBcnRx40220294 000002ae T get_flash_bin_len4021e71c 000002da T umm_info4020680c 000002dc T _vfiprintf_r402094c8 000002e1 T dns_gethostbyname_addrtype40225094 000002eb T ram_set_channel_freq402083b8 000002ee T tcp_slowtmr4022ab34 000002fa T tx_pwctrl_cal4020f688 00000300 T rijndaelKeySetupEnc402334dc 00000317 t handle_dhcp402166c4 00000386 T ieee80211_sta_new_state402026a8 000003b3 T _printf_i4021a47c 000003cf T wpa_receive4021a8f0 000003fa T __wpa_send_eapol4020f1c4 00000416 T rijndaelEncrypt40227f7c 00000418 T phy_bb_rx_cfg4020cab8 00000463 t dhcp_recv4020ba18 00000467 T tcp_output4022925c 00000470 T register_chipv6_phy402106c0 000004b1 T hostap_input40202a5c 000004bc W _scanf_float40212798 000004f6 T ieee80211_parse_beacon4020209c 00000504 W _printf_float40213f48 00000594 T ieee80211_send_mgmt402097e8 000005a3 t tcp_receive40209ec0 00000a57 T tcp_input40204200 00000cd2 T _dtoa_r4020314c 00000d76 T _strtod_rSince even a "small" ESP system (Wimos D1 "lite") has 1MB of flash, I doubt that anyone is working too much on cutting down the size of sketches...Hmm. pinMode() is unexpectedly big. It looks pretty icky...

author: TJ232
author_rank: Frequent Contributor
timestamp: April 07, 2018, 09:16:10 am
content: This is probably the simplest ESP8266 + CH340 adapter/interface board:More details, schematics, PCB, etc here:ESP8266 CBDB devboard description and schematics

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: April 07, 2018, 09:24:10 am
content: Slightly off-topic:May I ask what the implementation of the ESP module looks like? I am doing a lot of prototyping with these and since I am more interested in getting things up and running I opted for using the Wemos D1 mini clones. They do not cost much more than the bare module and I am using the pin headers to keep the "brain of the operation" easily exchangeable. That uses up some more space of course and does not look too fancy. However, I can have several of them and just plug and play my new firmware version.

author: mdijkens
author_rank: Regular Contributor
timestamp: April 07, 2018, 12:25:00 pm
content: I can only answer for myself and I am a very happy user of Wemos and Nodemcu boards tooBut in the end most projects end up in a box running on a simple battery and then deep sleep and power consumption is key!All the bells and whistles on the wemos and nodemcu boards consume a lot of power (only the cp2102 or ch304 alone take several mA)So therefore I designed my own board (see here) that only consumes 18uA when in deep sleep and lets my project run for over a year on a single 18650 cell

author: metrologist
author_rank: Super Contributor
timestamp: April 12, 2018, 05:31:35 pm
content: That's cool. This is perf board I was laying out. I was just going to hot goo the esp and run jumpers to pin headers.

author: Nusa
author_rank: Super Contributor
timestamp: April 12, 2018, 08:42:51 pm
content: You need a pull-up on the reset line.

author: metrologist
author_rank: Super Contributor
timestamp: April 14, 2018, 03:02:55 pm
content: Quote from: mdijkens on April 07, 2018, 06:17:48 amI do not have prebuilt, rather it's "compile from source" or "Bandwidth". It was set to "v2 Lower Memory"

author: metrologist
author_rank: Super Contributor
timestamp: April 20, 2018, 08:15:06 pm
content: Tried a number of board settings and all the same synch failed result.Added 4k7 pullup to rst line and 220 uF cap across power, sometimes it boots with LED on and RX line active. It is spewing out data, but no baud rate will decode it properly. I tried moving D00 to gnd or 3.3V. I'll try the second module and if the same, I'll remove these devices from my reality, and may look at esp32.

author: Naguissa
author_rank: Regular Contributor
timestamp: April 21, 2018, 04:37:57 am
content: It's strange, but somtimes the default baud rate is weird, like 75k.One test coulb be trying one Linux kivecd, to discard the serial driver.

author: mdijkens
author_rank: Regular Contributor
timestamp: April 21, 2018, 02:22:52 pm
content: Yep, 74880 baud is the 'default' to monitor serialWhen booted withCH_EN = HighGPIO15 = LowGPIO2 = High (just to be sure)GPIO0 = HighYou should see a mode(3,6) or mode(3,7) bootWithGPIO0 = LowYou should see a mode(1,6) or mode(1,7) boot and able to flash a new program (start with low upload-baudrate just to be sure)

author: metrologist
author_rank: Super Contributor
timestamp: April 22, 2018, 05:07:18 pm
content: I tried second module and same same, except when setting GPIO0 high I can read the data sent out:Fatal exception (28):epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000Fatal exception (28):epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000...Oh wait, it's uploading now.It's blinking. Yay!

author: metrologist
author_rank: Super Contributor
timestamp: April 26, 2018, 02:26:03 am
content: Folks,TL;DR does ESP remember wifi credentials after removing them from sketch and reloading?I decided to try the FSBrowser example. This required me to enter my SSID and password for my local wifi connection. It will serve a web page with wonderful data plots, but I wanted to avoid my network and have ESP serve the page through wifi as an access point.I tried modifying the WiFiAccessPoint example, basically just replace the connecting to my home SSID with launching AP and then the server...Now, I got my phone to connect to the ESP AP and it loaded the wonderful web page.Then I noticed the serial monitor spit out data that ESP connected to my home SSID. I was getting the web page on my phone via AP and then I tried a computer on my network and it was there too!!!How is that possible? I removed my SSID and PW from the sketch. DOES ESP remember these settings?After a couple minutes, it seems ESP crashes and it started pumping out rst messages, but eventually recovered...Code:ets Jan 8 2013,rst cause:4, boot mode:(3,6)wdt resetload 0x4010f000, len 1384, room 16tail 8chksum 0x2dcsum 0x2dv614f7c32~ldFS File: /edit.htm.gz, size: 4.02KBFS File: /favicon.ico, size: 1.12KBFS File: /graphs.js.gz, size: 1.92KBFS File: /index.htm, size: 3.63KBscandonestate: 0 -> 2 (b0)Configuring access point...AP IP address: 192.168.4.1Open http://esp8266fs.local/edit to see the file browserHTTP server startedstate: 2 -> 3 (0)state: 3 -> 5 (10)add 0aid 4cntconnected with HOME-SSID, channel 1dhcp client start...ip:192.168.1.70,mask:255.255.255.0,gw:192.168.1.254add 1aid 1station: fc:db:b3:49:d6:58 join, AID = 1handleFileRead: /handleFileRead: /handleFileRead: /graphs.jshandleFileRead: /favicon.icoCode:/*FSWebServer - Example WebServer with SPIFFS backend for esp8266Copyright (c) 2015 Hristo Gochkov. All rights reserved.This file is part of the ESP8266WebServer library for Arduino environment.This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAupload the contents of the data folder with MkSPIFFS Tool ("ESP8266 Sketch Data Upload" in Tools menu in Arduino IDE)or you can upload the contents of a folder if you CD in that folder and run the following command:for file in `ls -A1`; do curl -F "file=@$PWD/$file" esp8266fs.local/edit; doneaccess the sample web page at http://esp8266fs.localedit the page by going to http://esp8266fs.local/edit*/#include <ESP8266WiFi.h>#include <WiFiClient.h>#include <ESP8266WebServer.h>#include <ESP8266mDNS.h>#include <FS.h>#define DBG_OUTPUT_PORT Serial//(these are commented and are fake too, how does ESP know the credentials?)//const char* ssid = "HOME-SSID";//const char* password = "xxxxxxxxxxxxxxxxxx";//change to AP/* Set these to your desired credentials. */const char *ssid = "ESPap";const char *password = "password";const char* host = "esp8266fs";ESP8266WebServer server(80);//holds the current uploadFile fsUploadFile;//format bytesString formatBytes(size_t bytes){if (bytes < 1024){return String(bytes)+"B";} else if(bytes < (1024 * 1024)){return String(bytes/1024.0)+"KB";} else if(bytes < (1024 * 1024 * 1024)){return String(bytes/1024.0/1024.0)+"MB";} else {return String(bytes/1024.0/1024.0/1024.0)+"GB";}}String getContentType(String filename){if(server.hasArg("download")) return "application/octet-stream";else if(filename.endsWith(".htm")) return "text/html";else if(filename.endsWith(".html")) return "text/html";else if(filename.endsWith(".css")) return "text/css";else if(filename.endsWith(".js")) return "application/javascript";else if(filename.endsWith(".png")) return "image/png";else if(filename.endsWith(".gif")) return "image/gif";else if(filename.endsWith(".jpg")) return "image/jpeg";else if(filename.endsWith(".ico")) return "image/x-icon";else if(filename.endsWith(".xml")) return "text/xml";else if(filename.endsWith(".pdf")) return "application/x-pdf";else if(filename.endsWith(".zip")) return "application/x-zip";else if(filename.endsWith(".gz")) return "application/x-gzip";return "text/plain";}bool handleFileRead(String path){DBG_OUTPUT_PORT.println("handleFileRead: " + path);if(path.endsWith("/")) path += "index.htm";String contentType = getContentType(path);String pathWithGz = path + ".gz";if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){if(SPIFFS.exists(pathWithGz))path += ".gz";File file = SPIFFS.open(path, "r");server.streamFile(file, contentType);file.close();return true;}return false;}void handleFileUpload(){if(server.uri() != "/edit") return;HTTPUpload& upload = server.upload();if(upload.status == UPLOAD_FILE_START){String filename = upload.filename;if(!filename.startsWith("/")) filename = "/"+filename;DBG_OUTPUT_PORT.print("handleFileUpload Name: "); DBG_OUTPUT_PORT.println(filename);fsUploadFile = SPIFFS.open(filename, "w");filename = String();} else if(upload.status == UPLOAD_FILE_WRITE){//DBG_OUTPUT_PORT.print("handleFileUpload Data: "); DBG_OUTPUT_PORT.println(upload.currentSize);if(fsUploadFile)fsUploadFile.write(upload.buf, upload.currentSize);} else if(upload.status == UPLOAD_FILE_END){if(fsUploadFile)fsUploadFile.close();DBG_OUTPUT_PORT.print("handleFileUpload Size: "); DBG_OUTPUT_PORT.println(upload.totalSize);}}void handleFileDelete(){if(server.args() == 0) return server.send(500, "text/plain", "BAD ARGS");String path = server.arg(0);DBG_OUTPUT_PORT.println("handleFileDelete: " + path);if(path == "/")return server.send(500, "text/plain", "BAD PATH");if(!SPIFFS.exists(path))return server.send(404, "text/plain", "FileNotFound");SPIFFS.remove(path);server.send(200, "text/plain", "");path = String();}void handleFileCreate(){if(server.args() == 0)return server.send(500, "text/plain", "BAD ARGS");String path = server.arg(0);DBG_OUTPUT_PORT.println("handleFileCreate: " + path);if(path == "/")return server.send(500, "text/plain", "BAD PATH");if(SPIFFS.exists(path))return server.send(500, "text/plain", "FILE EXISTS");File file = SPIFFS.open(path, "w");if(file)file.close();elsereturn server.send(500, "text/plain", "CREATE FAILED");server.send(200, "text/plain", "");path = String();}void handleFileList() {if(!server.hasArg("dir")) {server.send(500, "text/plain", "BAD ARGS"); return;}String path = server.arg("dir");DBG_OUTPUT_PORT.println("handleFileList: " + path);Dir dir = SPIFFS.openDir(path);path = String();String output = "[";while(dir.next()){File entry = dir.openFile("r");if (output != "[") output += ',';bool isDir = false;output += "{\"type\":\"";output += (isDir)?"dir":"file";output += "\",\"name\":\"";output += String(entry.name()).substring(1);output += "\"}";entry.close();}output += "]";server.send(200, "text/json", output);}void handleRoot() {server.send(200, "text/html", "<h1>You are connected</h1>");}void setup(void){DBG_OUTPUT_PORT.begin(115200);DBG_OUTPUT_PORT.print("\n");DBG_OUTPUT_PORT.setDebugOutput(true);SPIFFS.begin();{Dir dir = SPIFFS.openDir("/");while (dir.next()) {String fileName = dir.fileName();size_t fileSize = dir.fileSize();DBG_OUTPUT_PORT.printf("FS File: %s, size: %s\n", fileName.c_str(), formatBytes(fileSize).c_str());}DBG_OUTPUT_PORT.printf("\n");}/* change this block to AP?//WIFI INITDBG_OUTPUT_PORT.printf("Connecting to %s\n", ssid);if (String(WiFi.SSID()) != String(ssid)) {WiFi.mode(WIFI_STA);WiFi.begin(ssid, password);}while (WiFi.status() != WL_CONNECTED) {delay(500);DBG_OUTPUT_PORT.print(".");}DBG_OUTPUT_PORT.println("");DBG_OUTPUT_PORT.print("Connected! IP address: ");DBG_OUTPUT_PORT.println(WiFi.localIP());*///AP blockSerial.println();Serial.print("Configuring access point...");/* You can remove the password parameter if you want the AP to be open. */WiFi.softAP(ssid, password);IPAddress myIP = WiFi.softAPIP();Serial.print("AP IP address: ");Serial.println(myIP);//server.on("/", handleRoot);//server.begin();// Serial.println("HTTP server started");//end AP blockMDNS.begin(host);DBG_OUTPUT_PORT.print("Open http://");DBG_OUTPUT_PORT.print(host);DBG_OUTPUT_PORT.println(".local/edit to see the file browser");//SERVER INIT//list directoryserver.on("/list", HTTP_GET, handleFileList);//load editorserver.on("/edit", HTTP_GET, [](){if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound");});//create fileserver.on("/edit", HTTP_PUT, handleFileCreate);//delete fileserver.on("/edit", HTTP_DELETE, handleFileDelete);//first callback is called after the request has ended with all parsed arguments//second callback handles file uploads at that locationserver.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);//called when the url is not defined here//use it to load content from SPIFFSserver.onNotFound([](){if(!handleFileRead(server.uri()))server.send(404, "text/plain", "FileNotFound");});//get heap status, analog input value and all GPIO statuses in one json callserver.on("/all", HTTP_GET, [](){String json = "{";json += "\"heap\":"+String(ESP.getFreeHeap());json += ", \"analog\":"+String(analogRead(A0));json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));json += "}";server.send(200, "text/json", json);json = String();});server.begin();DBG_OUTPUT_PORT.println("HTTP server started");}void loop(void){server.handleClient();}

author: martinayotte
author_rank: Regular Contributor
timestamp: April 27, 2018, 12:51:01 pm
content: Quote from: metrologist on April 26, 2018, 02:26:03 amYes, WiFi STA credentials are persisted in a specific region of the flash.You need to do a "full erase" before uploading any new sketch.

author: metrologist
author_rank: Super Contributor
timestamp: April 27, 2018, 05:49:03 pm
content: Thanks, I came across that eventually.And the persistent error messages I receive. It does not stay running long. Many had the same problem and there seemed to be dozens of different things people did to "fix" the problem, from code, wiring, board settings, other code bits such as ignore interrupts and some others...Fatal exceptionpanicand rst messages that I posted above - are like ants.