Author Topic: ESP8266-12F (Trouble Getting Started)  (Read 6145 times)

0 Members and 1 Guest are viewing this topic.

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
ESP8266-12F (Trouble Getting Started)
« on: April 04, 2018, 05:43:02 pm »
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 10k
GPIO15 to GND via 10k
GPIO0 to GND
I 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 failed
error: espcomm_open failed

I'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?
 

Offline mdijkens

  • Regular Contributor
  • *
  • Posts: 146
  • Country: nl
Re: ESP8266-12F (Trouble Getting Started)
« Reply #1 on: April 04, 2018, 06:47:01 pm »
Sounds like not enough power
The ESP12F consumes on average 75mA but the 1ms spikes are above 300mA
At least you need a big (>=220uF) cap right between the VCC and GND

Also check that TX>RX and RX>TX
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #2 on: April 04, 2018, 07:35:17 pm »
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.
 

Offline Naguissa

  • Regular Contributor
  • *
  • Posts: 114
  • Country: es
    • Foro de electricidad, electrónica y DIY / HUM en español
Re: ESP8266-12F (Trouble Getting Started)
« Reply #3 on: April 05, 2018, 06:59:55 am »
I don't fully understand the connections. Nano is 5V and ESP needs 3.3V

About 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.

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: ESP8266-12F (Trouble Getting Started)
« Reply #4 on: April 05, 2018, 08:09:26 am »
Make sure the power supply going to VCC is 3.3V! The I/O pins are unofficially tolerant 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.
 

Offline TJ232

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: 00
  • www.esp8266-projects.org
    • ESP8266 Projects
Re: ESP8266-12F (Trouble Getting Started)
« Reply #5 on: April 06, 2018, 05:25:16 am »
Take a look at esp8266-projects.com.
You will find there a lot about, from the CBDB ghetto style programmer to more complex ESP8266 boards like BLMS or nEXTEVO, MPRSx8 Home Automation, MPDMv7.5 MAINS AC Dimmer ,etc.
ESP8266 Projects - www.esp8266-projects.org
MPDMv4 Dimmer Board available on Tindie: https://www.tindie.com/stores/next_evo1/
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #6 on: April 06, 2018, 01:19:29 pm »
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.
 

Offline mdijkens

  • Regular Contributor
  • *
  • Posts: 146
  • Country: nl
Re: ESP8266-12F (Trouble Getting Started)
« Reply #7 on: April 06, 2018, 03:07:45 pm »
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.

Have 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
 

Offline Naguissa

  • Regular Contributor
  • *
  • Posts: 114
  • Country: es
    • Foro de electricidad, electrónica y DIY / HUM en español
Re: ESP8266-12F (Trouble Getting Started)
« Reply #8 on: April 06, 2018, 11:48:48 pm »
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.

Still, RX and TX are being driven at 3.3 or 5V?

Online westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
Re: ESP8266-12F (Trouble Getting Started)
« Reply #9 on: April 07, 2018, 12:18:45 am »
The ESP8266 needs some relatively complicated boot sequence involving GPIO pins beyond Rx/Tx/Reset.
See https://github.com/espressif/esptool/wiki/ESP8266-Boot-Mode-Selection
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #10 on: April 07, 2018, 12:58:35 am »
If it's not hardware, what about software?

I read one post about baud rate. 115200

What 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  :-[
 

Offline mdijkens

  • Regular Contributor
  • *
  • Posts: 146
  • Country: nl
Re: ESP8266-12F (Trouble Getting Started)
« Reply #11 on: April 07, 2018, 06:17:48 am »
It is 'normal' that the sketch has that size. There are lots of libs going in there also

So use:
3.3V power
220uF or more cap
3.3V RX/TX (GPIO3/GPIO1)
EN to VCC
GPIO0 and GPIO15 to GND

In AIDE use:
Generic ESP8266
Flashmode QIO
IwIP 1.4 prebuilt
reset ck
crystal 26MHz
Flash 40MHz
Speed 115kbps (very rare somteimes 57600)
 

Online westfw

  • Super Contributor
  • ***
  • Posts: 4196
  • Country: us
Re: ESP8266-12F (Trouble Getting Started)
« Reply #12 on: April 07, 2018, 09:12:06 am »
Quote
Quote
Also, why is blink 246kB? Aside from setup and loop, that's 5 lines  [img alt=:-[]https://www.eevblog.com/forum/Smileys/default/embarrassed.gif
It is 'normal' that the sketch has that size. There are lots of libs going in there also
I 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_input
402091ec 00000285 t dns_recv
40228a60 0000029a T register_chipv6_phy_init_param
4022da24 000002a7 T pm_onBcnRx
40220294 000002ae T get_flash_bin_len
4021e71c 000002da T umm_info
4020680c 000002dc T _vfiprintf_r
402094c8 000002e1 T dns_gethostbyname_addrtype
40225094 000002eb T ram_set_channel_freq
402083b8 000002ee T tcp_slowtmr
4022ab34 000002fa T tx_pwctrl_cal
4020f688 00000300 T rijndaelKeySetupEnc
402334dc 00000317 t handle_dhcp
402166c4 00000386 T ieee80211_sta_new_state
402026a8 000003b3 T _printf_i
4021a47c 000003cf T wpa_receive
4021a8f0 000003fa T __wpa_send_eapol
4020f1c4 00000416 T rijndaelEncrypt
40227f7c 00000418 T phy_bb_rx_cfg
4020cab8 00000463 t dhcp_recv
4020ba18 00000467 T tcp_output
4022925c 00000470 T register_chipv6_phy
402106c0 000004b1 T hostap_input
40202a5c 000004bc W _scanf_float
40212798 000004f6 T ieee80211_parse_beacon
4020209c 00000504 W _printf_float
40213f48 00000594 T ieee80211_send_mgmt
402097e8 000005a3 t tcp_receive
40209ec0 00000a57 T tcp_input
40204200 00000cd2 T _dtoa_r
4020314c 00000d76 T _strtod_r


Since 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...
 

Offline TJ232

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: 00
  • www.esp8266-projects.org
    • ESP8266 Projects
Re: ESP8266-12F (Trouble Getting Started)
« Reply #13 on: April 07, 2018, 09:16:10 am »
This is probably the simplest ESP8266 + CH340 adapter/interface board:



More details, schematics, PCB, etc here: ESP8266 CBDB devboard description and schematics


ESP8266 Projects - www.esp8266-projects.org
MPDMv4 Dimmer Board available on Tindie: https://www.tindie.com/stores/next_evo1/
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266-12F (Trouble Getting Started)
« Reply #14 on: April 07, 2018, 09:24:10 am »
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.
He’s like a trained ape. Without the training.
 

Offline mdijkens

  • Regular Contributor
  • *
  • Posts: 146
  • Country: nl
Re: ESP8266-12F (Trouble Getting Started)
« Reply #15 on: April 07, 2018, 12:25:00 pm »
I can only answer for myself and I am a very happy user of Wemos and Nodemcu boards too

But 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
« Last Edit: April 07, 2018, 12:29:33 pm by mdijkens »
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #16 on: April 12, 2018, 05:31:35 pm »
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.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: ESP8266-12F (Trouble Getting Started)
« Reply #17 on: April 12, 2018, 08:42:51 pm »
You need a pull-up on the reset line.
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #18 on: April 14, 2018, 03:02:55 pm »
It is 'normal' that the sketch has that size. There are lots of libs going in there also

So use:
3.3V power
220uF or more cap
3.3V RX/TX (GPIO3/GPIO1)
EN to VCC
GPIO0 and GPIO15 to GND

In AIDE use:
Generic ESP8266
Flashmode QIO
IwIP 1.4 prebuilt
reset ck
crystal 26MHz
Flash 40MHz
Speed 115kbps (very rare somteimes 57600)

I do not have prebuilt, rather it's "compile from source" or "Bandwidth". It was set to "v2 Lower Memory"
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #19 on: April 20, 2018, 08:15:06 pm »
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.
 

Offline Naguissa

  • Regular Contributor
  • *
  • Posts: 114
  • Country: es
    • Foro de electricidad, electrónica y DIY / HUM en español
Re: ESP8266-12F (Trouble Getting Started)
« Reply #20 on: April 21, 2018, 04:37:57 am »
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.

Offline mdijkens

  • Regular Contributor
  • *
  • Posts: 146
  • Country: nl
Re: ESP8266-12F (Trouble Getting Started)
« Reply #21 on: April 21, 2018, 02:22:52 pm »
Yep, 74880 baud is the 'default' to monitor serial

When booted with
CH_EN = High
GPIO15 = Low
GPIO2 = High (just to be sure)
GPIO0 = High
You should see a mode(3,6) or mode(3,7) boot

With
GPIO0 = Low
You 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)
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #22 on: April 22, 2018, 05:07:18 pm »
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=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
...

Oh wait, it's uploading now.    :box:

It's blinking. Yay!
« Last Edit: April 22, 2018, 05:11:13 pm by metrologist »
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2199
  • Country: 00
Re: ESP8266-12F (Trouble Getting Started)
« Reply #23 on: April 26, 2018, 02:26:03 am »
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: [Select]
ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld

FS File: /edit.htm.gz, size: 4.02KB
FS File: /favicon.ico, size: 1.12KB
FS File: /graphs.js.gz, size: 1.92KB
FS File: /index.htm, size: 3.63KB
scandone
state: 0 -> 2 (b0)


Configuring access point...AP IP address: 192.168.4.1
Open [url]http://esp8266fs.local/edit[/url] to see the file browser
HTTP server started
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt

connected with HOME-SSID, channel 1
dhcp client start...
ip:192.168.1.70,mask:255.255.255.0,gw:192.168.1.254
add 1
aid 1
station: fc:db:b3:49:d6:58 join, AID = 1
handleFileRead: /
handleFileRead: /
handleFileRead: /graphs.js
handleFileRead: /favicon.ico


Code: [Select]
/*
  FSWebServer - Example WebServer with SPIFFS backend for esp8266
  Copyright (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/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 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 of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
  upload 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; done
 
  access the sample web page at [url]http://esp8266fs.local[/url]
  edit the page by going to [url]http://esp8266fs.local/edit[/url]
*/
#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 upload
File fsUploadFile;

//format bytes
String 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();
  else
    return 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 INIT
  DBG_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 block
  Serial.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 block




  MDNS.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 directory
  server.on("/list", HTTP_GET, handleFileList);
  //load editor
  server.on("/edit", HTTP_GET, [](){
    if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound");
  });
  //create file
  server.on("/edit", HTTP_PUT, handleFileCreate);
  //delete file
  server.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 location
  server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);

  //called when the url is not defined here
  //use it to load content from SPIFFS
  server.onNotFound([](){
    if(!handleFileRead(server.uri()))
      server.send(404, "text/plain", "FileNotFound");
  });

  //get heap status, analog input value and all GPIO statuses in one json call
  server.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();
}

 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: ESP8266-12F (Trouble Getting Started)
« Reply #24 on: April 27, 2018, 12:51:01 pm »
TL;DR does ESP remember wifi credentials after removing them from sketch and reloading?
...
How is that possible? I removed my SSID and PW from the sketch. DOES ESP remember these settings?
Yes, WiFi STA credentials are persisted in a specific region of the flash.
You need to do a "full erase" before uploading any new sketch.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf